RFR: JDK-8243548: Javac incorrectly collects enumerated fields when switch expressions containing outer enum classes

Vicente Romero vicente.romero at oracle.com
Thu Apr 30 16:28:30 UTC 2020


looks good,

Vicente

On 4/29/20 8:46 AM, Jan Lahoda wrote:
> 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