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

scalac 2.11 regression. Scalac is not honouring the SerialVersionUID annotation #8549

Closed
scabug opened this Issue Apr 30, 2014 · 10 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Apr 30, 2014

Compiling this code:

package test

@SerialVersionUID(1)
class Ser extends Serializable

using 2.10 and then running the following:

object Main extends App {
  println( classOf[test.Ser].getDeclaredField("serialVersionUID") )
}

Will print public static final long test.Ser.serialVersionUID

However, compiling the same with 2.11 gives a NoSuchFIeldException

@scabug

This comment has been minimized.

Copy link

scabug commented Apr 30, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8549?orig=1
Reporter: @oxbowlakes
Affected Versions: 2.11.0

@scabug

This comment has been minimized.

Copy link

scabug commented Apr 30, 2014

@oxbowlakes said:
I can see that this has affected scala library classes as well. This is a terrrible regression!

Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> Nil.getClass.getDeclaredField("serialVersionUID").get(null)
res0: Object = -8256821097970055419

But with 2.11

Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> Nil.getClass.getDeclaredField("serialVersionUID").get(null)
java.lang.NoSuchFieldException: serialVersionUID
  at java.lang.Class.getDeclaredField(Class.java:1948)
  ... 32 elided
@scabug

This comment has been minimized.

Copy link

scabug commented Apr 30, 2014

@retronym said:
Regressed in scala/scala#1673

@scabug

This comment has been minimized.

Copy link

scabug commented Apr 30, 2014

@oxbowlakes said:
It strikes me that you're in a dilemma here. Are the serialization IDs of things like Nil part of the "binary compatibility" of scala to be kept between minor versions? If so, there's a task to retrofit the new-and-incorrect IDs onto the source for 2.11.1

@scabug

This comment has been minimized.

Copy link

scabug commented Apr 30, 2014

@retronym said:
You read my mind. I've tabled the options in your thread: https://groups.google.com/forum/#!topic/scala-user/lauGrJItfX4

I am leaning towards retrofitting. I believe I can automate the process so we don't miss any.

@scabug

This comment has been minimized.

Copy link

scabug commented May 1, 2014

@paulp said:
For what it's worth it has previously been decreed that "binary compatibility does not cover serialization" in #5697.

@scabug

This comment has been minimized.

Copy link

scabug commented May 1, 2014

@paulp said:
Also it would appear scala/scala#1673 was intended to fix #6988 but that ticket is still open. Actually no, the commit is Nov 2012 but the ticket was opened in Jan 2013.

@scabug

This comment has been minimized.

Copy link

scabug commented May 1, 2014

@oxbowlakes said:
(Duplicating comment from ML):

Also note that for any non-trivial scala project which uses serialization, then doing trying to make SerialUIDs consistent in the scala library between 2.11.0/1 is pretty useless unless all library dependencies (which include serialized classes) also follow this route. For example, if I'm using akka, an ActorRef is serializable (see SerializedActorRef at https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/actor/ActorRef.scala): they may have to do exactly the same.

It seems unlikely that all my dependencies are going to "fix" their codebase's Serial IDs, so it's really unlikely that my non-trivial scala project is actually going to end up being really binary+serialization-compatible for 2.11.0/1.

@scabug

This comment has been minimized.

Copy link

scabug commented May 5, 2014

@scabug

This comment has been minimized.

Copy link

scabug commented May 10, 2014

@retronym said:
Reopening to track the partial reversion of the serialization stability test case here: scala/scala#3739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment