RFR: JDK-8226510: No compilation error when switch expression has no result expressions

Jan Lahoda jan.lahoda at oracle.com
Fri Jun 21 15:52:05 UTC 2019


Hi,

javac does not correctly detect situation where a switch expression does 
not yield any value (but has some cases), like:
switch (i) {
      default -> throw new IllegalStateException();
}

The proposed solution is to add a check for this situation. Sadly, this 
triggered updates of several tests (which also contained switch 
expression which failed to yield a value), which had to be updated.

Proposed patch:
http://cr.openjdk.java.net/~jlahoda/8226510/webrev.00/

JBS:
https://bugs.openjdk.java.net/browse/JDK-8226510

How does this look?

Thanks,
     Jan


More information about the compiler-dev mailing list