-
Notifications
You must be signed in to change notification settings - Fork 21
SerialVersionUID not working (Scala 2.9.3, Mac OSX 10.8.2, Java 1.7.0_09, Eclipse Juno) #6713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6713?orig=1
|
@paulp said: |
John Crowley (jcrowley) said: Not a clue -- it was a puzzle to me also. On the working (Windows) environment, when I forced an error by diddling with the local SerialVersionUID the error message did include the correct class name. I'm trying to see if I can reproduce the problem in a self-contained app. Will post that if I am successful. John |
John Crowley (jcrowley) said: On the server the instance is serialized into a byte stream, then converted to Base64 for transmission, and converted back at the client. I need to verify that nothing changes during the conversion/reconversion. |
@paulp said: |
John Crowley (jcrowley) said: |
John Crowley (jcrowley) said: I did not solve the original problem, but suspect that it involved an Enumeration (a couple of values were present in the object being serialized). One enumeration had been expanded a bit (a new class extended the basic Value). I went back and added @SerializeVersionUID to all of these (even the class that extended Value), but still got the same failure. At that point, had to move on .... As a workaround, I finally changed the objects involved so that they contained nothing but primitive values, Strings, or Arrays of same. Where there was previously an Enumeration Value it was changed to be the ID of the entry (a simple Int). Added a def to convert that back to the original Value -- so only the Int ID is actually serialized, but the caller can still work with the Enumeration value as before. A kludge to be sure, but have already fiddled with it for 2 days without any real progress. Also suspect that the "default" calculation of a UID works differently between the environments. Don't know if it's the 64-bit vs 32-bit difference, different Scala versions, or what. (Remember that if it was compiled under 2.9.1 on 32-bit Windows, and built an executable Jar, then it would execute correctly on the OSX machine with Java 1.7.0_09) Understand that the "default" UID calculation will be very sensitive to any changes to the Class definition, but in this case (at least at the source level) the definitions were identical and it looks like it still calculated different values. That is probably not a good thing. There may also be something nasty going on in how an Enumeration handles serialization. I'll see if I can build a standalone test case with an Enumeration involved to see if we can further isolate the problem. John |
John Crowley (jcrowley) said: Wrote a standalone routine to serialize an object with a couple of Enumerations. It dumps the serialized byte array to the console (with the description of the environment). Also contains a List(String, Array[Byte]) (description, serialization) of test cases that are de-serialized. Ran on 3 different environments, and everything appears to work correctly. Standalone routine is attached if it would be of any use to anyone. Still scratching my head ..... John |
Code snippet:
@serialversionuid(1000L)
class dsContextBase(status:VersionStatus.Value) extends Serializable
....
@serialversionuid(1001L)
class dsContext(status:VersionStatus.Value) extends dsContextBase(status)
....
The 'dsContext' class is the one actually being serialized/deserialized (sent from a server to a client).
This all works compiling on a Windows XP machine, Scala 2.9.1, Java 1.7.0_07, Eclipse Indigo. In fact, on the client I deliberately modified the SerialVersionUID and forced the expected errors on de-serialization. The error messages included the correct SerialVersionUID values for both the external and local classes.
On the Mac, get the error:
java.io.InvalidClassException: scala.reflect.ClassTypeManifest; local class incompatible: stream classdesc serialVersionUID = -1175914390044276083, local class serialVersionUID = -6957848672150754496
First note that the local serialVersionUID is not as expected. It appears that the annotation was ignored and the default UID was computed.
If I compile on the Windows machine, create a JAR, copy the Jar to the MAC machine, and then execute from that Jar -- it works. So it would appear that Mac OS X and Java 1.7.0_09 are not the culprits.
The text was updated successfully, but these errors were encountered: