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

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P3
    • 18
    • 11
    • tools
    • b21

    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

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

              Dates

                Created:
                Updated:
                Resolved: