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

Desugaring of pattern matching enum switch should be improved

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 17
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      A new bootstrap method, SwitchBootstraps.enumSwitch is added to improve desugaring of pattern matching switches over enum, in order to make the desugaring more uniform and less error-prone.

      Problem

      Currently, javac uses a bootstrap method, SwitchBootstrap.typeSwitch to compile pattern matching switches, except pattern matching switches over enum type. Pattern matching switches over enum types are compiled using a very different and potentially much slower way. The proposal here is to introduce a new bootstrap method SwitchBootstraps.enumSwitch, to better support pattern matching switches over enums. This will lead to a more uniform transformation of pattern matching switches, be less error-prone and also will produce code with potentially better performance.

      Solution

      A new bootstrap method, SwitchBootstraps.enumSwitch is added, and javac is adjusted to use it to compiler pattern matching switches over enums.

      Specification

      The specdiff for the proposed API change is attached, and is also available here: http://cr.openjdk.java.net/~jlahoda/8268766/specdiff.00/overview-summary.html

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              jlahoda Jan Lahoda
              Reviewed By:
              Maurizio Cimadamore
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: