Reputation: 210
I am trying to add a static method call to the java.lang.Object constructor using the java.lang.instrument API. I know I have the basics right because it works if I make the method call System.gc(). I verified this by running -verbosegc with and without the instrumentation. If I change the method call to a static class/method in my own package I get a fatal error:
Exception in thread "main" FATAL ERROR in native method: processing of -javaagent failed
No dump files are created in the working directory so I am finding it hard to figure out what's wrong. Other info:
Thanks in advance.
Upvotes: 3
Views: 2312
Reputation: 7779
Yes, as @barry noted in his comment, you have to add to the Java Agent's manifest the Boot-Class-Path
definition. For me, I used javassist within my agent to create the bytecode, so my manifest looks like this:
Manifest-Version: 1.0
Premain-Class: com.company.agent.Agent
Agent-Class: com.company.agent.Agent
Boot-Class-Path: javassist-3.18.2-GA.jar agent.jar
I have all my application's jar files in the same lib directory as the javassist and agent jars. With everything on the classpath, in the same folder, it works.
Upvotes: 1