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.
Asked
Active
Viewed 1,330 times
1 Answers
12
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.

jhouse
- 2,674
- 1
- 18
- 17
-
yeah I got your point but how Spring framework & struts2 uses the bytecode manipulation in their framework – Nuwan Arambage Feb 01 '11 at 12:26