javac should warn if serialVersionUID is present in an enum or anon subclass of an enum

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P5
    • tbd
    • Affects Version/s: 8
    • Component/s: tools

      Javac doesn't issue a warning if a serialVersionUID is present in an enum or an anonymous subclass. It should issue a warning, since the serialVersionUID of any enum or anon subclass of enum is defined to be 0L.

      Compiling the following with -Xlint:all generates no warnings.

      It might be reasonable to have this warning controlled by the "serial" lint option, that is, enabled via -Xlint:serial.

      ----- Guy.java -----

      enum Guy {
          TOM {
              private static final long serialVersionUID = 4290774380558885855L;
          },

          DICK {
              private static final long serialVersionUID = -6849794470754667710L;
          },

          HARRY {
              private static final long serialVersionUID = -9172774392245257468L;
          };

          private static final long serialVersionUID = 1360826667806852920L;
      }

            Assignee:
            Andreas Lundblad (Inactive)
            Reporter:
            Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: