Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are the compatible and incompatible changes when dealing with versioned serialized objects?

0
Posted

What are the compatible and incompatible changes when dealing with versioned serialized objects?

0

Location: http://www.jguru.com/faq/view.jsp?EID=5064 Created: Jan 15, 2000 Author: Govind Seshadri (http://www.jguru.com/guru/viewbio.jsp?EID=14) If a newer version of a serialized object has to be compatible with an older version, it is important that the newer version abides by the rules for compatible and incompatible changes. A compatible change is one that can be made to a new version of the class, which still keeps the stream compatible with older versions of the class. Examples of compatible changes are: • Addition of new fields or classes does not affect serialization, as any new data in the stream is simply ignored by older versions. When the instance of an older version of the class is deserialized, the newly added field will be set to its default value. • You can field change access modifiers like private, public, protected or package as they are not reflected to the serial stream. • You can change a transient or static field to a non-transient or non-static field, as it is

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.