New error when combining Concise Method Bodies and Switch Expressions

Francois Green francois.green at gmail.com
Wed Mar 6 21:53:17 UTC 2019


I'm certain this code had worked earlier:

public class HowMany {

    static void howMany(int k) -> switch (k) {
        case 1 -> System.out.println("one");
        default -> throw new IllegalArgumentException("unknown");
    };

    public static void main(String[] args) {
        howMany(1);
    }
}

An exception has occurred in the compiler (13-amber). 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.AssertionError
        at
jdk.compiler/com.sun.tools.javac.jvm.Items$Item.load(Items.java:206)
        at
jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBreak(Gen.java:1733)
        at
jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1596)
        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:1350)
        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:1554)
        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:1061)
        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:879)
        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.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
        at
jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
        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:379)
        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

I'm using the last Concise Method Bodies build from Remi Forax's Github,
which is about a month old (so it might already be fixed).

PS.  Please consider re-adding Concise Method Bodies to the Amber Demo.


More information about the amber-dev mailing list