OscarRyz
OscarRyz

Reputation: 199224

Is it possible to modify the bytecode and save it with javassist?

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

Answers (1)

Johan Sjöberg
Johan Sjöberg

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

Related Questions