Object Serializable Design Guide

1. 避免Serialize Inner Class, 见oracle文档:“Serialization of inner classes (i.e., nested classes that are not static member classes), including local and anonymous classes, is strongly discouraged for several reasons. Because inner classes declared in non-static contexts contain implicit non-transient references to enclosing class instances, serializing such an inner class instance will result in serialization of its associated outer class instance as well. ”;

2. 所有的non-static或none-transient非基本类型域, 都应该implements Serializable;

3. 明确使用private final static关键字,指定serialVersionUID。如果不指定,不同虚拟机可能计算出不同默认serialVersionUID, 产生难以意料的问题

4. new versions of Serializable classes may or may not be able to read old serialized objects; it depend on the nature of the changes. 见:Type Changes Affecting Serialization