The Java Attach API has a pluggable provider architecture. The dynamic join provider is specific to the target virtual machine. In the case of Oracle or OpenJDK, the JVM is responsible for the Sun provider. This provider uses various methods, depending on the operating system. The protocol also supports other facilities (for example, jcmd )
For Linux, it uses the following protocol:
- compile the pid of the target JVM and create flaffile
/tmp/.attach_pid%d - send SIGQUIT to the target JVM
- in the target JVM, the signal handler will start attaching a listener thread if the flag file exists.
- A socket of the domain
/tmp/.java_pid%d unix will be created in the attachment listener thread and will listen to this socket for commands - a typical
load command that tells the target JVM to load an agent implementation. This is implied in shared attachListener.cpp and loads the JVMTI agent.
The method used for JMX is "load", which loads the specified JVMTI agent and then connects regularly through RMI.
Older versions of Java use java.io.tmpdir or even environment-related temporary directories, for later versions / tmp, however, are hard-coded.
Solaris uses IPC Door instead of a unix domain socket. Windows uses CreateRemoteThread with the name of the named pipe for this bootstrap.
This is described here: http://openjdk.java.net/groups/hotspot/docs/Serviceability.html#tattach (I did not check, but I would expect the HP port to use the Linux engine, OpenJDK AIX port).
The IBM JDK uses a similar mechanism (with a larger configuration): https://www.ibm.com/support/knowledgecenter/en/SSYKE2_7.0.0/com.ibm.java.win.70.doc/user/attachapi.html
eckes source share