A class implements Cloneable but does not override clone()

tx0/java:cloneable-without-overriderecommendedwarningsmell

What it finds

Cloneable only permits Object.clone(), which stays protected; without a public clone() override, code outside the class cannot copy the object, and the shallow copy Object.clone makes may share mutable fields, as the Cloneable documentation explains.

Reported is a class that implements Cloneable, extends no other class from which it could inherit a clone(), and declares none.

From the rule's source, cloneable_without_clone.rs.

Example from the rule's tests
class Sheep implements Cloneable {}tx0 reports: does not override clone() class Goat implements Cloneable {  @Override  public Goat clone() throws CloneNotSupportedException {    return (Goat) super.clone();  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:

tx0.toml
[rules]
"tx0/java:cloneable-without-override" = "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:cloneable-without-override] reason="..."

tx0 explain tx0/java:cloneable-without-override shows the same in the terminal. Found a false positive? Report it.