JDK-6350835 : Most exceptions and errors fail to declare serialVersionUID
  • Type: Bug
  • Component: other-libs
  • Sub-Component: other
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2005-11-16
  • Updated: 2017-07-20
  • Resolved: 2017-07-20
Related Reports
Relates :  
Description
java.lang.Throwable is declared as implementing the Serializable interface.
This means that it and all of its subclasses should declare serialVersionUID
fields if they want to maintain serialization compatibility across releases.

Currently the JDK workspace has 612 classes whose names end in Exception.java
(602 of which contain the string "extends .*Exception") but only 274 of those
classes have a serialVersionUID defined.

There are also 54 classes whose names end in Error.java (40 of which contain
the string "extends .*Error), but only 12 of those have a serialVersionUID.

Note that this simple search is not necessarily exhaustive since there could
be subclasses of Throwable which do not include those words in the name of
their source file, but it indicates that well over half of all exceptions and
more than 2/3 of all errors fail to declare a serialVersionUID.  A tool which
scans the class files for actual subclasses of Throwable could generate more
complete statistics and a list of the non-compliant classes.

I've attached the simple lists of source files for a first pass reference:

    - allexceptions (a list of all source files ending in Exception.java)
    - serialexceptions (those files in which "serialVersionUID" is found)
    - allerrors (a list of all source files ending in Error.java)
    - serialerrors (those files in which "serialVersionUID" is found)

Comments
There was huge clean in this area for Java SE 9 and the build now fails if a serialable doesn't declare its SUID. So I think we can close this issue.
20-07-2017

EVALUATION Good progress was made on this issue in JDK7 via bugs that include: 6749308: java.io, java.lang, java.util exception classes don't specify serialVersionUID 4921754: Javadoc doesn't specify serialVersionUID for java.nio.* classes 6746836: java.net exception classes don't specify serialVersionUID 6895875: Missing serialVersionUID in sun.management classes The current effort to eliminate javac warnings when compiling with -Xlint:all should ensure that the exception (and other) serializable classes in the platform will add their serialVersionUID declared.
03-01-2012

EVALUATION This should be fixed.
16-11-2005