RFR: JDK-8312415: Expand -Xlint:serial checks to enum constants with specialized class bodies

Jan Lahoda jlahoda at openjdk.org
Tue Jul 25 15:18:54 UTC 2023


On Mon, 24 Jul 2023 20:00:54 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java line 5219:
>> 
>>> 5217:                     case ENUM_CONSTANT -> {
>>> 5218:                         var field = (VarSymbol)enclosed;
>>> 5219:                         if (field.isEnum()) {
>> 
>> It's not wrong, but is this check redundant?  When can an `ENUM_CONSTANT` not be `isEnum()` ?
>
> See these lines in `Symbol.java` `public ElementKind getKind()` line 1725:
> 
>             } else if ((flags & ENUM) != 0) {
>                 return ElementKind.ENUM_CONSTANT;

Yes, sorry for that, I've originally had the code elsewhere. The `isEnum` check should not be needed here.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15004#discussion_r1273710986


More information about the compiler-dev mailing list