-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
openjdk8u262
-
None
-
generic
-
generic
Problem reported by one of our users:
import jdk.nashorn.internal.ir.debug.ObjectSizeCalculator;
public class GetObjectSizeDemo {
public static void main(String[] args) {
GetObjectSizeDemo demo = new GetObjectSizeDemo();
try {
long size = ObjectSizeCalculator.getObjectSize(demo);
System.out.println("size = " + size);
} catch (Exception e){
System.out.println(e.getStackTrace());
}
}
}
$ java GetObjectSizeDemo
Exception in thread "main" java.lang.ExceptionInInitializerError
at jdk.nashorn.internal.ir.debug.ObjectSizeCalculator.getObjectSize(ObjectSizeCalculator.java:122)
at GetObjectSizeDemo.main(GetObjectSizeDemo.java:8)
Caused by: java.lang.UnsupportedOperationException: ObjectSizeCalculator only supported on HotSpot VM
at jdk.nashorn.internal.ir.debug.ObjectSizeCalculator.getEffectiveMemoryLayoutSpecification(ObjectSizeCalculator.java:400)
at jdk.nashorn.internal.ir.debug.ObjectSizeCalculator$CurrentLayout.<clinit>(ObjectSizeCalculator.java:102)
... 2 more
Trivial fix:
diff -r f5a3d8f60cf5 src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java
--- a/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Tue May 19 05:11:20 2020 +0100
+++ b/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Fri May 22 15:50:37 2020 +0800
@@ -396,7 +396,8 @@
*/
public static MemoryLayoutSpecification getEffectiveMemoryLayoutSpecification() {
final String vmName = System.getProperty("java.vm.name");
- if (vmName == null || !vmName.startsWith("Java HotSpot(TM) ")) {
+ if (vmName == null
+ || (!vmName.startsWith("OpenJDK ") && !vmName.startsWith("Java HotSpot(TM) "))) {
throw new UnsupportedOperationException(
"ObjectSizeCalculator only supported on HotSpot VM");
}
import jdk.nashorn.internal.ir.debug.ObjectSizeCalculator;
public class GetObjectSizeDemo {
public static void main(String[] args) {
GetObjectSizeDemo demo = new GetObjectSizeDemo();
try {
long size = ObjectSizeCalculator.getObjectSize(demo);
System.out.println("size = " + size);
} catch (Exception e){
System.out.println(e.getStackTrace());
}
}
}
$ java GetObjectSizeDemo
Exception in thread "main" java.lang.ExceptionInInitializerError
at jdk.nashorn.internal.ir.debug.ObjectSizeCalculator.getObjectSize(ObjectSizeCalculator.java:122)
at GetObjectSizeDemo.main(GetObjectSizeDemo.java:8)
Caused by: java.lang.UnsupportedOperationException: ObjectSizeCalculator only supported on HotSpot VM
at jdk.nashorn.internal.ir.debug.ObjectSizeCalculator.getEffectiveMemoryLayoutSpecification(ObjectSizeCalculator.java:400)
at jdk.nashorn.internal.ir.debug.ObjectSizeCalculator$CurrentLayout.<clinit>(ObjectSizeCalculator.java:102)
... 2 more
Trivial fix:
diff -r f5a3d8f60cf5 src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java
--- a/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Tue May 19 05:11:20 2020 +0100
+++ b/src/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Fri May 22 15:50:37 2020 +0800
@@ -396,7 +396,8 @@
*/
public static MemoryLayoutSpecification getEffectiveMemoryLayoutSpecification() {
final String vmName = System.getProperty("java.vm.name");
- if (vmName == null || !vmName.startsWith("Java HotSpot(TM) ")) {
+ if (vmName == null
+ || (!vmName.startsWith("OpenJDK ") && !vmName.startsWith("Java HotSpot(TM) "))) {
throw new UnsupportedOperationException(
"ObjectSizeCalculator only supported on HotSpot VM");
}
- duplicates
-
JDK-8171934 ObjectSizeCalculator.getEffectiveMemoryLayoutSpecification() does not recognize OpenJDK's HotSpot VM
- Resolved