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

Desugaring of pattern matching enum switch should be improved

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 17
    • tools
    • None
    • source
    • minimal
    • Java API
    • SE

      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

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

              Created:
              Updated:
              Resolved: