aspose file tools*
The moose likes I/O and Streams and the fly likes Deserialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Deserialization" Watch "Deserialization" New topic
Author

Deserialization

Santosh Kumar Nayak
Ranch Hand

Joined: Aug 02, 2011
Posts: 107
When Deserialization is successful in another JVM2 then how does it notify the first JVM as "Deserialization is successful"
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42639
    
  65
It doesn't. Why do you think it should?


Ping & DNS - my free Android networking tools app
Santosh Kumar Nayak
Ranch Hand

Joined: Aug 02, 2011
Posts: 107
Just wanted to know if there is any mechanism via which we can make sure the De-serialization was successful.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42639
    
  65
In a different JVM? You'd have to put in place some communication protocol of your design.
Santosh Kumar Nayak
Ranch Hand

Joined: Aug 02, 2011
Posts: 107
Thanks for your reply.

Can you tell me as what are the ways the serialized object is transferred to another JVM ?

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42639
    
  65
Java's built-in serialization classes (Object[In|Out]putStream and XML[En|De]coder) write to OutputStreams, from which you can obtain a byte[] - you can then use those in whichever way you see fit. Note that binary serialization frequently does not work if source JVM and target JVM have different versions, and XML serialization needs the transferred objects to be JavaBeans.
Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 493
    
    1

Ulf Dittmer wrote:Note that binary serialization frequently does not work if source JVM and target JVM have different versions..

Really ? Even for java built-in serialization / deserialization ?
As far as you know, what are circumstances under which default Java serialization / deserialization mechanism may fail ?

Thank you.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42639
    
  65
Binary serialization relies on identical serialVersionUID, which can be different for the same class between different JVMs implementing the same Java version (say, JRockit 1.6 and OpenJDK 1.6), or different between two versions of the same JVM implementing different Java versions (say, OpenJDK 1.6 and OpenJDK 1.7), or sometimes even between two versions of the same JVM implementing different patch releases of the same Java version (say, OpenJDK 1.6.25 and OpenJDK 1.6.45).

http://www.mkyong.com/java-best-practices/understand-the-serialversionuid/ has some more information on that.
Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 493
    
    1

I've read the article you suggested... In my working scenario, I Exchange dataobject from java client to java server in serialized form. I never run into any issue; do you think that may
be sufficient to provide my custom object with a serialUID to avoid issues ? By the way: of course, I have both client and server side the same version of objects.
If they are disaligned, an exception is surely going to be thrown.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42639
    
  65
Adding a serialVersionUID helps make the version explicit, but it can also be source of problems - for example, if you forget to change it after making incompatible changes to a class.
Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 493
    
    1

Thank you for your answer.
Oleg Glizerin
Greenhorn

Joined: Apr 15, 2014
Posts: 15
thanks it helped me 2
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2366
    
  50
Welcome to the Ranch Oleg
 
Consider Paul's rocket mass heater.
 
subject: Deserialization