in Java Serialization concept. In an already serialized object, the most challenging task is to change the structure of a class when a new field is added or removed. As per the specifications of Java Serialization, addition of any method or field is considered to be a compatible change whereas changing of class hierarchy or non-implementation of Serializable interface is considered to be a non-compatible change. You can go through the Java serialization specification for the extensive list of compatible and non-compatible changes. If a serialized object need to be compatible with an older version, it is necessary that the newer version follows some rules for compatible and incompatible changes. A compatible change to the implementing class is one that can be applied to a new version of the class, which still keeps the object stream compatible with older version of same class. Some Simple Examples of compatible changes are: Addition of a new field or class will not affect serialization, since any new data in the stream is simply ignored by older versions. the newly added field will be set to its default values when the object of an older version of the class is un marshaled. The access modifiers change (like private, public, protected or default) is compatible since they are not reflected in the serialized object stream. Changing a transient field to a non-transient field is compatible change since it is similar to adding a field. Changing a static field to a non-static field is compatible change since it is also similar to adding a field.
Java
Topic: Serialization
What changes are compatible and incompatible to the mechanism of java Serialization?
Browse random answers:
Define Serialization? What do you mean by Serialization in Java?
Why is Serialization required? What is the need to Serialize?
What is the Difference between Externalizable and Serializable Interfaces?
When will you use Serializable or Externalizable interface? and why?
What are the ways to speed up Object Serialization? How to improve Serialization performance?
What is a Serial Version UID (serialVersionUID) and why should I use it? How to generate one?
What would happen if the SerialVersionUID of an object is not defined?
Does setting the serialVersionUID class field improve Java serialization performance?
What are the alternatives to Serialization? If Serialization is not used, is it possible to persist or transfer an object using any other approach?
What are transient variables? What role do they play in Serialization process?
Why does serialization NOT save the value of static class attributes? Why static variables are not serialized?
How to Serialize a collection in java? How to serialize a ArrayList, Hashmap or Hashset object in Java?
Is it possible to customize the serialization process? How can we customize the Serialization process?
How can a sub-class of Serializable super class avoid serialization? If serializable interface is implemented by the super class of a class, how can the serialization of the class be avoided?
What changes are compatible and incompatible to the mechanism of java Serialization?
How to make a Java class Serializable?
How many methods Serializable has? If no method then what is the purpose of Serializable interface?
What is serialVersionUID? What would happen if you don't define this?
While serializing you want some of the members not to serialize? How do you achieve it?
What will happen if one of the members in the class doesn't implement Serializable interface?
If a class is Serializable but its super class in not, what will be the state of the instance variables inherited from super class after deserialization?
Can you Customize Serialization process or can you override default Serialization process in Java?
Suppose super class of a new class implement Serializable interface, how can you avoid new class to being serialized?
Which methods are used during Serialization and DeSerialization process in java?
Suppose you have a class which you serialized it and stored in persistence and later modified that class to add a new field. What will happen if you deserialize the object already serialized?
What are the compatible changes and incompatible changes in Java Serialization Mechanism?
Can we transfer a Serialized object vie network?
Which kind of variables is not serialized during Java Serialization?