[jdk17u-dev] RFR: 8278834: Error "Cannot read field "sym" because "this.lvar[od]" is null" when compiling
Glavo
duke at openjdk.org
Wed Feb 1 16:59:00 UTC 2023
On Wed, 1 Feb 2023 16:25:31 GMT, Paul Hohensee <phh at openjdk.org> wrote:
>> 8278834: Error "Cannot read field "sym" because "this.lvar[od]" is null" when compiling
>
> @Glavo, please add a note describing the reason for the backport, testing, and risk.
@phohensee
javac crashed when we compiled the following code using JDK 17:
import java.util.*;
public class Main {
public static void main(String[] args) {
Integer b = 1;
new Main(b) {
private final List<String> list = this.o instanceof Integer i ? new ArrayList<String>(i) : new ArrayList<String>();
}.run();
}
protected final Object o;
public Main(Object o) {
this.o = o;
}
public void run() {
}
}
javac output:
An exception has occurred in the compiler (17.0.6). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://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.visitSelect(Gen.java:2316)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2450)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:877)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1875)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1797)
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.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)
printing javac parameters to: /mnt/d/Downloads/javac.20230202_005046.args
This backport is to fix this problem. I think there are no known risks.
What tests should I run for javac?
-------------
PR: https://git.openjdk.org/jdk17u-dev/pull/1141
More information about the jdk-updates-dev
mailing list