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
- csr of
-
JDK-8268766 Desugaring of pattern matching enum switch should be improved
-
- Resolved
-