1) Take the can only with META-INF/MANIFEST.MF
the manifest must be properly configured using Premain-Class and other attributes. The bank does not need any other files. Use this jar with -javaagent . If the agent classes are in the class path, the agent starts normally.
This can lead to an error when using maven-surefire-plugin with forkMode=never , since by default application classes are loaded into the child class of ClassLoader.
Works great with Eclipse and Intellij.
If you do this, double-check the syntax of the manifest (I once spent a lot of time figuring out that the package name was wrong).
It will allow you to load the agent (any agent) at runtime (it uses VM.attach() ). However, VM.attach() sometimes interrupts debugging, and breakpoints may not start.
It will have the same problems with surefire in forkMode = never
3) Download the agent at run time.
Write your code on the agent download at runtime . And name it from @BeforeClass . You still need a jar (which you can create at runtime if you want).
You just need to call this (only once):
AgentLoader.loadAgentClass(YourAgentClass.class.getName());
Daniel Sperry
source share