1. I have a few instances of the same class X. One of the fields of the class is a reference to an instance of another class Y. All X instances point to the same instance of Y at run time. I want to dump them all, and maintain that relation when later retrieving them. What happens if I dump each instance of X separately?The subsequent instances of X will all point to the Y instance that was deserialized along with the first X. In general, object graphs are preserved.
What is the correct and efficient way of achieving what I want?It works as you want by default.
2. Is it possible to visualize the serialized object, that is, dump it to some human-readable format (something like Data::Dumper in perl)?java.beans.XMLEncoder.