Lets say I have an array arr
of objects of type A
in memory, each of which has a reference field pointing to the same object B
.
Illustration:
A_1 A_2 A_3 ... A_N
| | | |
| | V |
\--->\--> B <-----/
Note that the reference field in every object of type A
points to the same object of type B
.
Now, I serialize the array arr
containing objects of type A
to an ObjectOutputStream
. I then deserialize the bytes obtained in this way.
I get a new array arr1
.
1) Does the array arr1
have objects of type A
such that they all point to the same object of type B
? (I don't mean the same object before serialization, but a unique newly created object of type B
)
2) In other words, does calling serialize/deserialize in Java retain the same object graph as it was before serialization? (i.e. is the newly deserialized object graph isomorphic to the old one)
3) Where is this documented? (i.e. please provide a citation)
4) The same questions 1-3, but applied to the Kryo serialization framework for Java.
Thank you.
ObjectOutputStream
, or additionally through the same invocation of thewriteObject
method? – Farandole