Question: When running FindBugs on my project, I got a few instances of the error described above.

Namely, my overriding versions of equals cast the RHS object into the same type as the object in which the overriding version is defined.

However, I'm not sure whether a better design is possible, since AFAIK Java does not allow variance in method parameters, so it is not possible to define any other type for the equals parameter.

Am I doing something very wrong, or is FindBugs too eager? 

A different way to phrase this question is: what is the correct behavior if the object passed to equals is not the same type as an LHS: Is this a false, or should there be an exception?

For example:

```
public boolean equals(Object rhs)
{
    MyType rhsMyType = (MyType)rhs; // Should throw exception
    if(this.field1().equals(rhsMyType.field1())... // Or whatever
}

```

Answer: 
I'd recommend to ignore said findbugs warning. In practice, if equals is called with an object of an unexpected class, it is almost certainly a bug, and you want to fail fast on bugs.

For example, if you have an 'ArrayList files' and call files.contains("MyFile.txt"), it would be nice if you got a ClassCastException. Instead, Java just returns false, and it likely takes a long time until you discover that bug.
I start my equals(Object) implementations like this:

```
if ((object == null) || !(object instaceof ThisClass)) {
    return false;
}

```

This will also prevent the FindBugs warning but will not automatically return `false` when a subclass of ThisClass is being handed in. It might also be considered equal, especially if its `equals(Object)` method hasn’t been overridden.