...
When a nonfinal class defines a clone()
method that does not call super.clone()
, cloning a subtype will produce an object of the wrong type.
The Java API for the {{ Wiki Markup clone()
}} method \ [[API 2006|AA. References#API 06] \] says:
By convention, the returned object should be obtained by calling
super.clone
. If a class and all of its superclasses (exceptObject
) obey this convention, it will be the case thatx.clone().getClass() == x.getClass()
.
...
Automated detection is straightforward.
Bibliography
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a5c5b81e-ba4e-42cf-b5b0-21f50a0db17e"><ac:plain-text-body><![CDATA[ | [ [API 2006AA. References#API 06] ] | [Class Objecthttp://java.sun.com/javase/6/docs/api/java/lang/ Object.html] ]]></ac:plain-text-body></ac:structured-macro> |
...
MET15-J. Do not use deprecated or obsolete classes or methods 05. Methods (MET) MET17-J. Do not increase the accessibility of overridden or hidden methods