Reputation: 199224
All the references I've found on the web says the bytecode 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.
Upvotes: 5
Views: 909
Reputation: 49187
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.
Upvotes: 3