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)