5

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.

Eugene
  • 117,005
  • 15
  • 201
  • 306
OscarRyz
  • 196,001
  • 113
  • 385
  • 569

1 Answers1

3

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.

Johan Sjöberg
  • 47,929
  • 21
  • 130
  • 148
  • That was what I was looking for. Thanks. Looks like it is possible, trying right now! – OscarRyz Mar 04 '11 at 18:34
  • If anyone want to see the sample ( in spanish ) here's the link: http://www.javamexico.org/blogs/oscarryz/nano_ejemplo_de_javassist Just look at the code, is self explaining – OscarRyz Mar 05 '11 at 03:59