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
Affected Platforms
Java
Extended Description
AI Translation
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().
Technical Details
AI Translation
Common Consequences
integrity
other
Impacts
other
Detection Methods
automated static analysis
Potential Mitigations
Phases:
implementation
Descriptions:
•
Both Equals() and Hashcode() should be defined.