• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Deserialization

 
Ranch Hand
Posts: 230
IntelliJ IDE Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When Deserialization is successful in another JVM2 then how does it notify the first JVM as "Deserialization is successful"
 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't. Why do you think it should?
 
Santosh Kumar Nayak
Ranch Hand
Posts: 230
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wanted to know if there is any mechanism via which we can make sure the De-serialization was successful.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a different JVM? You'd have to put in place some communication protocol of your design.
 
Santosh Kumar Nayak
Ranch Hand
Posts: 230
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.

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

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 1359
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1359
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1359
39
IBM DB2 Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your answer.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks it helped me 2
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Oleg
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic