This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Serialization doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Serialization doubt" Watch "Serialization doubt" New topic
Author

Serialization doubt

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

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 ?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 9990
    
    7

http://faq.javaranch.com/java/TellTheDetails


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

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.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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 ?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

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.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks Vijitha . somehow i got
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

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


Just to confirm
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Just to confirm


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Serialization doubt
 
Similar Threads
Help! Getting java.io.StreamCorruptedException
How to clone a object containing collection?
Question about clone a Hashtable
Serialization Error
serialization of static members