Qualified enum constants in switch?

Tagir Valeev amaembo at gmail.com
Thu Jul 6 08:20:20 UTC 2023


We are working on Java 21 support in our IDE, and stumbled the following issue.
Previous draft of spec [1] said:

Every case constant must be either (1) the null literal, (2) a
constant expression (15.29), or (3) the (simple or qualified) name of
an enum constant (8.9.1); otherwise a compile-time error occurs. A
single null case constant may also be paired with the default keyword.

Now, it says [2]

Every case constant must be either a constant expression (15.29), or
the name of an enum constant (8.9.1), or a compile-time error occurs.

So, now it doesn't mention the qualified names. Still JEP 441 [3]
still mentions that qualified enum constants are allowed. Could you
please tell me whether the intent is to keep this part of
specification, or it was decided to drop it?

With best regards,
Tagir Valeev.

[1] https://cr.openjdk.org/~gbierman/jep440+441/jep440+441-20230524/specs/patterns-switch-record-patterns-jls.html
[2] https://cr.openjdk.org/~gbierman/jep440%2B441/jep440+441-20230612/specs/patterns-switch-record-patterns-jls.html
[3] https://openjdk.org/jeps/441

More information about the amber-spec-experts mailing list