I heard that many frameworks (Struts, Spring, Hibernate, AspectJ) use bytecode manipulation internally. What are the compelling reasons to use bytecode manipulation? I'm expecting a answer with at least a use-case for each particular framework.
These frameworks manipulate the bytecode of your classes so that they can add support for their features into them. For example, Hibernate may code into getters/setters of a class in order to help it track when the entity has been updated (become dirty) and/or to return proxies of sub-entities that contain code to do lazy-loading.
Aspectj manipulates bytecode in order to add the aspects that you have requested it to enforce. For example, if you want to add advice to all the methods of a class to log when they are invoked, then aspectj may add bytecode (that performs that logging) to each method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With