[switch] Status of implementation of switch expression

Brian Goetz brian.goetz at oracle.com
Tue Feb 27 20:24:47 UTC 2018


> -enhanced exhaustiveness check for enums (if all existing constants 
> are covered, the "default" clause may be omitted, and javac will 
> generate it automatically. The automatically generated one will throw 
> an exception, although the form of the exception may need some 
> improvements). This is for switch expressions only.

What is the form of the exception currently?

> -for switch statements and expressions over reference types, "case 
> null: <statements>" (or "case null -> <expression>" in case of switch 
> expression) may be used, which will be invoked when the reference is null
> -multiple labels (for both switch statement and expression)

Does the case null have to be first, or are there other ordering 
constraints?  (For the current round, the only rule about placement of 
case null we strictly need to follow in order to not make trouble later 
is that case null must precede the default, if present.  But we may wish 
(or not) to make stricter requirements, for purposes of clarity.)

Is the new translation (using indy) enabled by default?

> Current (new) tests are in the following directories:

If anyone wants to contribute, a place to start would be on the tests 
for the indy bootstraps that we are targeting.  Bootstraps are in:
http://hg.openjdk.java.net/amber/amber/file/2b837643a2d4/src/java.base/share/classes/java/lang/runtime/SwitchBootstraps.java

And the unit tests (testing the bootstraps directly, not testing the 
compiler support) are in:
http://hg.openjdk.java.net/amber/amber/file/2b837643a2d4/test/jdk/java/lang/runtime/TestSwitchBootstrap.java

The tests we have are currently quite basic, so we'd be happy for more 
coverage here.




More information about the amber-dev mailing list