Hi all,
We get the ExceptionInInitializerError when using the method
jdk.nashorn.internal.ir.debug.ObjectSizeCalculator.getObjectSize on our openjdk
build. the exception message says "ObjectSizeCalculator only supported on
HotSpot VM".
After check the source code, we find the exception was throwed by method
getEffectiveMemoryLayoutSpecification:the code is: final String vmName =
System.getProperty("java.vm.name");
if (vmName == null || !vmName.startsWith("OpenJDK"))
throw new UnsupportedOperationException() here is the source
code:http://hg.openjdk.java.net/jdk8u/jdk8u/nashorn/file/91d33aea2714/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java#l397
, and the current jdk9 nashorn source code remains the same:
http://hg.openjdk.java.net/jdk9/jdk9/nashorn/file/a9c819c3c7f6/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java#l397
Since we are building jdk in the openjdk repo and the build's system property
"java.vm.name" starts with "OpenJDK" (e.g., "OpenJDK 64-Bit Server VM"), we are
considering maybe this code can be changed to !vmName.startsWith("OpenJDK"),
and the exception message should also be changed to "ObjectSizeCalculator only
supported on OpenJDK VM"
Thanks,Tongbao Zhang from Alibaba