Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8312229

Crash involving yield, switch and anonymous classes

XMLWordPrintable

    • b08

        public class Bug {
            void test(Object o) {
                Runnable r = () -> {
                    var l = switch (o) {
                        default -> {
                            Integer i = 42;
                            yield new Runnable() { // ok with lambda, crash with anon
                                public void run() {
                                    i.toString(); // crash here, symbol of i is null
                                }
                            };
                        }
                    };
                };
            }
        }

        An exception has occurred in the compiler (22-internal). 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.AssertionError
        at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
        at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.access(Lower.java:1227)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitIdent(Lower.java:3499)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2715)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitSelect(Lower.java:4201)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2581)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitApply(Lower.java:3167)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1816)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitExec(TreeTranslator.java:257)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1603)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:3689)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1092)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:150)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2858)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2774)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:916)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:2323)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:814)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitNewClass(Lower.java:2956)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1871)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2192)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitYield(Lower.java:4181)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCYield.accept(JCTree.java:1677)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:3689)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1092)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitCase(TreeTranslator.java:212)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCase.accept(JCTree.java:1343)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translateCases(TreeTranslator.java:94)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.handleSwitch(Lower.java:3801)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitSwitchExpression(Lower.java:3733)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitchExpression.accept(JCTree.java:1399)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2192)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitLetExpr(Lower.java:4221)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3418)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2192)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitVarDef(Lower.java:3675)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1022)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:70)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitBlock(TreeTranslator.java:167)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitBlock(Lower.java:3689)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1092)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.visitMethodDef(TreeTranslator.java:150)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitMethodDefInternal(Lower.java:2858)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitMethodDef(Lower.java:2774)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:916)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.visitClassDef(Lower.java:2323)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:814)
        at jdk.compiler/com.sun.tools.javac.tree.TreeTranslator.translate(TreeTranslator.java:58)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2181)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translate(Lower.java:2200)
        at jdk.compiler/com.sun.tools.javac.comp.Lower.translateTopLevelClass(Lower.java:4293)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1660)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.desugar(JavaCompiler.java:1474)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:978)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)

        https://mail.openjdk.org/pipermail/amber-dev/2023-July/008206.html

              jlahoda Jan Lahoda
              abimpoudis Angelos Bimpoudis
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: