Results 1 to 5 of 5
  1. #1
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

    Default SerialVersionUID

    Hi,

    When i want to serialize a class i have to put a serialversionUID into the class when i want to make small changes.

    When this class has subclasses that are serialized with, do i have to put a SerialVersionID in them also ?

    Kind regards

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Dipke View Post
    Hi,
    When i want to serialize a class i have to put a serialversionUID into the class when i want to make small changes.
    You should have this variable present even before you make small changes.


    When this class has subclasses that are serialized with, do i have to put a SerialVersionID in them also ?
    What happens when you try it? Do you get a compiler warning if you don't?

  3. #3
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

    Default

    Hello,

    I have this variable present, but only in the "main" class.
    I have not tried it with a small change into the subclasses.

    Grz

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Dipke View Post
    I have this variable present, but only in the "main" class.
    I have not tried it with a small change into the subclasses.
    Every class that is serializable should define that long UID field, no matter whether or not a superclass is also serializable. The deserialization process checks that number for compatibility of the present class and the object to be deserialized. You can trust on the default UID if your classes never change (something that will almost never happen).

    kind regards,

    Jos

  5. #5
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 01-09-2009, 07:23 PM
  2. serialVersionUID
    By jon80 in forum New To Java
    Replies: 5
    Last Post: 05-04-2008, 08:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •