File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization doubt

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vijitha . somehow i got
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic