Java 源代码 随手记录 一 java.io.Serializable_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Java 源代码 随手记录 一 java.io.Serializable

Java 源代码 随手记录 一 java.io.Serializable

 2011/12/20 10:53:47  gteam.yu  http://gteam-yu.iteye.com  我要评论(0)
  • 摘要:这个只是一个Java源代码的部分记录,免得有时候想去看了,还要打开编译器。Serializabilityofaclassisenabledbytheclassimplementingthejava.io.Serializableinterface.Classesthatdonotimplementthisinterfacewillnothaveanyoftheirstateserializedordeserialized
  • 标签:Java 代码 RIA
这个只是一个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 always have the default computed value, but the requirement for matching serialVersionUID values is waived for array classes.
发表评论
用户名: 匿名