Serializable class with unconstructable ancestor
Reports Serializable
classes whose closest non-serializable ancestor doesn't have a no-argument constructor. Such classes cannot be deserialized and will fail with an InvalidClassException
.
Example:
class Ancestor {
private String name;
Ancestor(String name) {
this.name = name;
}
}
// warning on this class because the superclass is not
// serializable, and its constructor takes arguments
class Descendant extends Ancestor implements Serializable {
Descendant() {
super("Bob");
}
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023