Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P3
    • 18
    • Affects Version/s: 11
    • Component/s: tools
    • b21

      The core check of javac's serial lint warning (JDK-4767441) is to verify the presence of a properly declared serialVersionUID field in serializable classes.

      There are other useful checks that could be added, including that serial-involved methods are properly declared rather than being overloads which will get ignored by the serialization system. Those methods include:

       private void writeObject(java.io.ObjectOutputStream stream)
           throws IOException;
       private void readObject(java.io.ObjectInputStream stream)
           throws IOException, ClassNotFoundException;
       private void readObjectNoData()
           throws ObjectStreamException

      as discussed in java.io.ObjectInputStream and java.io.ObjectOutputStream. In additional, the serialization spec discusses the methods:

      ANY-ACCESS-MODIFIER Object writeReplace()
                   throws ObjectStreamException;
      ANY-ACCESS-MODIFIER Object readResolve()
                  throws ObjectStreamException;

      Additional methods are defined for Externalization.

            Assignee:
            Joe Darcy
            Reporter:
            Joe Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: