Forums Register Login

Serialization doubt

+Pie Number of slices to send: Send
i Serialize the class A object in class A and store in test.ser file . then i DeSerialize the object from class B .here i notice serializa and Deserialize objects are same[no new object created] . but if i deserialize[serialize+deserialize] in same class A , then i am getting new Object
+Pie Number of slices to send: Send
 

seetharaman venkatasamy wrote:... then i DeSerialize the object from class B .here i notice serializa and Deserialize objects are same[no new object created] . ...



How did you test it ? Are you deserializing in the same JVM? Then how ?
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
 

Maneesh Godbole wrote:http://faq.javaranch.com/java/TellTheDetails





i tested in same jvm only.the asware is



if i remove the Deserialization part from Rob and put the in separate class[Test]



if you run both class separatly

then output



i am not sure whether i confuse. but please some one explain
+Pie Number of slices to send: Send
 

seetharaman venkatasamy wrote:if i remove the Deserialization part from Rob and put the in separate class[Test]
if you run both class separatly then output



You are running them separately so it's obvious they are not the same but heppens to have the same hashcode values generated by the JVM.
+Pie Number of slices to send: Send
 

Vijitha Kumara wrote:

seetharaman venkatasamy wrote:if i remove the Deserialization part from Rob and put the in separate class[Test]
if you run both class separatly then output



You are running them separately so it's obvious they are not the same but heppens to have the same hashcode values generated by the JVM.



well, then what about my first scenario result ?
+Pie Number of slices to send: Send
 

seetharaman venkatasamy wrote:well, then what about my first scenario result ?



Serialized object has nothing to do with the deserialized one, those are two different objects.
+Pie Number of slices to send: Send
Thanks Vijitha . somehow i got
+Pie Number of slices to send: Send
 

java.io.ObjectInputStream wrote:New objects are always allocated when deserializing, which prevents existing objects from being overwritten.



Just to confirm
+Pie Number of slices to send: Send
 

Vijitha Kumara wrote:

java.io.ObjectInputStream wrote:New objects are always allocated when deserializing, which prevents existing objects from being overwritten.


Just to confirm



Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1592 times.
Similar Threads
serialization of static members
Question about clone a Hashtable
Help! Getting java.io.StreamCorruptedException
Serialization Error
How to clone a object containing collection?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:40:02.