src/java.base/share/classes/java/io/Serializable.java
changeset 59142 c4be5e03aff7
parent 58288 48e480e56aad
equal deleted inserted replaced
59141:bd436284147d 59142:c4be5e03aff7
   132  * </PRE><p>
   132  * </PRE><p>
   133  *
   133  *
   134  * This readResolve method follows the same invocation rules and
   134  * This readResolve method follows the same invocation rules and
   135  * accessibility rules as writeReplace.<p>
   135  * accessibility rules as writeReplace.<p>
   136  *
   136  *
       
   137  * Enum types are all serializable and receive treatment defined by
       
   138  * the <cite>Java Object Serialization Specification</cite> during
       
   139  * serialization and deserialization. Any declarations of the special
       
   140  * handling methods discussed above are ignored for enum types.<p>
       
   141  *
   137  * The serialization runtime associates with each serializable class a version
   142  * The serialization runtime associates with each serializable class a version
   138  * number, called a serialVersionUID, which is used during deserialization to
   143  * number, called a serialVersionUID, which is used during deserialization to
   139  * verify that the sender and receiver of a serialized object have loaded
   144  * verify that the sender and receiver of a serialized object have loaded
   140  * classes for that object that are compatible with respect to serialization.
   145  * classes for that object that are compatible with respect to serialization.
   141  * If the receiver has loaded a class for the object that has a different
   146  * If the receiver has loaded a class for the object that has a different
   150  * </PRE>
   155  * </PRE>
   151  *
   156  *
   152  * If a serializable class does not explicitly declare a serialVersionUID, then
   157  * If a serializable class does not explicitly declare a serialVersionUID, then
   153  * the serialization runtime will calculate a default serialVersionUID value
   158  * the serialization runtime will calculate a default serialVersionUID value
   154  * for that class based on various aspects of the class, as described in the
   159  * for that class based on various aspects of the class, as described in the
   155  * Java(TM) Object Serialization Specification.  However, it is <em>strongly
   160  * Java Object Serialization Specification.  This specification defines the
   156  * recommended</em> that all serializable classes explicitly declare
   161  * serialVersionUID of an enum type to be 0L. However, it is <em>strongly
       
   162  * recommended</em> that all serializable classes other than enum types explicitly declare
   157  * serialVersionUID values, since the default serialVersionUID computation is
   163  * serialVersionUID values, since the default serialVersionUID computation is
   158  * highly sensitive to class details that may vary depending on compiler
   164  * highly sensitive to class details that may vary depending on compiler
   159  * implementations, and can thus result in unexpected
   165  * implementations, and can thus result in unexpected
   160  * {@code InvalidClassException}s during deserialization.  Therefore, to
   166  * {@code InvalidClassException}s during deserialization.  Therefore, to
   161  * guarantee a consistent serialVersionUID value across different java compiler
   167  * guarantee a consistent serialVersionUID value across different java compiler