It would be possible to change the Java bytecode of your classes?
It would be possible to create new procedures and change the body of his methods, even at runtime?
Yes, the answer is yes, this is possible!
Thanks to the APIs lowest level or higher level as java.lang.instrumentat and Apache BCEL among others.
For better transparency, you can always automatically generate code and add it to their classes. There are several frameworks. The java developer may be adding a simple enhancer code in their applications, which is relatively easy to do, with little intrusion into your creative process.
It would be possible to create new procedures and change the body of his methods, even at runtime?
Yes, the answer is yes, this is possible!
Thanks to the APIs lowest level or higher level as java.lang.instrumentat and Apache BCEL among others.
For better transparency, you can always automatically generate code and add it to their classes. There are several frameworks. The java developer may be adding a simple enhancer code in their applications, which is relatively easy to do, with little intrusion into your creative process.
Byte code enhancement
Programs written in Java to compile a form of code called bytecode. The idea is through instrumentation, inject byte code to add services and still maintain transparency. For example, most implementations use an enhancer JDO bytecode.
Another excellent example was a project at IBM where test scenarios were created dynamically through bytecode instrumentation.
Often inject a code snippet actually is to inject methods that perform the work of their service it is intended, as with the intensifier source code in Figure below. Enhancement of the source code has a class as an input and then generate code, often called method to inject resources into service code, fully preserving transparency in the original class. Amazing, no?
Another excellent example was a project at IBM where test scenarios were created dynamically through bytecode instrumentation.
Often inject a code snippet actually is to inject methods that perform the work of their service it is intended, as with the intensifier source code in Figure below. Enhancement of the source code has a class as an input and then generate code, often called method to inject resources into service code, fully preserving transparency in the original class. Amazing, no?
JDO enhancers work like this: you create a class that is transparent with respect to persistence. The technique has many benefits:
- You do not have to make any changes to the source code. Ual!
- You do not imposes any restriction on their class, to completely preserve transparency.
- Code injection is fast at runtime. You have affected performance only in Build-time
Tasks like adding logs, code instrumentation for performance analysis, or methods of intercepting calls work fine with a simple injector code.
- You do not have to make any changes to the source code. Ual!
- You do not imposes any restriction on their class, to completely preserve transparency.
- Code injection is fast at runtime. You have affected performance only in Build-time
Tasks like adding logs, code instrumentation for performance analysis, or methods of intercepting calls work fine with a simple injector code.
To have a deeper understanding of the topic, I recommend reading the following link:
http://docs.oracle.com/javase/7/docs/api/java/lang/instrument/package-summary.html
http://pt.wikipedia.org/wiki/Programa%C3%A7%C3%A3o_orientada_a_aspecto
http://pt.wikipedia.org/wiki/AspectJ
http://docs.oracle.com/javase/7/docs/api/java/lang/instrument/package-summary.html
http://pt.wikipedia.org/wiki/Programa%C3%A7%C3%A3o_orientada_a_aspecto
http://pt.wikipedia.org/wiki/AspectJ
Comments
Post a Comment