[switch] Status of implementation of switch expression

Remi Forax forax at univ-mlv.fr
Tue Feb 27 20:37:36 UTC 2018

----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "jan lahoda" <jan.lahoda at oracle.com>, "amber-dev" <amber-dev at openjdk.java.net>
> Envoyé: Mardi 27 Février 2018 21:24:47
> Objet: Re: [switch] Status of implementation of switch expression

>> -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

Two students of mine have chosen to take a look to the String case to see if things can be improved.
Is there some performance tests somewhere comparing the time with and without the bootstrap methods ?

> 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