The readObject()
method must not call any overridable methods. Invoking overridable methods from the readObject()
method can allow provide the overriding method with access to read the object's state of the subclass before it is fully constructed because the base class is deserialized first, followed by the subclass. As a result, readObject()
must not call any overridable methodsinitialized. This premature access is possible because, in deserialization,readObject
plays the role of object constructor and therefore object initialization is not complete until readObject
exits.
Also see the related rule MET06-J. Do not invoke overridable methods in clone().
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b5647a545a6c758a-20c7e1be-47904d9d-b7719972-428bdca13541efeae773b46d"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. References#API 06]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="60006585a1a5847d-ece3333c-4b314204-ac07b60a-9e01753d10c4e7db062ad86d"><ac:plain-text-body><![CDATA[ | [[Bloch 2008 | AA. References#Bloch 08]] | Item 17. Design and document for inheritance or else prohibit it | ]]></ac:plain-text-body></ac:structured-macro> |
...