apiaccess.blogg.se

Java serialization data version 5
Java serialization data version 5





java serialization data version 5 java serialization data version 5

If the no-arg constructor is not available, the InvalidClassException is thrown.Ĭhanging the access to a field - The access modifiers public, package, protected, and private have no effect on the ability of serialization to assign values to the fields.Ĭhanging a field from static to nonstatic or transient to nontransient - When relying on default serialization to compute the serializable fields, this change is equivalent to adding a field to the class. The support for subclassing nonserializable classes requires that the class's supertype have a no-arg constructor and the class itself will be initialized to default values. There will be no values in the stream for this class so its fields will be initialized to default values. Removing writeObject/ readObject methods - If the class reading the stream does not have these methods, the required data will be read by default serialization, and the optional data will be discarded.Īdding java.io.Serializable - This is equivalent to adding types. The writeObject method is expected as usual to call defaultWriteObject to write the required data and then may write optional data. It should call defaultReadObject first before reading any optional data. They will be garbage-collected when the stream is garbage-collected or reset.Īdding writeObject/ readObject methods - If the version reading the stream has these methods then readObject is expected, as usual, to read the required data written to the stream by the default serialization. Primitive fields are discarded, but the objects referenced by the deleted class are created, since they may be referred to later in the stream. In this case, the fields and objects corresponding to that class are read from the stream. Removing classes - Comparing the class hierarchy in the stream with that of the current class can detect that a class has been deleted. Since there is no information in the stream from which to initialize the object, the class's fields will be initialized to the default values. Comparing this hierarchy in the stream with the current class can detect additional classes. If class-specific initialization is needed, the class may provide a readObject method that can initialize the field to nondefault values.Īdding classes - The stream will contain the type hierarchy of each object in the stream. The compatible changes to a class are handled as follows:Īdding fields - When the class being reconstituted has a field that does not occur in the stream, that field in the object will be initialized to the default value for its type.

java serialization data version 5

Java Object Serialization Specification: 5 - Versioning of Serializable Objects







Java serialization data version 5