New JEP: Switch Expressions for the Java Language

Liam Miller-Cushon cushon at
Thu Dec 7 23:28:44 UTC 2017

I don't see it mentioned in the JEP, but will the default case of an
expression switch be required to be last? (Previously:

> in the case of an enum switch that covers all known cases, a default
clause can be inserted by the compiler that indicates that the enum
definition has changed between compile time and runtime

This sounds great, but note that it makes adding values to an enum a
potentially source-incompatible change. Pattern switches that handle all
values of an enum will need to be updated to handle the new value, or to
have an explicit default.

In our code base we use static analysis to require statement switches on
enums either handle all values or have a default. The issue with source
incompatibility and adding values to enums hasn't been a significant
problem so far.

On Thu, Dec 7, 2017 at 2:33 PM, Brian Goetz <brian.goetz at> wrote:

> We've separated out a package of standalone improvements to `switch`
> (switch expressions, case null, and case alternation) into their own JEP:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the amber-spec-experts mailing list