-
Bug
-
Resolution: Fixed
-
P3
-
17
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8269454 | 18 | Robo Duke | P3 | Resolved | Fixed | b04 |
JDK-8270641 | 17.0.1 | Robo Duke | P3 | Resolved | Fixed | b03 |
A DESCRIPTION OF THE PROBLEM :
javac crashes at "jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0" with NPE when trying to compile a correct program. The program compiles successfully with 16.0.1 compiler, but crashes with 17.ea.22.
Pasting the error messages below. Also attached the source code with the bug report.
java.lang.NullPointerException: Cannot read field "sym" because "this.lvar[2]" is null
at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:574)
at jdk.compiler/com.sun.tools.javac.jvm.Items$LocalItem.load(Items.java:399)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitTypeTest(Gen.java:2233)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCInstanceOf.accept(JCTree.java:2172)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:783)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:696)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBinary(Gen.java:2136)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:2114)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitParens(Gen.java:2005)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1972)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:783)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:696)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1878)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1475)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitLetExpr(Gen.java:2368)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3120)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitParens(Gen.java:2005)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1972)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1830)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1667)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:610)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:645)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:631)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:682)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1097)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1055)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:610)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:645)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:967)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:930)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:901)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:610)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2407)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:756)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1644)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1612)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
REGRESSION : Last worked in version 16.0.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Main.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compile successfully
ACTUAL -
javac crashes
---------- BEGIN SOURCE ----------
import java.util.function.Supplier;
class Main {
public Integer foo(Object x) {
Integer bar = 1;
return ((x instanceof Number y) ?
((Supplier<Integer>) (() -> {
return ((y instanceof Integer z) ? z : bar);
})).get() : bar);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Remove the bar variable and use an integer value directly.
FREQUENCY : always
javac crashes at "jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0" with NPE when trying to compile a correct program. The program compiles successfully with 16.0.1 compiler, but crashes with 17.ea.22.
Pasting the error messages below. Also attached the source code with the bug report.
java.lang.NullPointerException: Cannot read field "sym" because "this.lvar[2]" is null
at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:574)
at jdk.compiler/com.sun.tools.javac.jvm.Items$LocalItem.load(Items.java:399)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitTypeTest(Gen.java:2233)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCInstanceOf.accept(JCTree.java:2172)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:783)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:696)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBinary(Gen.java:2136)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:2114)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitParens(Gen.java:2005)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1972)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:783)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genCond(Gen.java:696)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitConditional(Gen.java:1878)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCConditional.accept(JCTree.java:1475)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitLetExpr(Gen.java:2368)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3120)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitParens(Gen.java:2005)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1972)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1830)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1667)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:610)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:645)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:631)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:682)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1097)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1055)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:610)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:645)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:967)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:930)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:901)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:610)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2407)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:756)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1644)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1612)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
REGRESSION : Last worked in version 16.0.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Main.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
compile successfully
ACTUAL -
javac crashes
---------- BEGIN SOURCE ----------
import java.util.function.Supplier;
class Main {
public Integer foo(Object x) {
Integer bar = 1;
return ((x instanceof Number y) ?
((Supplier<Integer>) (() -> {
return ((y instanceof Integer z) ? z : bar);
})).get() : bar);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Remove the bar variable and use an integer value directly.
FREQUENCY : always
- backported by
-
JDK-8269454 NPE at at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop
-
- Resolved
-
-
JDK-8270641 NPE at at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop
-
- Resolved
-
- relates to
-
JDK-8220041 NullPointerException at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0
-
- Resolved
-
-
JDK-8229862 NPE in jdk.compiler/com.sun.tools.javac.jvm.Code.emitop0(Code.java:570)
-
- Resolved
-
-
JDK-8268748 Javac generates uncorrect bytecodes when using nested pattern variables
-
- Resolved
-
(2 links to)