Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks with polymorphic singletons #294

Open
gretchenfrage opened this issue Aug 11, 2017 · 0 comments
Open

Breaks with polymorphic singletons #294

gretchenfrage opened this issue Aug 11, 2017 · 0 comments

Comments

@gretchenfrage
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant