-
Bug
-
Resolution: Fixed
-
P4
-
8
-
b116
-
generic
-
generic
-
Verified
Javac issues a [serial] warning if an instantiation of an anonymous inner class is missing a serialVersionUID. For example,
return new java.security.Key() {
// ...
}
results in something like
Warning.java:16: warning: [serial] serializable class
<anonymous Warning$1> has no definition of serialVersionUID
There are a variety of reasons that serialization compatibility of an anonymous inner class cannot be guaranteed, or even that such instances can be serialized at all. Thus, it is incorrect to warn the user to add a useless serialVersionUID.
(Reasons include: anonymous class names are implementation-specific and may vary from one build to the next; synthesized field names and types may also vary unpredictably; the enclosing instance or captured local variables might not be serializable; even if they were serializable it's unlikely that this is what the programmer would want.)
return new java.security.Key() {
// ...
}
results in something like
Warning.java:16: warning: [serial] serializable class
<anonymous Warning$1> has no definition of serialVersionUID
There are a variety of reasons that serialization compatibility of an anonymous inner class cannot be guaranteed, or even that such instances can be serialized at all. Thus, it is incorrect to warn the user to add a useless serialVersionUID.
(Reasons include: anonymous class names are implementation-specific and may vary from one build to the next; synthesized field names and types may also vary unpredictably; the enclosing instance or captured local variables might not be serializable; even if they were serializable it's unlikely that this is what the programmer would want.)
- relates to
-
JDK-4767441 new warning: class implements serializable but doesn't define serialVersionUID
-
- Resolved
-
-
JDK-8002086 javac should warn if serialVersionUID is present in an enum or anon subclass of an enum
-
- Closed
-
-
JDK-6981095 Additional -Xlint:serial warning
-
- Open
-