CWE-581

Object Model Violation: Just One of Equals and Hashcode Defined
AI Translation Available

The product does not maintain equal hashcodes for equal objects.

Status
draft
Abstraction
variant
Java

Java objects are expected to obey a number of invariants related to equality. One of these invariants is that equal objects must have equal hashcodes. In other words, if a.equals(b) == true then a.hashCode() == b.hashCode().

Common Consequences

integrity other
Impacts
other

Detection Methods

automated static analysis

Potential Mitigations

Phases:
implementation
Descriptions:
• Both Equals() and Hashcode() should be defined.