Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

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.

Wiki MarkupThe Java API for the {{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 (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

...

Automated detection is straightforward.

Bibliography

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f68a313e-ad37-4676-9387-6bae6682755c"><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