Reputation: 267
I have the problem of serialized objects having a mismatching serialversionuids.. Here is my scenario...
Version 1. Class A extends Class B, both implement serializable, Class B DOES NOT HAVE A SERIAL UID
Version 2. Class A extends Class B, both implement serializable, Class B NOW HAS A SERIAL UID*, CLASS A's serialuid is same as that of version 1.
sadly i dont have access to the java sources, so i checked here and on other sites and found a workaround by overriding the readclassdescriptor of my objectinputstream and using that to read the objects.. however, i followed the example to the letter but my code still reports that the serialversionuids (of class B) still do not match.. i even tried another solution where i "inject" the Class B version 2's serialversionuid into Class B v1's data and then read using objectinputstream but i can't find the serialversionuid in the file where Class B v1's objects are persisted (using a hex viewer/editor) .. any ideas how i can overcome this? Thanks
Upvotes: 0
Views: 297
Reputation: 533680
I would set the serialVersionUID to 1 and when you get your error message like
serialVersionUID=-1023774639622504485 local class serialVersionUID=1
you know that if you change your serialVersionUID to -1023774639622504485
L or what ever it is it will match what you have currently. This will allow you to get past the uid check.
Upvotes: 2