Hi,
I'm using eclipse 3.2 for development and have configured my project to
use JDK 1.5.0_07 with Compiler compliance level 1.3 (using default
compliance settings) and selected all "Classfile Generation" options
except "Inline finally blocks." The problem I'm having is that the
class files that are generated by eclipse are not the same as those
generated by javac (also using JDK 1.5.0_07), which is used in a make
script. javac is invoked like so:
javac -source 1.3 -g -d classes -nowarn -deprecation -classpath
<classpath> ...
The different class files cause a problem because I have serialized
some objects already with the javac classes so when I try to
deserialize them with the eclipse classes, I get the
InvalidClassException. When I run serialver on the offending class
file, I get two different values for the class file generated with
javac and the one generated using eclipse.
Has anyone ever had this or some similar problem? How do I correct this
(besides not using the eclipse class files)? I've spent many hours
scouring the web to find a solution, but have had no success. Any help
would be really appreciated!
Thanks,
Tai
Paul Davis - 27 Jul 2006 19:29 GMT
> Hi,
> I'm using eclipse 3.2 for development and have configured my project to
[quoted text clipped - 23 lines]
> Thanks,
> Tai
Tai,
Try defining this in your class:
private static final long serialVersionUID = 1L;
replace 1 with something sufficiently unique. Reserialize your data
afterwards as well. You should change the serial number when you change
your classes.
tai.thach@gmail.com - 27 Jul 2006 20:26 GMT
Hi Paul,
Thanks for your input. Unfortunately, this is not a feasible solution
for me because the application I'm working on has been deployed at
numerous clients already. So I cannot just add the serialVersionUID
field and regenerate all the classes because I would have to require
all the clients to also reserialize. As you might expect, no one wants
to have to do this. Plus, the data is already stored in those
previously serialized objects, so I still have to retrieve that data
before I could serialize it again with my new class. I've also
considered just using the serialVersionUID from the javac generated
class. But that assumes that the serialVersionUID generated on my
machine matches exactly what has been generated in the older versions
of the class (which did not have the serialVersionUID field). I'm not
completely confident that that assumption is always true.
Any other ideas?
Tai
> > Hi,
> > I'm using eclipse 3.2 for development and have configured my project to
[quoted text clipped - 30 lines]
> afterwards as well. You should change the serial number when you change
> your classes.
Paul Davis - 28 Jul 2006 04:01 GMT
> Hi Paul,
> Thanks for your input. Unfortunately, this is not a feasible solution
[quoted text clipped - 48 lines]
> > afterwards as well. You should change the serial number when you change
> > your classes.
Use the serialver program. Its in the bin directory of your JDK
install.
Point it to an original copy.
You should feed it the same classpath as the original was built on. Set
the new classes to use the value returned.
Hope that helps
Greg R. Broderick - 28 Jul 2006 16:22 GMT
tai.thach@gmail.com wrote in news:1154024384.502849.220290
@p79g2000cwp.googlegroups.com:
> Hi,
> I'm using eclipse 3.2 for development and have configured my project to
[quoted text clipped - 17 lines]
>
> Has anyone ever had this or some similar problem? How do I correct this
How about explicitly specifying the serialVersionUID in the serializable
classes? :-)
c.f.
<http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html>
<http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html#
4100>

Signature
---------------------------------------------------------------------
Greg R. Broderick gregb.usenet200606@blackholio.dyndns.org
A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------