forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scala#3711 from retronym/ticket/8549-2
SI-8549 Serialization: fix regression with @serialversionuid / start enforcing backwards compatibility
- Loading branch information
Showing
10 changed files
with
231 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
t6988.scala:3: error: annotation argument needs to be a constant; found: 13.asInstanceOf[Long] | ||
@SerialVersionUID(13.asInstanceOf[Long]) case class IdentifyMessage1(userName: String, user: User, code: Int) | ||
^ | ||
t6988.scala:8: error: annotation argument needs to be a constant; found: O.SerialUID | ||
@SerialVersionUID(O.SerialUID) case class IdentifyMessage3(userName: String, user: User, code: Int) | ||
^ | ||
two errors found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
case class User() | ||
|
||
@SerialVersionUID(13.asInstanceOf[Long]) case class IdentifyMessage1(userName: String, user: User, code: Int) | ||
@SerialVersionUID(13l) case class IdentifyMessage2(userName: String, user: User, code: Int) | ||
object O { | ||
val SerialUID = "13".toLong | ||
} | ||
@SerialVersionUID(O.SerialUID) case class IdentifyMessage3(userName: String, user: User, code: Int) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#1 13 | ||
#2 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
case class User() | ||
|
||
@SerialVersionUID(13l) case class IdentifyMessage1(userName: String, user: User, code: Int) | ||
@SerialVersionUID(10l + 3l) case class IdentifyMessage2(userName: String, user: User, code: Int) | ||
|
||
object Test extends App { | ||
println("#1 " + java.io.ObjectStreamClass.lookup(IdentifyMessage1("hei", User(), 8).getClass).getSerialVersionUID) | ||
println("#2 " + java.io.ObjectStreamClass.lookup(IdentifyMessage2("hei", User(), 8).getClass).getSerialVersionUID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
warning: there were 2 deprecation warning(s); re-run with -deprecation for details |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) | ||
} |