-
Enhancement
-
Resolution: Duplicate
-
P5
-
8
Javac doesn't issue a warning if a serialVersionUID is present in an enum or an anonymous subclass. It should issue a warning, since the serialVersionUID of any enum or anon subclass of enum is defined to be 0L.
Compiling the following with -Xlint:all generates no warnings.
It might be reasonable to have this warning controlled by the "serial" lint option, that is, enabled via -Xlint:serial.
----- Guy.java -----
enum Guy {
TOM {
private static final long serialVersionUID = 4290774380558885855L;
},
DICK {
private static final long serialVersionUID = -6849794470754667710L;
},
HARRY {
private static final long serialVersionUID = -9172774392245257468L;
};
private static final long serialVersionUID = 1360826667806852920L;
}
Compiling the following with -Xlint:all generates no warnings.
It might be reasonable to have this warning controlled by the "serial" lint option, that is, enabled via -Xlint:serial.
----- Guy.java -----
enum Guy {
TOM {
private static final long serialVersionUID = 4290774380558885855L;
},
DICK {
private static final long serialVersionUID = -6849794470754667710L;
},
HARRY {
private static final long serialVersionUID = -9172774392245257468L;
};
private static final long serialVersionUID = 1360826667806852920L;
}
- duplicates
-
JDK-8202056 Expand serial warning to check for bad overloads of serial-related methods and ineffectual fields
- Resolved
- relates to
-
JDK-8207751 Remove misleading serialVersionUID from JulienFields.Field
- Closed
-
JDK-7152104 javac should not warn about missing serialVersionUID for anonymous inner classes
- Closed
-
JDK-8160675 Issue lint warning for non-serializable non-transient instance fields in serializable type
- Resolved