这个只是一个Java源代码的部分记录,免得有时候想去看了,还要打开编译器。
Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this
interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface
has no methods or fields and serves only to identify the semantics of being serializable.
If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and
can thus result in unexpected InvalidClassException during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. It is also strongly advised that explicit serialVersionUID declarations use the private modifier where possible, since such declarations apply only to the immediately declaring class--serialVersionUID fields are not useful as inherited members. Array classes cannot declare an explicit serialVersionUID, so they al
ways have the default computed value, but the requirement for matching serialVersionUID values is waived for array classes.