Jtest logo




Contents  Previous  Next  Index

MISC.CLONE


A `clone()' method should invoke `super.clone()' in the body

Description

This rule flags any `clone()' method that does not invoke `super.clone()' in the body.

`super.clone()' invokes the method Object.clone, which creates an object of the correct type. Object.clone initializes each field in the new clone object by assigning it the value from the same field of the object being cloned. Therefore, if `super.clone()' is not called, the object might not be initialized correctly.

Reference

Arnold, Ken, and Gosling, James The Java Programming Language. 2d ed. Addison Wesley, 1997, pp. 77 - 82.


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft