ADDITIONAL SYSTEM INFORMATION :
Ubuntu 22.04.2 LTS
openjdk version "20-internal" 2023-03-21
OpenJDK Runtime Environment (build 20-internal-adhoc.admin1.jdk-jdk-20-34)
OpenJDK 64-Bit Server VM (build 20-internal-adhoc.admin1.jdk-jdk-20-34, mixed mode)
A DESCRIPTION OF THE PROBLEM :
When pattern matching for a switch is used and the break statement was forgotten as shown in the example, then the error message is just illegal fall-through to a pattern. Since most developers are not familiar with the fall-trough behavior of switch cases, it would be good if the error message could be more specific, i.e., it should mention that a break statement is missing.
Object o = null;
switch(o){
case null: System.out.println("null");
case Integer i: System.out.println("int: "+i); break;
case Short s: System.out.println("short: "+s); break;
default: System.out.println("default");
}
Ubuntu 22.04.2 LTS
openjdk version "20-internal" 2023-03-21
OpenJDK Runtime Environment (build 20-internal-adhoc.admin1.jdk-jdk-20-34)
OpenJDK 64-Bit Server VM (build 20-internal-adhoc.admin1.jdk-jdk-20-34, mixed mode)
A DESCRIPTION OF THE PROBLEM :
When pattern matching for a switch is used and the break statement was forgotten as shown in the example, then the error message is just illegal fall-through to a pattern. Since most developers are not familiar with the fall-trough behavior of switch cases, it would be good if the error message could be more specific, i.e., it should mention that a break statement is missing.
Object o = null;
switch(o){
case null: System.out.println("null");
case Integer i: System.out.println("int: "+i); break;
case Short s: System.out.println("short: "+s); break;
default: System.out.println("default");
}