0

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.

janiss
  • 1
  • 2

1 Answers1

1

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

wrm
  • 1,898
  • 13
  • 24