Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
Note that the {{clone()}} method must manually clone the {{Date}} object. This step is usually unnecessary when the object contains only primitive fields or fields that refer to immutable objects. However, when the fields contain data such as unique identifiers or object creation times, the {{clone()}} method must calculate and assign appropriate new values for such fields \[[Bloch 2008|AA. Bibliography#BlochReferences#Bloch 08]\].

Mutable classes that define a clone() method must be declared final. This ensures that untrusted code cannot declare a subclass that overrides the clone() method to create a spurious instance. The clone() method should copy all internal mutable state as necessary — in this compliant example, the Date object.

...

Wiki Markup
Callers can use the {{clone()}} method to obtain an instance of such a mutable class. The {{clone()}} method must create a new instance of the final member class and copy the original state to it. The new instance is necessary because there might not be an accessible copy method available in the member class. If the member class evolves in the future, it is critical to include the new state in the manual copy. Finally, the {{clone()}} method must create and return a new instance of the enclosing class ({{MutableClass}}) using the newly created member instance ({{d}}) \[[SCG 2009|AA. Bibliography#SCGReferences#SCG 09]\].

Mutable classes that define a clone() method must be declared final.

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d193de7a19c2c84a-3d31493f-4f034f93-8a5db12b-da1b9062edaa597db7cc1169"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API References#API 06]]

[Method clone()

http://java.sun.com/javase/6/docs/api/java/lang/Object.html#clone()]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="98fd59fed72891ba-f0450711-45d34325-ad0a930a-d0e9743eb5f30322bcf6be1a"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch References#Bloch 08]]

Item 39. Make defensive copies when needed, Item 11. Override clone judiciously

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6051242c165d1022-f2c69d75-42b94172-a8b3a1f6-03d7fe446ed6d3c1ecb9b59b"><ac:plain-text-body><![CDATA[

[[Security 2006

AA. Bibliography#Security References#Security 06]]

]]></ac:plain-text-body></ac:structured-macro>

...