JDK-8232685 : Make switch expressions final
  • Type: CSR
  • Component: tools
  • Sub-Component: javac
  • Priority: P2
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 14
  • Submitted: 2019-10-21
  • Updated: 2019-10-29
  • Resolved: 2019-10-29
Related Reports
CSR :  
Description
Summary
-------

The switch expressions feature, currently preview, is to be made final.

Problem
-------

The switch expressions features is in the preview mode for a second release, with overall positive feedback.

Solution
--------

The feature is going to be marked as final. The set of legal Java programs is not being changed, only "--enable-preview" will not be needed to enable the feature, it will be enough to use source level 14 or later, implicitly or explicitly.

Specification
-------------

The final specification draft is attached and is also available for convenience here:
http://cr.openjdk.java.net/~gbierman/jep361/jep361-20190927/specs/switch-expressions-jls.html

Specdiff for updated Trees API (removal of @PreviewFeature annotation and associated text) is attached, and is also available for convenience here:
http://cr.openjdk.java.net/~jlahoda/8232684/specdiff.00/overview-summary.html


Comments
Moving to Approved. API changes look fine. I skimmed the JLS changes; I assume they are very similar to what was already present as a preview feature. For the example in Example 14.15-2. "The yield Statement", I recommend replacing the variable name "l" with "len" or some other longer name to avoid posible typographical confusion with "1".
29-10-2019

"to enable the feature, "-source 14" will suffice." I think the text should be changed, as this seems to suggest that you need -source 14 all the time (which is not true; you can also omit the source level).
21-10-2019