On Wed, 28 Jun 2000, Stuart Ballard wrote:

> One thing I noticed is that JDK1.1 doesn't return "protected" members in
> getFields/getMethods. Protected members are, of course, vital for
> calculating the svuid. If you're getting results that are right most of
> the time, it might be worth checking whether gcj is doing the same
> thing...

Yeah, after Andrew Haley converted this from native code to java, I then
made a patch to use getDeclaredField instead of getField.

The strange thing is that I get the correct value for test classes I write
and compile with gcj.  My discrepancies are with the JDK 1.1 classes; only
java.io.Serializable seems to match up with the right serialVersionUID
that is generated by the JDK.  Oddly, if I take a class from libgcj,
change the name of the class and then use gcj to compile it in a test dir,
the serialVersionUID generated for that new class then matches the value
computed by the JDK.  I have not looked into why that's happening.

I do note that quite a few classpath classes (over 100, IIRC) specify
their own serialVersionUID value to use as an override for the computed
value.  I haven't looked into it but that seems like an awful lot of
special cases; I'm made more suspicious because classpath's
java.io.Serializable *has* an entry:
        public static final long serialVersionUID = 1196656838076753133L;
but libgcj calculates this value (*without* having to override it in the
class itself).  Even still, I suspect that libgcj is messing up the
calculation somehow for its core packages.  If/when I can take care of
that, I'll be able to tell for which of the classes it really is necessary
to override the calculation.

I notice that some classes that explicitly set a serialVersionUID value
were written by Brian Jones; perhaps he can shed some light on things.

> Other problems that I had causing me to get wrong values were (1)
> completely forgetting that I needed to check a serialVersionUID field if
> it existed, and (2) assuming it had to be *private* static final -
> actually it just has to be static final. Took me ages to find this bug,
> because when the errors are of the form of getting 1437831798324783
> instead of 569468459655654, there aren't many hints as to what you're
> doing wrong...

Ok, thanks.  I'll check into these to see if I can track down my problem.
Like you, I'm appreciative of all the hints I can get ;-).
--warrenl

Reply via email to