Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-8549

scalac 2.11 regression. Scalac is not honouring the SerialVersionUID annotation

    Details

      Description

      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

        Attachments

          Issue Links

            Activity

            Hide
            oxbow_lakes Chris Marshall added a comment -

            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
            

            Show
            oxbow_lakes Chris Marshall added a comment - 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
            Hide
            retronym Jason Zaugg added a comment -
            Show
            retronym Jason Zaugg added a comment - Regressed in https://github.com/scala/scala/pull/1673
            Hide
            oxbow_lakes Chris Marshall added a comment -

            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

            Show
            oxbow_lakes Chris Marshall added a comment - 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
            Hide
            retronym Jason Zaugg added a comment -

            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.

            Show
            retronym Jason Zaugg added a comment - 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.
            Hide
            extempore Paul Phillips added a comment -

            For what it's worth it has previously been decreed that "binary compatibility does not cover serialization" in SI-5697.

            Show
            extempore Paul Phillips added a comment - For what it's worth it has previously been decreed that "binary compatibility does not cover serialization" in SI-5697 .
            Hide
            extempore Paul Phillips added a comment -

            Also it would appear https://github.com/scala/scala/pull/1673 was intended to fix SI-6988 but that ticket is still open. Actually no, the commit is Nov 2012 but the ticket was opened in Jan 2013.

            Show
            extempore Paul Phillips added a comment - Also it would appear https://github.com/scala/scala/pull/1673 was intended to fix SI-6988 but that ticket is still open. Actually no, the commit is Nov 2012 but the ticket was opened in Jan 2013.
            Hide
            oxbow_lakes Chris Marshall added a comment -

            (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.

            Show
            oxbow_lakes Chris Marshall added a comment - (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.
            Show
            retronym Jason Zaugg added a comment - https://github.com/scala/scala/pull/3711
            Hide
            retronym Jason Zaugg added a comment -

            Reopening to track the partial reversion of the serialization stability test case here: https://github.com/scala/scala/pull/3739

            Show
            retronym Jason Zaugg added a comment - Reopening to track the partial reversion of the serialization stability test case here: https://github.com/scala/scala/pull/3739

              People

              • Assignee:
                retronym Jason Zaugg
                Reporter:
                oxbow_lakes Chris Marshall
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: