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

ClassCastError when use ArrayBuffer #20

Open
ponkotuy opened this issue May 19, 2015 · 1 comment
Open

ClassCastError when use ArrayBuffer #20

ponkotuy opened this issue May 19, 2015 · 1 comment
Labels

Comments

@ponkotuy
Copy link

import org.msgpack.annotation.Message
import org.msgpack.ScalaMessagePack
import scala.collection.mutable

@Message
class A {
  var names: scala.collection.Seq[String] = Nil
}

object Main extends App {
  val a = new A()
  a.names = mutable.ArrayBuffer("a", "b")
  val serialized : Array[Byte] = ScalaMessagePack.write(a)
}
[error] (run-main-0) java.lang.ClassCastException: scala.collection.mutable.ArrayBuffer cannot be cast to scala.collection.immutable.List
java.lang.ClassCastException: scala.collection.mutable.ArrayBuffer cannot be cast to scala.collection.immutable.List
    at org.msgpack.template.ImmutableListTemplate.write(ImmutableListTemplate.scala:32)
    at org.msgpack.template.AbstractTemplate.write(AbstractTemplate.java:27)
    at A_$$_Template_1493359522_0.write(A_$$_Template_1493359522_0.java)
    at org.msgpack.template.AbstractTemplate.write(AbstractTemplate.java:27)
    at org.msgpack.MessagePack.write(MessagePack.java:196)
    at org.msgpack.ScalaMessagePackWrapper$class.write(ScalaMessagePack.scala:64)
    at org.msgpack.ScalaMessagePack$.write(ScalaMessagePack.scala:43)
    at Main$.delayedEndpoint$Main$1(Main.scala:13)
    at Main$delayedInit$body.apply(Main.scala:10)
    at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
    at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.App$$anonfun$main$1.apply(App.scala:76)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
    at scala.App$class.main(App.scala:76)
    at Main$.main(Main.scala:10)
    at Main.main(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
@ponkotuy
Copy link
Author

more simple

scala> import org.msgpack.ScalaMessagePack
 import org.msgpack.ScalaMessagePack
scala> val mp = new ScalaMessagePack()
 mp: org.msgpack.ScalaMessagePack = org.msgpack.ScalaMessagePack@2054a05e
scala> mp.write(collection.mutable.ArrayBuffer(1,2,3))
 java.lang.ClassCastException: scala.collection.mutable.ArrayBuffer cannot be cast to scala.collection.immutable.List at
org.msgpack.template.ImmutableListTemplate.write(ImmutableListTemplate.scala:32) at
org.msgpack.template.AbstractTemplate.write(AbstractTemplate.java:27) at
org.msgpack.MessagePack.write(MessagePack.java:196)

@xerial xerial added the 0.6.x label Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants