Reports the methods writeObject(), readObject(), readObjectNoData(), writeExternal(), and
readExternal() or the field serialPersistentFields defined in a record class.
These members are not used for the serialization or deserialization of records.
Examples:
record R1() implements Serializable {
// The field is ignored during record serialization
@Serial
private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];
// The method is ignored during record serialization
@Serial
private void writeObject(ObjectOutputStream out) throws IOException {
}
}
record R2() implements Externalizable {
// The method is ignored during record serialization
@Override
public void writeExternal(ObjectOutput out) throws IOException {
}
// The method is ignored during record serialization
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
}
}
This inspection applies to the language level 14 or higher.
New in 2020.3