diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-05-05 11:32:43 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-05-05 12:29:41 +0200 |
commit | ecbc9d02153e9ad3a710c7c2c0f385797b1ba3a6 (patch) | |
tree | 71addf3344b1fdfaeee21cfd5d3d5e5cd0b9ae58 /test/files | |
parent | fc4602a1415066f897530b6995299de1f3d9830f (diff) | |
download | scala-ecbc9d02153e9ad3a710c7c2c0f385797b1ba3a6.tar.gz scala-ecbc9d02153e9ad3a710c7c2c0f385797b1ba3a6.tar.bz2 scala-ecbc9d02153e9ad3a710c7c2c0f385797b1ba3a6.zip |
SI-8549 Honour the @SerialVersionUID annotatation
In PR #1673 / 4267444, the annotation `SerialVersionId` was
changed from a `StaticAnnotation` to `ClassFileAnnotation` in
order to avoid silently ignoring non-literal UIDs like:
@SerialVersionUID(0 - 12345L) class C
And to flag non-constant UIDs:
@SerialVersionUID("!!!".length)
While this indeed was fold constants, the change was incomplete.
The compiler API for reading the argument from a `ClassFileAnnoation`
is different, on must look for a `LiteralAnnotArg`, rather than a
`Literal`.
This commit:
- amends the backend accordingly
- removes relevant duplication between `GenASM` and `GenBCode`
- tests that the static field is generated accordingly
This will mean that we will break deserialization of objects from
Scalal 2.11.0 that use this annotation.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t8549b.scala | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/files/run/t8549b.scala b/test/files/run/t8549b.scala new file mode 100644 index 0000000000..1e1bf2c0bc --- /dev/null +++ b/test/files/run/t8549b.scala @@ -0,0 +1,16 @@ + +@SerialVersionUID(42) +class C + +@SerialVersionUID(43 - 1) +class D + + +object Test extends App { + def checkId(cls: Class[_]) { + val id = cls.getDeclaredField("serialVersionUID").get(null) + assert(id == 42, (cls, id)) + } + checkId(classOf[C]) + checkId(classOf[D]) +} |