I've attached a sample JVMTI agent to demonstrate the issue.
On macOS, the agent can be built with with
gcc -dynamiclib -o libagent.dylib -I $JAVA_HOME/include -I$JAVA_HOME/include/darwin agent.c
The agent does the following:
1. calls GetSystemProperty to get the value of jdk.boot.class.path.append
2. calls AddToBootClassLoadSearch to add to the "two.jar" to the boot class loader search
3. calls GetSystemProperty again to get the updated value of jdk.boot.class.path.append
Consider the following:
$ java -agentlib:agent -Xbootclasspath/a:one.jar -version
The initial value of the system property is ":one.jar". Note the spurious path separator.
Now try:
$ java -agentlib:agent -version
The initial value of the property is the empty string. I expected the function would fail with JVMTI_ERROR_NOT_AVAILABLE because -Xbootclasspath/a was not specified.
The value changes to ":two.jar" after AddToBootClasspathSearch has been called to append to the boot class path. Again, note the spurious path separator.
On macOS, the agent can be built with with
gcc -dynamiclib -o libagent.dylib -I $JAVA_HOME/include -I$JAVA_HOME/include/darwin agent.c
The agent does the following:
1. calls GetSystemProperty to get the value of jdk.boot.class.path.append
2. calls AddToBootClassLoadSearch to add to the "two.jar" to the boot class loader search
3. calls GetSystemProperty again to get the updated value of jdk.boot.class.path.append
Consider the following:
$ java -agentlib:agent -Xbootclasspath/a:one.jar -version
The initial value of the system property is ":one.jar". Note the spurious path separator.
Now try:
$ java -agentlib:agent -version
The initial value of the property is the empty string. I expected the function would fail with JVMTI_ERROR_NOT_AVAILABLE because -Xbootclasspath/a was not specified.
The value changes to ":two.jar" after AddToBootClasspathSearch has been called to append to the boot class path. Again, note the spurious path separator.
- relates to
-
JDK-8225093 Special property jdk.boot.class.path.append should not default to empty string
-
- Resolved
-
-
JDK-8144730 AddToBootstrapClassLoaderSearch replaces jdk.boot.class.path.append value set by SetSystemProperty
-
- Resolved
-