javajvmjava-bytecode-asm

How to find out whether the ASM java instrumentation happens at compile time OR at runtime?


I am a bit new to the Java ecosystem. I am reading the ASM way (in this doc https://www.baeldung.com/java-asm ) to do Java instrumentation.

And I don't know when ASM changes the byte code, to be specific it takes effect in compile time and changes the class directly OR it changes the code at the runtime of class loading.


Solution

  • The ASM library is not responsible for changing bytecode at all. It’s a tool for transforming a sequence of bytes (in the class file format) into another sequence of bytes (again in the class file format), though you could also use it for just analyzing class files or generating class files from scratch.

    So what you get at the end, is just a byte array.

    Since it’s your own responsibility to use this byte array to effectively change a class (if that’s what you want), you are the one deciding how and when the changes apply.