Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Automated detection of classes that override only one of equals() and hashcode() is straightforward. Sound static determination that the implementations of equals() and hashcode() are mutually consistent is not feasible in the general case, although heuristic techniques may be used.

Related

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

MITRE CWE

CWE ID 581, "Object Model Violation: Just One of Equals and Hashcode Defined"

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="673c251026513375-d8691f4a-444e4a68-a261afb3-29d729996ad0c374af0927ef"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

[Class Object

http://java.sun.com/javase/6/docs/api/java/lang/Object.html]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="fc7bb33324042fb9-7b5ff546-49104a54-b88aa5c7-eecc3b33464a9bfcad7a789e"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 9: Always override hashCode when you override equals

]]></ac:plain-text-body></ac:structured-macro>

...