Given a class Parent, which has been serialized to XML.
class Parent {
Object A;
Child child;
}
class Child {
Object C;
...
}
class Parent {
Object A;
Object C;
Child child;
}
class Child {
...
}
Since you are deserializing the xml, it was already generated, and a serialVersionUID was generated (it means if there is any difference in the class which was compiled again, another serialVersionUID will be generated), so it doesn't have this attribute defined on it, when you deserialize it and try to cast, it is going to throw an exception.
You will have to deserialize the two classes (Parent and Child) and set it on code like:
XStream xstream = new XStream();
NewParent newParent = new NewParent();
OldParentWithoutC oldParent = (OldParentWithoutC) xstream.fromXML(xml);
OldChild oldChild = (OldChild) xstream.fromXML(xml);
newParent.setObjectC(oldChild.getC());
String xml = xstream.toXML(newParent);
Then you can serialize it again.