Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 958102

Pages: 1
Anonymous
Unregistered




Uniqueness
      #35202 - 08/10/06 05:25 AM

Does the serialVersionUID has to be unique within the class, or within the universe? I.e. will class Foo with serialVersionUID 0L be compatible with class Bar with same serialVersionUID?
Is it a bad practice to use sequential serialVersionUID starting from 0L and being incremented by 1 for each new version, for all your classes.


Post Extras: Print Post   Remind Me!   Notify Moderator  

Unregistered




Re: Uniqueness [Re: Anonymous]
      #47016 - 05/08/07 01:55 PM

>>if this is your application's bottleneck, then something is very wrong with your overall design.

I don't know, I'm thinking if this is my bottleneck (5-50ms), I'm very very happy!! good design!!


Post Extras: Print Post   Remind Me!   Notify Moderator  
Keith R. Bennett
Unregistered




Re: Uniqueness [Re: Anonymous]
      #49352 - 06/21/07 11:53 AM

This article is correct, as long as you are not deserializing objects of this class coming in from outside your JVM.

If you are reading objects from a stream, they will be deserialized, and this is when you will probably want the class to have an explicitly specified serialVersionUid. Otherwise, the runtime will need to calculate it for each object coming in, in order to compare it with the one it knows to be "correct" for your class. This is where the performance difference may be significant.

To answer a previous question, the serialVersionUID does not need to be globally unique; the JRE will only need it in the context of a given class. So it's ok for multiple classes to share the same uid.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 5936

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5