RFR: JDK-8243548: Javac incorrectly collects enumerated fields when switch expressions containing outer enum classes
Jan Lahoda
jan.lahoda at oracle.com
Wed Apr 29 12:46:52 UTC 2020
Hi,
For switch expressions over enums, javac performs exhaustiveness
analysis. But there is an unfortunate bug in it - when gathering the
enum constants, it gets all members of the appropriate enum class, and
takes the names of those that are marked as ENUM - but both enum classes
and enum constant are marked internally as ENUM. So, as a consequence,
javac will include any nested enums in the list of expected constants,
making the switch expression non-exhaustive.
The proposed patch is to simply only use fields (constants), not nested
enum classes.
Webrev: http://cr.openjdk.java.net/~jlahoda/8243548/webrev.00/
JBS: https://bugs.openjdk.java.net/browse/JDK-8243548
How does this look?
Thanks,
Jan
More information about the compiler-dev
mailing list