Serialization Changes and Enhancements
The following are enhancements to serialization in Java 2 Platform Standard Edition 5.0. For a summary of enhancements in previous releases, see Enhancements in Previous Releases.
- Support for serialization of enumerated type instances
- Support has been added to serialization to handle enumerated types, which are new in version 5.0. The rules for serializing an enum instance differ from those for serializing an "ordinary" serializable object: the serialized form of an enum instance consists only of its enum constant name, along with information identifying its base enum type. Deserialization behavior differs as well--the class information is used to find the appropriate enum class, and the
Enum.valueOfmethod is called with that class and the received constant name in order to obtain the enum constant to return.
- Bug fix: java.io.StreamCorruptedException thrown due to java.lang.ClassNotFoundException
- In previous releases starting with version 1.4.0, a
ClassNotFoundExceptionthrown by the
ObjectInputStream.readClassDescriptormethod would be reflected to the top-level caller of
StreamCorruptedExceptionwith an empty cause. It is now reflected to the top-level caller as an
InvalidClassExceptionwith the original
ClassNotFoundExceptionas the cause.
- Bug fix: thread waiting on a java.io.ObjectStreamClass$EntryFuture for notification from [sic]
- In previous releases starting with version 1.4.0, the
ObjectStreamClass.lookupmethod could deadlock if called from within the static initializer of the class represented by the method's
Classargument. Deadlock should no longer occur in this case.
- Bug fix: no spec for serialVersionUID
- The javadoc for the
Serializableinterface has been expanded to more completely specify the role and usage of
serialVersionUIDs, and to emphasize the need to specify explicit
serialVersionUIDs for serializable classes.
2004 Sun Microsystems, Inc. All Rights
Please send comments to: email@example.com