chill
chill copied to clipboard
Breaks with polymorphic singletons
I'm using chill 2.12 version 0.9.2.
I have this test code:
trait Foo
object Bar extends Foo
case class FooHolder(foo: Foo)
object ChillTest {
def main(args: Array[String]): Unit = {
val instantiator = new ScalaKryoInstantiator
instantiator.setRegistrationRequired(false)
val kryo = instantiator.newKryo()
kryo.setRegistrationRequired(false)
val baos = new ByteArrayOutputStream
val out = new Output(baos, 4096)
kryo.writeObject(out, Seq(FooHolder(Bar)))
val in = new Input(baos.toByteArray)
val deser = kryo.readObject(in, classOf[Seq[FooHolder]])
println(deser)
}
}
Which yields an InstantiationError:
Exception in thread "main" java.lang.InstantiationError: scala.collection.Seq
at sun.reflect.GeneratedSerializationConstructorAccessor1.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:45)
at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:1061)
at com.esotericsoftware.kryo.serializers.FieldSerializer.create(FieldSerializer.java:547)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:523)
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:657)
at com.phoenixkahlo.hellcraft.serial.KryoTest$.main(GlobalKryo.scala:75)
at com.phoenixkahlo.hellcraft.serial.KryoTest.main(GlobalKryo.scala)
Am I using this wrong, or is this a glitch? Thanks.