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.

1
  • typo? or do you really mean instur/Util? Commented Apr 15, 2013 at 8:51

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.