Suppose I have two HashMaps: hashMapFoo and hashMapBar.
I create some object objCake and put it into both maps, so each map has a reference to objCake, and when I make some changes to objCake whichever map I access it from, I get correct state of my object.
After I serialize both maps and deserialize them, I meet problem that my object objCake has become two different objects! I change its state in hashMapFoo, but nothing happens in hashMapBar. hashMapBar does not contain the correct reference any more!
All maps and objects implement Serializable.
Can anyone please explain?
Works for me:
Show us your code. You probably call
reset()on the ObjectOutputStream between the first and the second map. Or you use two difference ObjectOutputStream instances.