All the references I've found on the web says the byte开发者_如何转开发code can be modified at runtime, but I don't seem to find if that modified bytecode could replace the original.
This way the original bytecode could be substituted once, and the rest of the time, use the enhanced afterwards.
Yes, it's called build-time
byte-code instrumentation; javassist
as well as libraries such as aspectj
supports this model.
I've had good experience with the latter in combination with Apache Maven
using the aspectj-maven-plugin.
[Edit] Also see the Implementing Build-time Bytecode Instrumentation With Javassist article.
精彩评论