这是我的openj9版本:
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.24.0, JRE 11 Linux amd64-64-Bit Compressed References 20210120_910 (JIT enabled, AOT enabled)
OpenJ9 - 345e1b09e
OMR - 741e94ea8
JCL - 0a86953833 based on jdk-11.0.10+9)当我在像HotSpot这样的其他JVM中运行以下程序时:
package dacapo6_26;
class Option {
public boolean isRequired() {
try {
OutOfMemoryError var6 = new OutOfMemoryError("java.lang.OutOfMemoryError in ThrowCatch without counter");
var6.initCause(new OutOfMemoryError("java.lang.OutOfMemoryError as cause exception"));
throw var6;
} catch (OutOfMemoryError var3) {
/*
The calling of var3.initCause would throw an IllegalStateException,
since var6 has EXPLICITLY set a cause exception at line 7.
*/
var3.initCause(new NoSuchMethodException("Cause Exception"));
}
return true;
}
}
public class Harness {
public static void main(String[] args) {
try {
Option option = new Option();
System.out.println(option.isRequired());
} catch (Exception var11) {
/*
The calling of var11.initCause would throw an IllegalStateException,
since var11 has IMPLICITLY set a cause exception at line 14.
*/
var11.initCause(new NoSuchMethodException("Cause Exception"));
System.err.println("should not reach here");
}
}
}结果是:
Exception in thread "main" java.lang.IllegalStateException: Can't overwrite cause with java.lang.NoSuchMethodException: Cause Exception
at java.base/java.lang.Throwable.initCause(Throwable.java:462)
at dacapo6_26.Harness.main(Harness.java:33)
Caused by: java.lang.IllegalStateException: Can't overwrite cause with java.lang.NoSuchMethodException: Cause Exception
at java.base/java.lang.Throwable.initCause(Throwable.java:462)
at dacapo6_26.Option.isRequired(Harness.java:12)
at dacapo6_26.Harness.main(Harness.java:29)
Caused by: java.lang.OutOfMemoryError: java.lang.OutOfMemoryError in ThrowCatch without counter
at dacapo6_26.Option.isRequired(Harness.java:6)
... 1 more
Caused by: java.lang.OutOfMemoryError: java.lang.OutOfMemoryError as cause exception
at dacapo6_26.Option.isRequired(Harness.java:7)
... 1 more但是在OpenJ9上运行时,结果是:
should not reach here结果是预期的,还是OpenJ9中的一个bug?
OpenJ9是否遗漏了在var3.initCause(new NoSuchMethodException("Cause Exception"));行获得的cause字段信息?
谢谢!
发布于 2022-05-03 11:47:56
此差异已得到纠正;请参见https://github.com/eclipse-openj9/openj9/pull/14877。修复应该在下一个(0.33.0)版本的OpenJ9中。
https://stackoverflow.com/questions/72075378
复制相似问题