Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8002086

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

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Duplicate
    • P5
    • tbd_major
    • 8
    • tools

    Description

      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;
      }

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: