scala class serialization, impossible to fix SerialVersionUID

I'm currently testing remote actors to communicate between Android and Windows. Actors remote sends differents classes where I set the serialVersionUID.

This is the code of my serialized class:

@SerialVersionUID(13.asInstanceOf[Long]) case class IdentifyMessage(userName : String, user : User, code : Int)

the problem is that the remote actors debug says there is a problem with incompatible class:

caught java.io.InvalidClassException: scala.actors.remote.Node; local class incompatible: stream classdesc serialVersionUID = -6610463074147725500, local class serialVersionUID = -7525549079045563153

Why my SerialVersionUID doesn't matter for compiler?

How do I do to fix serialVersionUID? or maybe there is an another problem?

thanks

Answers


For some reason using the long version of 13, 13l, works better:

@SerialVersionUID(13l) case class IdentifyMessage(userName : String, user : User, code : Int)

Tested in REPL with:

java.io.ObjectStreamClass.lookup(IdentifyMessage("hei", User(), 8).getClass).getSerialVersionUID()

Update

I also tried to run it as a program; like this:

object SerialTest extends App {
  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)
  println("#1 " + java.io.ObjectStreamClass.lookup(IdentifyMessage1("hei", User(), 8).getClass).getSerialVersionUID)
  println("#2 " + java.io.ObjectStreamClass.lookup(IdentifyMessage2("hei", User(), 8).getClass).getSerialVersionUID)
}

... and got:

#1 6829060442504540290
#2 13

Need Your Help

How can I autoformat/indent C code in vim?

c vim code-formatting

When I copy code from another file, the formatting is messed up, like this:

Adding id's to html components dynamically using jquery

php javascript jquery mysql

I am trying to auto save the content of my page and dump it into the database.Before inserting it,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.