`Summary
Add a mechanism to jcmd (VM.classes) to list the location/origin of class files for loaded classes.
Problem
It is useful for both audit and debugging purposes to be able to correlate loaded classes with the location/origin of their respective class files.
Solution
The original ER requested a jcmd to list all the .jar files loaded by the JVM.
After some initial investigation it became apparent that implementing this in either Java, or native code, dependent upon the state currently available from the implementation of, either the ClassLoader,
VM internal state, or by direct interrogation of the O.S itself was not viable;
such state either does not exist, or is ephemeral in nature, and there appeared to be no clear solution by adding code to capture such.
Since the actual requirement underlying the original ER was in fact to be able to correlate loaded classes with the location/origin of their associated class files other alternatives were investigated.
Since the current defineClass interface between ClassLoader and the JVM includes a method variant that includes the source of the class to be loaded by the JVM, and this value is persisted by the JVM when provided, a solution using this metadata combined with the existing VM.classes jcmd was identified and a -location option added to that jcmd to enable the printing of this information.
Specification
The VM.classes jcmd is modified with the following option:
-location: (Optional) Print the location of the class file from which the class is loaded (if available)
If provided by its defining ClassLoader, this option will print a URL specifying the location of the
class file (directory, jar or other URL location) from which this class was initially loaded.
Note: JDK (and other classes) loaded by a `ClassLoader` that does not provide a location URL to the JVM will omit this field.
Note: if any classes are loaded from an AOT cache, their location reported is that of the original
url from which they were loaded at the time of the training run that created the AOT cache,
additionally the class flag `S` when printed will also be annotated to indicate the AOT cache origin (`s`tatic or `d`ynamic).
The total number of classes loaded (if any) from either AOT cache (and the associated cache path location) are summarized.
- csr of
-
JDK-8327246 Add a jcmd diagnostic command to list the jar files loaded by a process
-
- In Progress
-