equals takes a parameter that is not Object, so it does not override Object.equals

tx0/java:equals-overloadrecommendedwarningbug

What it finds

boolean equals(Point other) does not override Object.equals: it overloads it. Collections, Objects.equals and anything else that holds the value as an Object call equals(Object), which still compares identity, so two equal points are never found equal there.

Reported only when the class declares no equals(Object) next to it.

From the rule's source, equals_overload.rs.

Example from the rule's tests
class Point {  int x;   public boolean equals(Point other) {tx0 reports: equals(Point) overloads equals(Object)    return other != null && other.x == x;  }} class Size {  int w;   public boolean equals(Size other) {    return other != null && other.w == w;  }   @Override  public boolean equals(Object o) {    return o instanceof Size && equals((Size) o);  }   @Override  public int hashCode() {    return w;  }}
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:equals-overload" = "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:equals-overload] reason="..."

tx0 explain tx0/java:equals-overload shows the same in the terminal. Found a false positive? Report it.