InterviewSolution
| 1. |
What Changes Are Compatible And Incompatible To The Mechanism Of Java Serialization? |
|
Answer» This is one of a difficult and tricky questions and answering this correctly would mean you are an expert 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:
Some Simple Examples of incompatible changes are:
Java serialization is one of the most commonly misunderstood areas. Many developers still think its only used for saving objects on the file system. Hope you found this list useful. Can you think of a questions that is not part of this list? Please don't forget to share it with me in comments section & I will try to include it in the list. This is one of a difficult and tricky questions and answering this correctly would mean you are an expert 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: Some Simple Examples of incompatible changes are: Java serialization is one of the most commonly misunderstood areas. Many developers still think its only used for saving objects on the file system. Hope you found this list useful. Can you think of a questions that is not part of this list? Please don't forget to share it with me in comments section & I will try to include it in the list. |
|