Versions Compared

Key

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

...

More information on correctly handling singleton classes is available in the rule MSC11-J. Address the shortcomings of the Singleton design patternPrevent multiple instantiations of singleton objects.

Code Block
bgColor#ccccff
class SingletonClass extends Exception {
  // ...
  private final Object readResolve() throws NotSerializableException {
    return INSTANCE;
  }
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5c1d30e317578f70-21778615-47f64176-b448b960-830abf9c688cb2a870e36de2"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

Class Object, Class Hashtable

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1fd87e83c3ef7e01-09a480f1-46b94805-a5249d3b-96736eb557082bc0eee47a4a"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 75: "Consider using a custom serialized form"

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="87b4b28bdc05f0a2-8ee530a2-4e074ec8-8ea3bcc9-1e45c536a34be14f8bfd06eb"><ac:plain-text-body><![CDATA[

[[Greanier 2000

AA. Bibliography#Greanier 00]]

 

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="9f2618e45562d782-aa5c15c4-48794aa5-86bab46e-992bf92f6b49130b09cd884c"><ac:plain-text-body><![CDATA[

[[Harold 1999

AA. Bibliography#Harold 99]]

Chapter 11: Object Serialization, Validation

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="4368857c38681895-56f9b2ed-401b4700-bcacb60c-23cae0b57123f583201dadc7"><ac:plain-text-body><![CDATA[

[[Hawtin 2008

AA. Bibliography#Hawtin 08]]

Antipattern 8: Believing deserialisation is unrelated to construction

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

...