I am using ASM with java agents. I have the following problem. Whenever I see a "PUTFIELD" instruction within a method call, I want call a method from my agent library.
if (opcode == PUTFIELD) {
super.visitMethodInsn(Opcodes.INVOKESTATIC, "instrumenter/Util", "debug", "()V");
Util
is a class defined by me with a static debug
method. It stays in my agent.jar
java -javagent:agent.jar -jar test.Test
works as I expected.
However, when I test this agent with some other jar files I got following error.
Exception in thread "main" java.lang.NoClassDefFoundError: instrumenter/Util
I suspect this occurs due to concurrency. Since the programs which create this error are mostly multi-threaded.