Why are case objects serializable and case classes not?

后端 未结 2 1918
半阙折子戏
半阙折子戏 2021-02-05 21:19

I am playing with this example http://scala.sygneca.com/code/remoteactors to learn how remote actors work in Scala (2.8.0). In particular I slightly modified how the messages se

2条回答
  •  無奈伤痛
    2021-02-05 21:34

    @serializable case class Foo
    

    I was also surprised that case objects were serializable per default.

    Edit: After reading the exception properly I suspect that:

    You're trying to send the generated companion object of the case class over the wire, instead of an instance of the case class.

提交回复
热议问题