Call for feedback -- enhanced switch

Alex Buckley alex.buckley at oracle.com
Mon Mar 25 18:22:02 UTC 2019


On 3/24/2019 10:57 AM, forax at univ-mlv.fr wrote:
> ----- Mail original -----
>> De: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>
>> À: "Remi Forax" <forax at univ-mlv.fr>, "Brian Goetz" <brian.goetz at oracle.com>
>> Cc: "amber-dev" <amber-dev at openjdk.java.net>
>> Envoyé: Samedi 23 Mars 2019 22:27:47
>> Objet: Re: Call for feedback -- enhanced switch
>
>> On 23/03/2019 17:38, Remi Forax wrote:
>>> And the expression switch is supported by the latest releases of both IntelliJ
>>> IDEA and Eclipse [1]
>>>
>>> BTW, it remember me something i have forgotten to ask, for both ecj and javac,
>>> when you compile with --enable-preview, all the classes have they minor version
>>> changed even the one that doesn't use the switch expression. I've tried to find
>>> where this behaviour was documented in the JEP 12 [2] but the "compile-time"
>>> section is not clear about that.
>>
>> Remi, my initial implementation of JEP 12 was actually doing the finer
>> grained treatment you described.
>
> I'm not sure which implementation is better, but anyway, at least the current behavior should be documented in the spec,
> as you said, at least the semantics of the current implementation is  clear.

JEP 12 is not a spec for javac. JEP 12 is a policy document which, 
though its sections "Design of a Preview Feature", "Use of Preview 
Features", and "Relationship to Java SE APIs", lays groundwork for the 
Java SE Platform Spec. (See 
http://cr.openjdk.java.net/~iris/se/12/latestSpec/#Preview-features)

Accordingly, JEP 12 mandates the smallest possible behavior for Java 
compilers and runtimes that is consistent with its policy goals. That's 
why it requires only:

"If Java source code uses a preview language feature of Java SE $N, then 
a Java compiler must record that the emitted class file depends on the 
preview VM features of Java SE $N."

and does not require the inverse, "If Java source code does not use a 
preview language feature, then a Java compiler must not record that the 
emitted class file depends on preview VM features."  (For one thing, 
that inverse requirement, as written, would be inappropriate if a Java 
compiler started compiling an old language feature into a class file 
that genuinely uses a preview VM feature.)

For convenience, JEP 12 has a section "Example use of preview features" 
which discusses how javac could enable preview features. That's not a 
spec, but to help readers, I have added this:

"- Every `class` file emitted by `javac` _depends on the preview VM 
features of Java SE $N_, regardless of whether the source code 
corresponding to the `class` file actually uses preview language 
features of Java SE $N."

Alex


More information about the amber-dev mailing list