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.

How does XStream deal with newer versions of classes?

0
Posted

How does XStream deal with newer versions of classes?

0

• If a new field is added to the class, deserializing an old version will leave the field uninitialized. • If a field is removed from the class, deserializing an old version that contains the field will cause an exception. Leaving the field in place but declaring it as transient will avoid the exception, but XStream will not try to deserialize it. • If a class is renamed, aliases can be used to create an abstraction between the name used in XML and the real class name. • If a field is renamed, this should be treated as adding a field and removing a field. For more advanced class migrations, you may • have to do custom pre-processing of the XML before sending it to XStream (for example, with XSLT or DOM manipulations) • declare new fields as transient • implement your own converter, that can handle the situation • add a readResolve() method to your class, that initializes the object accordingly • implement a custom mapper to ignore unknown fields automatically (see acceptance test Custo

Related Questions

What is your question?

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

Experts123