summaryrefslogtreecommitdiff
path: root/src/library/scala/SerialVersionUID.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-11-25 18:29:16 -0800
committerPaul Phillips <paulp@improving.org>2012-11-25 19:04:10 -0800
commit426744441c22fa3153b7192bead46f8b244c4f12 (patch)
treed15f9cd20ac0a5c1f1cb9dc14158a6ee1927043d /src/library/scala/SerialVersionUID.scala
parent9afc00c0408e49a111f381334cbdb7fcdaa4f340 (diff)
downloadscala-426744441c22fa3153b7192bead46f8b244c4f12.tar.gz
scala-426744441c22fa3153b7192bead46f8b244c4f12.tar.bz2
scala-426744441c22fa3153b7192bead46f8b244c4f12.zip
Fix for SerialVersionUID instability.
Can hardly believe this has been broken for a decade or so, but there it is - see test case. Four classes attempt to set their SerialVersionUID to 13. One succeeds. No warnings or errors. The output before this patch (for me anyway - your random numbers may differ) was: 860336111422349646 13 8409527228024057943 -7852527872932878365 There was already code in place for rejecting annotations with non-constant args when constant args are required, but that check is only performed on ClassfileAnnotations, and SerialVersionUID was a StaticAnnotation. Maybe people don't reach for ClassfileAnnotation because of this giant warning which I see no way to suppress: warning: Implementation restriction: subclassing Classfile does not make your annotation visible at runtime. If that is what you want, you must write the annotation class in Java. Why did I change the name of the field from uid to value? If you don't use the name 'value', you have to name the argument every time you use it, even if it's the only parameter. I didn't relish breaking every usage of scala's @SerialVersionUID in the known universe.
Diffstat (limited to 'src/library/scala/SerialVersionUID.scala')
-rw-r--r--src/library/scala/SerialVersionUID.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/library/scala/SerialVersionUID.scala b/src/library/scala/SerialVersionUID.scala
index 1f7d047060..77094f0bbf 100644
--- a/src/library/scala/SerialVersionUID.scala
+++ b/src/library/scala/SerialVersionUID.scala
@@ -12,4 +12,4 @@ package scala
* Annotation for specifying the `static SerialVersionUID` field
* of a serializable class.
*/
-class SerialVersionUID(uid: Long) extends scala.annotation.StaticAnnotation
+class SerialVersionUID(value: Long) extends scala.annotation.ClassfileAnnotation