An Externalizable class has no public constructor without parameters, so it cannot be read back
What it finds
Reading an Externalizable object starts by calling its public constructor without parameters, then readExternal. A class that declares constructors, none of them public and without parameters, cannot be read back: deserialization fails with an InvalidClassException.
From the rule's source, externalizable_without_no_arg.rs.
import java.io.Externalizable;import java.io.ObjectInput;import java.io.ObjectOutput; class Point implements Externalizable {tx0 reports: Point has no public constructor without parameters int x; Point(int x) { this.x = x; } public void writeExternal(ObjectOutput out) {} public void readExternal(ObjectInput in) {}} class Size implements Externalizable { public Size() {} Size(int w) {} public void writeExternal(ObjectOutput out) {} public void readExternal(ObjectInput in) {}} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:externalizable-without-no-arg" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:externalizable-without-no-arg] reason="..."tx0 explain tx0/java:externalizable-without-no-arg shows the same in the terminal. Found a false positive? Report it.