pickling icon indicating copy to clipboard operation
pickling copied to clipboard

Java UUID cast as a Scala Any does not pickle correctly

Open dodnert opened this issue 9 years ago • 1 comments

The issue I am seeing is that a java.util.UUID value is not pickled correctly if that value has been cast to a scala.Any. In my application, the value to be pickled is passed in to my application as an Any reference. Can this be made to work if the value is a UUID?

A call to the test function below results in this output: { "$type": "java.util.UUID" }

import scala.pickling.Defaults._
import scala.pickling.json._

def test() = {
  val uuid = UUID.fromString("e3aa05c0-c771-11e4-b8a8-6146c4071e0f")
  val p = uuid.asInstanceOf[Any].pickle.value
  println(p)
}

dodnert avatar Jun 02 '15 17:06 dodnert

Note: This is related to a series of java pickling issues. Essentially, most of the field information for java types is erased at compile time by the scala compiler (as it doesn't need that) so the pickling algorithms are broken. In 0.11.x we've disabled generating arbitrary java picklers until we have a new mechanism of handling them.

jsuereth avatar Aug 12 '15 17:08 jsuereth