-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
17
-
generic
-
generic
-
Not verified
A DESCRIPTION OF THE PROBLEM :
When pattern matching for instanceof is used in instance initialization block compailer raise NullPointerException.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save code to test.java and run:
$ java test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Source code compiles.
ACTUAL -
$ java test.java
An exception has occurred in the compiler (17.0.2). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.NullPointerException: Cannot read field "sym" because "this.lvar[od]" is null
at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop1w(Code.java:956)
at jdk.compiler/com.sun.tools.javac.jvm.Items$LocalItem.load(Items.java:401)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:902)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitNewClass(Gen.java:1967)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1852)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1748)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1584)
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:1091)
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:921)
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:2420)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:737)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1617)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1585)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
at jdk.compiler/com.sun.tools.javac.launcher.Main.compile(Main.java:383)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:189)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
error: compilation failed
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String ... args) {
new Object() {
{
final Number n = 42d;
final var test = n instanceof Double d;
}
};
}
}
---------- END SOURCE ----------
FREQUENCY : always
When pattern matching for instanceof is used in instance initialization block compailer raise NullPointerException.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save code to test.java and run:
$ java test.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Source code compiles.
ACTUAL -
$ java test.java
An exception has occurred in the compiler (17.0.2). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.NullPointerException: Cannot read field "sym" because "this.lvar[od]" is null
at jdk.compiler/com.sun.tools.javac.jvm.Code.emitop1w(Code.java:956)
at jdk.compiler/com.sun.tools.javac.jvm.Items$LocalItem.load(Items.java:401)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:902)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitNewClass(Gen.java:1967)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1852)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1748)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1584)
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:1091)
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:921)
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:2420)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:737)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1617)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1585)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
at jdk.compiler/com.sun.tools.javac.launcher.Main.compile(Main.java:383)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:189)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132)
error: compilation failed
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String ... args) {
new Object() {
{
final Number n = 42d;
final var test = n instanceof Double d;
}
};
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8278834 Error "Cannot read field "sym" because "this.lvar[od]" is null" when compiling
- Resolved