It is possible to specify the serialVersionUID, however, if I do that I
have to make sure that it is exactly the same as the original class
file. Although I can find the old class file and get its
serialVersionUID, I am betting that there is no other version out there
that may have had a different UID. I think this is a fairly safe bet,
but as this is a product that has shipped to numerous customers, I
cannot make this change without handling all the different scenarios.
This would involve much more code and testing, which is not currently
possible for me.
> > Hi,
> > I'm using eclipse 3.2 for development and have configured my project to
[quoted text clipped - 24 lines]
>
> - Oliver
Oliver Wong - 28 Jul 2006 19:42 GMT
[post re-ordered]
>> > Hi,
>> > I'm using eclipse 3.2 for development and have configured my project to
[quoted text clipped - 33 lines]
> This would involve much more code and testing, which is not currently
> possible for me.
From the JavaDocs:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html
<quote>
it is strongly recommended that all serializable classes explicitly declare
serialVersionUID values, since the default serialVersionUID computation is
highly sensitive to class details that may vary depending on compiler
implementations, and can thus result in unexpected InvalidClassExceptions
during deserialization. Therefore, to guarantee a consistent
serialVersionUID value across different java compiler implementations, a
serializable class must declare an explicit serialVersionUID value.
</quote>
Also, AFAIK, the Java serialization mechanism is not intended for long
term storage of objects, so if you need to serialize and deserialize objects
across different versions of your application, you may be in for a lot of
headaches.
I'm not sure that there's a quick fix for this problem. You may have to
do some re-design work.
- Oliver