Question

I am using jdk 1.6. I attached an agent to a target jvm and sent several arguments. Is it possible to reuse the agent running in the target jvm, since my several arguments have changed? I want to program in the agent doing new job using new value of these arguments. Does any one have similar experiences? thanks

No correct solution

OTHER TIPS

Of course you can reuse an agent's implementation. A Java agent, represented by some method

public static void premain(String agentArgs, Instrumentation inst); 

is treated like any Java class. The only thing is that this agent is invoked before the main entry point of the normal Java application. Additionally, the agent offers a possibility to easily add Instrumentation. You could refactor your agent to come within its own bundle and add the agent to any program by just adding the agent's bundle to the program's class path. The agent is basically just a normal Java program that gets invoked before the Java program that was declared in a manifest file or as the explicit program entry point in the command line.

Just be aware that any classes that must be loaded in order to load the agent can no longer be intercepted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top