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

javac crash when compiling try-catch-finally inside switch expression

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 13
    • 12
    • tools
    • None
    • b25

    Backports

      Description

        Code:

        // SwTest.java
        public class SwTest {
            public static void main(String[] args) {
                System.out.println(switch (0) {
                   default -> {
                       try {
                           break 1;
                       }
                       catch (Exception ex) {
                           break 2;
                       }
                       finally {
                           break 3;
                       }
                   }
                });
            }
        }

        Steps to reproduce:
        > "C:\Program Files\Java\jdk-12\bin\java.exe" --version
        openjdk 12 2019-03-19
        OpenJDK Runtime Environment (build 12+33)
        OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)
        > "C:\Program Files\Java\jdk-12\bin\javac.exe" --release 12 --enable-preview SwTest.java

        Expected: successful compilation

        Actual result: compiler crash

        Note: SwTest.java uses preview language features.
        Note: Recompile with -Xlint:preview for details.
        An exception has occurred in the compiler (12). 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 and the following diagnostic 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.jvm.Gen.visitBreak(Gen.java:1707)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1561)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1067)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen$3.genLast(Gen.java:1450)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen$3.gen(Gen.java:1446)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genFinalizer(Gen.java:341)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.unwind(Gen.java:353)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.unwindBreak(Gen.java:1747)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBreak(Gen.java:1735)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1561)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1067)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genTry(Gen.java:1479)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitTry(Gen.java:1467)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1381)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1067)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:651)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.handleSwitch(Gen.java:1337)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.doHandleSwitchExpression(Gen.java:1205)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSwitchExpression(Gen.java:1172)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitchExpression.accept(JCTree.java:1315)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genArgs(Gen.java:872)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitApply(Gen.java:1808)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1709)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:853)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitExec(Gen.java:1702)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1519)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:616)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:667)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1067)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:630)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:937)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:900)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:872)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:595)
        at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2345)
        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:1635)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1603)
        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:311)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

        Attachments

          Issue Links

            Activity

              People

                jlahoda Jan Lahoda
                tvaleev Tagir Valeev
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: