Reputation: 1
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.
Upvotes: 0
Views: 212
Reputation: 1908
you could try to use -bootclasspath/p
instead of -jar
, probably, something is loaded too early for your util-class or some classloader-issue (e.g. a different (custom) classloader which cannot access your jar). if you put your jar into the bootclasspath, at least this source of defect is eliminated
Upvotes: 1