Versions Compared

Key

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

...

Extending a class or interface that implements Serializable should be avoided whenever possible. When extension of such a class is necessary, inappropriate serialization of the subclass can be prohibited by throwing NotSerializableException from a custom writeObject() or readResolvereadObject() method, defined in the subclass SensitiveClass. Note that the custom writeObject() or readResolvereadObject() methods must be declared private or final to prevent a malicious subclass from overriding them.

Code Block
bgColor#ccccff
class SensitiveClass extends Number {
  // ...

  private final Object readResolve(readObject(java.io.ObjectInputStream in) throws NotSerializableException {
    throw new NotSerializableException();
  }
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e38f8c9fd17fdb43-bb2b3158-44724610-a50a99a0-3145a0db7efbd4928647fb1f"><ac:plain-text-body><![CDATA[

[[Bloch 2005

AA. References#Bloch 05]]

Puzzle 83. Dyslexic monotheism

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c37c5ec6149e4a50-aebc4f60-4fe34e46-a21691f8-3020d3b1af17280263f49c85"><ac:plain-text-body><![CDATA[

[[Bloch 2001

AA. References#Bloch 01]]

Item 1. Enforce the singleton property with a private constructor

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="316f70a6785baeab-fc84fc0d-4bc0480e-b7428025-79e7998abc3e86adc6b7bd6f"><ac:plain-text-body><![CDATA[

[[Greanier 2000

AA. References#Greanier 00]]

[Discover the Secrets of the Java Serialization API

http://java.sun.com/developer/technicalArticles/Programming/serialization/]

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="25a8c26e07a92d30-52e81247-404f4621-a7ee8a66-be0e785498b036b686ddb878"><ac:plain-text-body><![CDATA[

[[Harold 1999

AA. References#Harold 99]]

 

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a755fe17d8f7c1fd-30ad1c0f-45894b45-ac2fb4df-9c33d548808cf7913c4b14f8"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. References#JLS 05]]

[Transient Modifier

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#37020]

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="fba26c8bc0156eb5-370e437d-4fde492e-9ad4988d-3f70998b80e6b4d4d8c6cd38"><ac:plain-text-body><![CDATA[

[[Long 2005

AA. References#Long 05]]

Section 2.4, Serialization

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="baa16ec208750e14-093d10b0-4fd240a4-8df4bd49-5a9543a8ccc2d7df35946c50"><ac:plain-text-body><![CDATA[

[[Sun 2006

AA. References#Sun 06]]

Serialization Specification, A.4, Preventing Serialization of Sensitive Data

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

...