The attached test file TestC2Miscompile.java prints:
$ java TestC2Miscompile.java
true
true
false
false
true
true
false
true
true
true
false
true
false
true
false
true
NullPointerException: Cannot invoke "TestC2Miscompile$Class0.Class0_method1()"
true
false
false
Examination of the code shows that the receiver can never be null here. Goes away with either of -Xint or -XX:TieredStopAtLevel=3, so I think this must be a C2 bug.
Reproduced today with OracleJDK 25+5, but goes back at least half a year.
$ java TestC2Miscompile.java
true
true
false
false
true
true
false
true
true
true
false
true
false
true
false
true
NullPointerException: Cannot invoke "TestC2Miscompile$Class0.Class0_method1()"
true
false
false
Examination of the code shows that the receiver can never be null here. Goes away with either of -Xint or -XX:TieredStopAtLevel=3, so I think this must be a C2 bug.
Reproduced today with OracleJDK 25+5, but goes back at least half a year.
- relates to
-
JDK-8316991 Reduce nullable allocation merges
- Resolved