Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Object Serialization how it will work?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Object Serialization how it will work?

    Hi,

    I saved a object in file with serialization method and then i change the class defination and after it i deserialize the object it will work or not?

    //old class
    Class A
    {
    int i;
    }
    //new class
    class B
    {
    int a;
    }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Object Serialization how it will work?

    Interesting question.
    Try it and see.

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Object Serialization how it will work?

    Hi,

    it does not work.
    As i know when i try to save the object jvm also create hashcode(serialVersionUID ) for our class and also save it with the object.and when i pick the object from the memory after changing the name of the variable at that time hash code generated by the jvm for our class is different from the privous one that is save in memory so jvm throws class cast exception.

    can any body explain what information jvm save with the object during Serialization.?
    and how de serialization work?

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Object Serialization how it will work?

    Quote Originally Posted by ashish12169 View Post
    can any body explain what information jvm save with the object during Serialization.?
    and how de serialization work?
    See The Java serialization algorithm revealed | JavaWorld's Daily Brew

  5. The Following User Says Thank You to copeg For This Useful Post:

    ashish12169 (July 19th, 2013)

Similar Threads

  1. Can't work out how to read object from .txt file
    By goformickey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 25th, 2012, 01:27 AM
  2. JDBC vs Serialization
    By hafunui in forum Java Theory & Questions
    Replies: 2
    Last Post: May 1st, 2012, 05:02 PM
  3. Serialization of lists
    By colerelm in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 5th, 2011, 10:39 PM
  4. Sub class Serialization
    By Param in forum Java Theory & Questions
    Replies: 6
    Last Post: April 23rd, 2010, 02:04 AM
  5. serialization problem
    By Park in forum Object Oriented Programming
    Replies: 2
    Last Post: November 26th, 2009, 04:44 PM