JDK-4767441 : new warning: class implements serializable but doesn't define serialVersionUID
Type:Enhancement
Component:tools
Sub-Component:javac
Affected Version:1.4.0
Priority:P4
Status:Resolved
Resolution:Fixed
OS:solaris_8
CPU:generic
Submitted:2002-10-23
Updated:2018-04-19
Resolved:2003-08-01
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
Please give a warning when a serializable class fails to
provide a definition of serialVersionUID.
Comments
CONVERTED DATA
BugTraq+ Release Management Values
COMMIT TO FIX:
tiger
FIXED IN:
tiger
INTEGRATED IN:
tiger
tiger-b14
14-06-2004
PUBLIC COMMENTS
...
10-06-2004
EVALUATION
This will help reduce the problems with spurious serial UID changes
due to changes in the synthetic data in a class.
###@###.### 2002-10-23
It is especially important to get this in to mantis to provide advance warning
before people start porting to tiger, because changes in the class file format
will cause changes in the system-computed serial version uid.
###@###.### 2002-10-24
I tried it, and got thousands of warnings in J2SE, including in javac itself.
Basically, this wouldn't fly, for the following fundamental reasons:
(1) Throwable implements serializable, so every exception type would be
required to provide a SVUID, even if the exception is never used in a way
that seriaization is an issue.
(2) As a generalization of the above, many classes are *accidentally*
serializable, by virtue of implementing a serializable interface or
extending a serializable class. Often, such classes are not intended
to be serialized.
(3) As a special case of the above, many serializable classes are local or
anonymous (for example, registered callbacks). Adding a SVUID to such a
class is often a useless exercise.
(4) There are 1071 warnings in J2SE due to serializable classes
failing to define a serial version UID, *excluding* those for reason (1).
It is unrealistic to expect this to be addressed anytime soon, and it
is inreasonable to expect people to put up with the warning in the meantime.
For the record, an attachment contains a catalog of where this
warning would be given, excluding those due to reason (1) above.
I could not put the list in the Comments field as I had originally
intended because it doesn't fit!
The best we can do is implement an optional warning. Because that requires
a compile-time flag, that will have to wait for Tiger.
###@###.### 2002-10-28