Fix Version/s: 18
Compatibility Risk Description:Augmented checks could cause types which currently compile cleanly under javac's -Xlint:serial to generate warnings.
New warnings can be suppressed using @SuppressWarnings("serial") annotations and/or disabling the lint category.
Interface Kind:add/remove/modify command line option
Xlint:serial checking to include suspicious types for instance fields.
If the serialization mechanism attempts to serialize an object that is not serializable at runtime a
NotSerializableException can result (https://docs.oracle.com/en/java/javase/17/docs/specs/serialization/output.html).
For serializable classes without
serialPersistentFields, examine the type of each non-transient instance field and issue a warning if the type of the field cannot be serialized. Primitive types, types declared to be serializable, and arrays can be serialized. While by the JLS all arrays are considered serializable, a warning is issue if the innermost component type is not serializable.
It is not necessarily erroneous that the field's type is not declared to be serializable; as a runtime invariant, the field could only point to objects that can be serialized. Another alternative, some collections are specified to be conditionally serializable based on their contents. In other cases, such fields are effectively transient if
writeReplace don't depend on their values.
However, It is worth some additional consideration and documentation if a serializable class has such a field.
No written specification of checking behavior.