Is it possible to inherit a final class modifying bytecode somehow?

是否有可能继承使用字节码操作的最终类?


Yes and no.

You can use bytecode manipulation to change a final class to non- final on the fly. This doesn't even break binary compatibility, so there is no risk of class loader / verifier errors.

However, you have to apply the bytecode modifications to the final class itself. You can't do bytecode manipulation on a child class to make it inherit from a final parent class. Or more precisely, if you do that the modified child class will be rejected by the verifier when loaded together with the final parent class.


This describes the class file format. At the offset 10+cpsize there are 2 bytes defining the access flags of this class. One of these flags is called ACC_FINAL (0x0010). I suppose you can mask that bit out and make that class non-final.

链接地址: http://www.djcxy.com/p/69630.html

上一篇: 为什么Minified Code不等于原来的?

下一篇: 是否有可能以某种方式继承修改字节码的最终类?