Contract of clone()

Correct and complete specification of a correct implementation of the clone() method

An implementation of a clone() method is correct if its type is cloneable and the method returns an object returned by super.clone() on all paths. In addition, such an implementation is complete, if it clones all desired fields of the object to clone and assignes the cloned objects properly.

In which ways can a clone() method be defined wrong? ("code smells")

Searches used for code smells:

Results:

Heuristics for detecting this code smell based on those observations

Heuristics for configuration of the code generation for a correct clone() method()



Resources