Well, I tried debugging this a little further an found that the cause of the warning is InstrumentationSupport
trying DYNAMIC_ATTACH on the application startup. The relevant section of dynamicAttach
where the code actually makes use of the VirtualMachine
is
String name = "com.sun.tools.attach.VirtualMachine";
try {
// JDK 9+ makes this class available on class path
vmClass = ClassLoader.getSystemClassLoader().loadClass(name);
...
The class is not loaded with initially resolved modules since its package is exported from jdk.attach
module which is currently missing from the module descriptor. Hence you can update to using the module declarations as :
module java9 { // module name 'joltrial' in output
requires jol.core;
requires jdk.attach;
}
and then allow self-attach further using the VM option as:-
-Djdk.attach.allowAttachSelf=true
On executing the shared code [VM.current().details()
], the output shall include details as -
/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/java -Djdk.attach.allowAttachSelf=true "-javaagent:/Applications/IntelliJ IDEA 2017.3 CE EAP.app/Contents/lib/idea_rt.jar=53783:/Applications/IntelliJ IDEA 2017.3 CE EAP.app/Contents/bin" -Dfile.encoding=UTF-8 -p .../joltrial/target/classes:.../.m2/repository/org/openjdk/jol/jol-core/0.9/jol-core-0.9.jar -m joltrial/com.Sample
# WARNING: Unable to attach Serviceability Agent. Unable to attach even with module exceptions: [org.openjdk.jol.vm.sa.SASupportException: Sense failed., org.openjdk.jol.vm.sa.SASupportException: Sense failed., org.openjdk.jol.vm.sa.SASupportException: Sense failed.]
# Running 64-bit HotSpot VM.
# Using compressed oop with 3-bit shift.
# Using compressed klass with 3-bit shift.
# WARNING | Compressed references base/shifts are guessed by the experiment!
# WARNING | Therefore, computed addresses are just guesses, and ARE NOT RELIABLE.
# WARNING | Make sure to attach Serviceability Agent to get the reliable addresses.
# Objects are 8 bytes aligned.
# Field sizes by type: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
# Array element sizes: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
Process finished with exit code 0
--add-opens java.base/java.util=ALL-UNNAMED
as per this – Orvilleorwell0.7
– Epaminondas