CWE-580

clone() Method Without super.clone()
AI Translation Available

The product contains a clone() method that does not call super.clone() to obtain the new object.

Status
draft
Abstraction
variant
Java

All implementations of clone() should obtain the new object by calling super.clone(). If a class does not follow this convention, a subclass's clone() method will return an object of the wrong type.

Common Consequences

integrity other
Impacts
unexpected state quality degradation

Detection Methods

automated static analysis

Potential Mitigations

Phases:
implementation
Descriptions:
• Call super.clone() within your clone() method, when obtaining a new object.
• In some cases, you can eliminate the clone method altogether and use copy constructors.