whenever I try to attach an agent to the JVM I get this error: Failed to find Agent-Class manifest attribute from /Users/yanjobs/Downloads/Dumper-master-2/out/artifacts/Dumper_master_2_jar/Dumper-master-2.jar
. But when I try to add this parameter (Agent-Class) to my MANIFEST.MF
the JVM throws me this nice error: Exception in thread "Attach Listener" Agent failed to start!
and IntelliJ says Invalid agent class (screenshot here). So... What should I do?
I posted the source here.
If someone got the time to help me, that would be nice :)
You added this to your manifest:
Premain-Class: me.accessmodifier364.dumper.Dumper
Agent-Class: me.accessmodifier364.dumper.Dumper
But you forgot to add this to your agent:
public static void agentmain(String agentArgs, Instrumentation inst) {
System.out.println("Hot-attaching Dumper...");
premain(agentArgs, inst);
}
How about reading a full tutorial? You might start with this one, based on Javassist. But instead of Javassist, you may also use whichever tool you prefer, such as Byte Buddy, ASM, BCEL. The basic code structure (manifest, agent main class, transformer) is the same in all cases.