Java – is it possible to inherit and modify the final class of bytecode in some way?

Can I inherit the final class using bytecode operations?

Solution

Yes, No

You can use bytecode operations to change the final class to a non - final class This does not even break binary compatibility, so there is no risk of classloader / verifier errors

However, you must apply bytecode modifications to the final class itself You cannot bytecode a subclass to inherit from the final parent Or more precisely, if you do, the validator will reject the modified subclass when loaded with the final parent

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>