Versions Compared

Key

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

Mutable classes allow code external to the class to alter their instance or class fields. Provide means for creating copies of mutable classes so that disposable instances of such classes can be passed to untrusted code. This functionality is useful when methods in other classes must create copies of the particular class instance; see rules "FIO00OBJ06-J. Defensively copy mutable inputs and mutable internal components" and "OBJ09OBJ05-J. Defensively copy private mutable class members before returning their references" for additional details.

...

When untrusted code can call accessor methods passing mutable arguments, create defensive copies of the arguments before they are stored in any instance fields. See rule "FIO00OBJ06-J. Defensively copy mutable inputs and mutable internal components" for additional information. When retrieving internal mutable state, make a defensive copy of that state before returning it to untrusted code. See rule "OBJ09OBJ05-J. Defensively copy private mutable class members before returning their references" for additional information.

...

OBJ04-EX0: Sensitive classes should not be cloneable, per rule "OBJ03OBJ07-J. Sensitive classes must not let themselves be copied."

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="06accc03f4eb5683-f84324a9-4fa346bc-918aa6e0-3a6ab6f3b4fc44fbf2a72554"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#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="754dbf6f4738fc26-41324903-4efc4d4c-bf1ca383-375bcd0f89cd0f23b9ae3a70"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 39: Make defensive copies when needed and 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="94056e7f95a725cf-04b1692b-46184deb-94e2bb3e-646d49a8121f6223e0e2fe1f"><ac:plain-text-body><![CDATA[

[[Security 2006

AA. Bibliography#Security 06]]

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

...