amber-demo branch has trouble with the switch on String
Remi Forax
forax at univ-mlv.fr
Tue Oct 9 10:45:07 UTC 2018
Hi all,
this was reported by one of my students.
It seems there is a bad merge somewhere with the amber-demo branch,
this issue is no reproducible with the latest beta of jdk 12.
javac struggle with the following code:
public static String exprStringSwitch(String index) {
return switch(index) {
case "viva zorg", "foo" -> "zero";
case "bar" -> "one";
case "baz" -> "a lot";
default -> throw new IllegalArgumentException("number should be foo, bar, baz or viva zorg. Having : " + index);
};
}
Note: ./src/main/java/fr.umlv.javainside.labthree/fr/umlv/javainside/labthree/ExprSwitches.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
An exception has occurred in the compiler (12-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 and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:662)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:647)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitSwitch(Gen.java:1226)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1260)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:591)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:626)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:612)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:663)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1027)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1052)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:591)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:626)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:612)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:663)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitLetExpr(Gen.java:2152)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:3202)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genExpr(Gen.java:813)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitReturn(Gen.java:1623)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1665)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:591)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:626)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:612)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStats(Gen.java:663)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1027)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1052)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:591)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genStat(Gen.java:626)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:897)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:860)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:894)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genDef(Gen.java:591)
at jdk.compiler/com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2204)
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:1647)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1615)
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.JavacToolProvider.run(JavacToolProvider.java:46)
at java.base/java.util.spi.ToolProvider.run(ToolProvider.java:137)
cheers,
Rémi
More information about the amber-dev
mailing list