scala / pickling

Fast, customizable, boilerplate-free pickling support for Scala
lampwww.epfl.ch/~hmiller/pickling
BSD 3-Clause "New" or "Revised" License
831 stars 79 forks source link

Java UUID cast as a Scala Any does not pickle correctly #336

Open dodnert opened 9 years ago

dodnert commented 9 years ago

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)
}
jsuereth commented 9 years ago

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.