| Wiki Markup |
|---|
"An inner class is a nested class that is not explicitly or implicitly declared static." \[[JLS 05 Section 8.1.3, Inner Classes and Enclosing Instances|http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3]\]. Serialization of inner classes (including local and anonymous classes) is error prone. TheAccording following postulates have been reproduced from to \[[Sun 06|AA. Java References#Sun 06]\], Serialization specification: |
...
- Synthetic fields generated by
javac(or other Java^superscript^TM Java TM compilers) to implement inner classes are implementation dependent and may vary between compilers; differences in such fields can disrupt compatibility as well as result in conflicting default serialVersionUID values. The names assigned to local and anonymous inner classes are also implementation dependent and may differ between compilers.
- Because inner classes cannot declare static members other than compile-time constant fields, they cannot use the serialPersistentFields mechanism to designate serializable fields.
Wiki Markup Finally, because inner classes associated with outer instances do not have zero-argument constructors (constructors of such inner classes implicitly accept the enclosing instance as a prepended parameter), they cannot implement {{Externalizable}}. \[The {{Externalizable}} interface requires the implementing object to manually save and restore its state using the {{writeExternal()}} and {{readExternal()}} methods.\]
None of these issues, however, apply to static member classes.
...