yazz.com
yazz.com

Reputation: 58796

What is the most future-proof way to perform Java bytecode instrumentation?

I wish to perform Java bytecode instrumentation from JDK 1.5 onwards. Is there a way to do this that works across most JVMs and is supported in future versions of the JDK?

Upvotes: 2

Views: 132

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533720

I suggest you use a library which abstracts away the reading/writing of raw byte code. Like ASM. This way any future changes may be fixed by updating the library. Also many of these have gone through many version changes already and have a structure which is farily version proof.

Having said that, there are very few byte code changes between JVM versions. Given the chance to change the byte code or to put in work around, the later appears to always be used. e.g. Java has supported inner classes accessing private member of outer classes for many years, however the JVM doesn't support this directly (instead a work around is used by the compiler)

Upvotes: 1

Related Questions