A method that overrides a method of Object lacks @Override
What it finds
@Override makes the compiler check that a method really overrides one; without it, a misspelled or mistyped equals(Point other) silently becomes an overload. The methods of Object are the ones overridden everywhere.
Reported is equals(Object), hashCode(), toString(), clone() and finalize() without @Override, in classes, enums and records.
From the rule's source, missing_override_annotation.rs.
class Point { public String toString() {tx0 reports: overrides a method of Object without @Override return ""; } @Override public int hashCode() { return 0; } public boolean equals(Point other) { return false; }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:missing-override-annotation" = "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:missing-override-annotation] reason="..."tx0 explain tx0/java:missing-override-annotation shows the same in the terminal. Found a false positive? Report it.