Versions Compared

Key

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

...

This rule prohibits publishing a reference to a partially initialized member object instance before initialization has concluded. Rule It specifically applies to safety in multithreaded code. The related rule TSM01-J. Do not let the (this) reference escape during object construction prohibits the this reference of the current object from escaping its constructor. Also see OBJ11-J. Be wary of letting constructors throw exceptions for some consequences of publishing partially-initialized objects even in single-threaded programs..

Noncompliant Code Example

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="70dfc25b893e585d-51f2fd98-4ade45a2-aa148e8f-216282fd0cb31087941d1598"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

 

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="52b12627472e9d10-953d15ab-45984acf-a0bcbed4-2d189771084c66f9f140a321"><ac:plain-text-body><![CDATA[

[[Bloch 2001

AA. Bibliography#Bloch 01]]

Item 48: "Synchronize access to shared mutable data"

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="15cd9bd9ec3cf876-830e9ee2-419b46a1-ab1c91f9-6caf3a0d5c97b856481eac4c"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. Bibliography#Goetz 06]]

Section 3.5.3 "Safe Publication Idioms"

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7a6cfb9b43465102-c49d7e5d-424c4c07-bffbafe0-342c287c113bc955cd9302d0"><ac:plain-text-body><![CDATA[

[[Goetz 2007

AA. Bibliography#Goetz 07]]

Pattern #2: "one-time safe publication"

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ad11398359cd69b7-b21a7324-487447c7-8560b24c-fab0b2058a6448d6db33e0bd"><ac:plain-text-body><![CDATA[

[[JPL 2006

AA. Bibliography#JPL 06]]

14.10.2. "Final Fields and Security"

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3ce93ea18721a633-e9b4236c-40bd4c82-beb488f6-e2f20b5434975ba52b5ffcc7"><ac:plain-text-body><![CDATA[

[[Pugh 2004

AA. Bibliography#Pugh 04]]

 

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

...