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

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

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 11
    • Fix Version/s: 14
    • Component/s: tools
    • Labels:
      None

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                darcy Joe Darcy
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated: