Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

serialization how does it work

 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please clear this for me...
1.I have serialized an object and written it to a text file.
2.The object that i have serialized implements an interface other than that of serializable.
3.now in a different jvm instance where i can import only the interface and not the implementation( that i have serialized ) ,I say
InterfaceName ii=(InterfaceName)ois.readObject();
4.now i invloke
ii.interfaceMethod();
and it works....
My query when only the non-static and non-transient variables are stored in the process of serialization how am i able to invoke methods when i donot have the implementation of the interface with me??
hope i am clear of what i want..
thanx in advance
kane
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not think that there is any "magic" going on. If the program doing the reading (deserialisation) is able to successfully deserialise the object from the stream, then it must be able to load the implementation class.
Typically, this means that the implementation class is on the class path. However, if you have installed some special ClassLoader, then the implementation class might be getting loaded in another way (e.g. over a network connection), via that ClassLoader.
That does not mean that the source code of the program doing the reading has to import the implementation class. Importing is something you do to help the compilation process, not the run-time process.
 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter Chase:
I do not think that there is any "magic" going on. If the program doing the reading (deserialisation) is able to successfully deserialise the object from the stream, then it must be able to load the implementation class.
Typically, this means that the implementation class is on the class path. However, if you have installed some special ClassLoader, then the implementation class might be getting loaded in another way (e.g. over a network connection), via that ClassLoader.
That does not mean that the source code of the program doing the reading has to import the implementation class. Importing is something you do to help the compilation process, not the run-time process.


hey thanks peter,
Yes that must have been the thing,I was hit by this query when we were having bussiness objects returned by an enterprise bean and the client just had the interface.
I'll check up how weblogic is going about this thing jus to be doubly sure
thanx again
william

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!