Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8207406

Compiler Tree API support for Switch Expressions (Preview)

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 12
    • tools
    • None
    • source
    • minimal
    • Hide
      The addition of the feature does not by itself bring a compatibility risk.

      Switch expressions are a preview feature in Java SE 12. It is possible that incompatible changes will be made to switch expressions in a later Java SE release, before they become final and permanent. It is also possible that switch expressions will be removed in a later Java SE release, without ever having become final and permanent.
      Show
      The addition of the feature does not by itself bring a compatibility risk. Switch expressions are a preview feature in Java SE 12. It is possible that incompatible changes will be made to switch expressions in a later Java SE release, before they become final and permanent. It is also possible that switch expressions will be removed in a later Java SE release, without ever having become final and permanent.
    • Java API
    • JDK

      Summary

      Extend the switch statement so that it can be used as either a statement or an expression, and so that both forms can use either a traditional case : label (with fall through) or a simplified case -> label (no fall through).

      Problem

      When the switch statement is extended, the Compiler Tree API (in the jdk.compiler module) should be extended as well.

      Solution

      JLS changes are covered by JDK-8207241. The Compiler Tree API will be enhanced with support for these changes.

      The language and API changes, as a group, will constitute a preview feature (JEP 12) in Java SE 12. Accordingly, the new APIs are marked as deprecated for removal.

      Specification

      The changes to the Compiler Tree API are attached as api.diff.02.zip, and also available for convenience at http://cr.openjdk.java.net/~jlahoda/8192963/api.diff.02/

      The API adds 2 new types, 7 new methods into existing types, 1 enum constant, and modifies 2 types and 2 methods.

        1. api.diff.00.zip
          118 kB
        2. api.diff.01.zip
          119 kB
        3. api.diff.02.zip
          119 kB

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: