I am writing a Java agent to interact with the JVMTI. For reasons that I wonโt fall into, I need to use the JVMTI (C interface inside the java process) rather than the Java API like java.lang.instrument or JDI. I would like to be able to do a couple of things that do not seem to be supported directly.
- Is there a way to load the agent after the Java process is already running?
- Is there a way to unload a Java agent (without waiting for the entire Java process to be killed), either from JVMTI code or from outside the process? For example, is it safe to call
dlclose() from JVMTI code if I can find a handle to a dynamically loaded module?
If these operations cannot be performed, is there a way to pass data to the Java agent after it is downloaded? Is there a normal way to do this through some Java command line utility? If not, can I safely create a stream and listen on a socket using standard C or C ++ library calls in the code for my agent?
If this helps, donโt worry about Windows support with the answer - Iโm taking this project to expand the Unix debugging tool.
Note: I already saw this one , but thought there might be some normal way to do this, which is not in the JVMTI standard.
source share