Katalog CWE

CWE-580 · Słabość

clone() Method Without super.clone()

Abstrakcja
Wariant
Status
Szkic
Dodano
15 grudnia 2006
Ostatnia zmiana
11 grudnia 2025

Podatności CVE z tą słabościąPełny wpis na cwe.mitre.org ↗

Opis

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

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.

Skutki

  • Integrity, Other

    Unexpected State; Quality Degradation

Zapobieganie

  • Implementation

    Call super.clone() within your clone() method, when obtaining a new object.

  • Implementation

    In some cases, you can eliminate the clone method altogether and use copy constructors.

Słabość nadrzędna

Kiedy powstaje

Dotyczy

Java

Wpis z katalogu CWE 4.20.