0
点赞
收藏
分享

微信扫一扫

javassist frozen classes

40dba2f2a596 2022-02-18 阅读 47


Frozen classes

If a ​​CtClass​​​ object is converted into a class file by ​​writeFile()​​​, ​​toClass()​​​, or ​​toBytecode()​​​, Javassist freezes that ​​CtClass​​​ object. Further modifications of that ​​CtClass​​ object are not permitted. This is for warning the developers when they attempt to modify a class file that has been already loaded since the JVM does not allow reloading a class.

A frozen ​​CtClass​​ can be defrost so that modifications of the class definition will be permitted. For example,

CtClasss cc = ...;
:
cc.writeFile();
cc.defrost();
cc.setSuperclass(...); // OK since the class is not frozen.

After ​​defrost()​​​ is called, the ​​CtClass​​ object can be modified again.


举报

相关推荐

0 条评论