Anonymous
Unregistered
|
|
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.
|
Unregistered
|
|
>>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!!
|
Keith R. Bennett
Unregistered
|
|
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.
|