...
Violating the general contract when overriding the equals() method can lead to unexpected results.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
MET08-J | Low | Unlikely | No | NoMedium | P2P1 | L3 |
Automated Detection
| Tool | Version | Checker | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CodeSonar |
| FB.BAD_PRACTICE.EQ_GETCLASS_AND_CLASS_CONSTANT FB.CORRECTNESS.OVERRIDING_EQUALS_NOT_SYMMETRIC | equals method fails for subtypesJAVA.COMPARE.CTO.ASSYM | Asymmetric compareTo (Java) | |||||||||
| Parasoft Jtest |
| CERT.MET08.EQREFL | Make sure implementation of Object.equals(Object) is reflexive | ||||||||||
| SonarQube |
| S2162 | "equals" methods should be symmetric and work for subclasses |
Related Guidelines
...