Community
Participate
Working Groups
For the given code public class X { private static void foo(Object o) { switch (o.hashCode()) { case Integer t: default : System.out.println("Object"); } } public static void main(String[] args) { foo("Hello World"); } } ecj reports error on converting int to Integer. Javac reports error in default with "illegal fall-through from a pattern"
Found another mismatch in switch handling. The following compiles fine with ECJ ``` public class App { public static void main(String[] args) { var foo = switch (get()) { case null -> "null value"; case default -> "default value"; }; System.out.println(foo); } private static Object get() { return null; } } ``` But `javac App.java` fails to compile ``` ❯ java -version openjdk version "17-panama" 2021-09-14 OpenJDK Runtime Environment (build 17-panama+3-167) OpenJDK 64-Bit Server VM (build 17-panama+3-167, mixed mode, sharing) ❯ javac App.java App.java:5: error: illegal start of expression case default -> "default value"; ``` Tested with https://download.eclipse.org/eclipse/updates/4.21-P-builds/P20210907-0320 in jdt.ls (https://github.com/eclipse/eclipse.jdt.ls/pull/1871/files#diff-f15305031e24556c35cc42f0684bf5bbe9451e76b57735163e51652610367dfbR50) Let me know if you prefer handling it in another bug.
(In reply to Fred Bricon from comment #1) > Found another mismatch in switch handling. The following compiles fine with > ECJ > ``` > public class App { > public static void main(String[] args) { > var foo = switch (get()) { > case null -> "null value"; > case default -> "default value"; > }; > System.out.println(foo); > } > > private static Object get() { > return null; > } > } > ``` > > But `javac App.java` fails to compile > ``` > ❯ java -version > openjdk version "17-panama" 2021-09-14 > OpenJDK Runtime Environment (build 17-panama+3-167) > OpenJDK 64-Bit Server VM (build 17-panama+3-167, mixed mode, sharing) > ❯ javac App.java > App.java:5: error: illegal start of expression > case default -> "default value"; > ``` > > Tested with > https://download.eclipse.org/eclipse/updates/4.21-P-builds/P20210907-0320 in > jdt.ls > (https://github.com/eclipse/eclipse.jdt.ls/pull/1871/files#diff- > f15305031e24556c35cc42f0684bf5bbe9451e76b57735163e51652610367dfbR50) > > Let me know if you prefer handling it in another bug. Please raise another bug.
My bad, turns out sdkman offered my a really old version of JDK 17. With the latest build (OpenJDK 64-Bit Server VM (build 17+35-2724)), the behaviour is consistent between javac and ecj.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.