The JVM Tool Interface (JVM TI) is a native (C/C++) programming interface that can be used by a wide range of development and monitoring tools. JVM TI provides an interface for the full breadth of tools that need access to VM state, including but not limited to profiling, debugging, monitoring, thread analysis, and coverage analysis tools.
Some examples of agents that rely on JVM TI are the following:
HPROF
Java Debug Wire Protocol (JDWP)
The java.lang.instrument
package
The specification for JVM TI can be found in the JVM Tool Interface documentation.
The JDK includes example code that demonstrates the usage of JVM TI. These examples can be found in the $JAVA_HOME/demo/jvmti
directory. Some of the example codes are as follows:
mtrace
is an agent library that tracks method call and return counts. It uses bytecode instrumentation to instrument all classes loaded into the virtual machine and prints a sorted list of the frequently used methods.
heapTracker
is an agent library that tracks object allocation. It uses bytecode instrumentation to instrument constructor methods.
heapViewer
is an agent library that prints heap statistics when the Control+Break handler is invoked. For more information, see Control+Break Handler. For each loaded class it prints an instance count of that class and the space used.