As far as I understand the Java 8 JLS the expression (1/0)
is considered a constant expression, but when I try to compile the following program with OpenJDK 8 I get an error
public class Switch {
public static void main(String[] args) {
switch(42) {
case (1/0):
return;
default:
return;
}
}
}
The error says (1/0)
isn't a constant expression
Switch.java:4: error: constant expression required
case (1/0):
^
1 error
Am I missing something? Or is it a bug in OpenJDK 8?