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

Unable to pickle List[T], e.g. List[String] when running `staticOnly` #360

Open elm- opened 9 years ago

elm- commented 9 years ago

I'm trying to pickle a more complex case class, (nested over 4 levels with Map's, List's and Case Objects based types). When using dynamic pickling the compilation fails with an out of memory error after several minutes, even with 8GB of memory. I used the static pickler to figure out where it fails, the problem are List types in the case classes. Therefore I tried to pickle a simple List[String], even there i get the following exception:

cannot generate fully static pickler because: 'scala.collection.immutable.$colon$colon' allows unknown subclasses (it is not sealed or final isCaseClass=false isEffectivelyFinal=false isSealed=false directSubclasses=List())
[error]   val pickler = Pickler.generate[List[String]]

It's scala 2.11.6 with latest pickling.

Is this a known issue and if so, does a work around exist? I'm right now trying to write my own list pickler for the specific types to see if that helps.

jsuereth commented 9 years ago

@elm- I may have just ran into that. My current (massive) PR to teh 0.11.x branch includes a ListPickler.

You can (and should) do this in the meantime: https://github.com/scala/pickling/blob/wip/new-macro-implementation/core/src/main/scala/scala/pickling/pickler/Iterable.scala#L14-L15

jvican commented 8 years ago

+1

heathermiller commented 8 years ago

Still an issue, above link broken. Same file on 0.11.x: https://github.com/scala/pickling/blob/0.11.x/core/src/main/scala/scala/pickling/pickler/Iterable.scala

jvican commented 8 years ago

For the record, that references to 0.11.x which hasn't been released. If you've stumbled upon this issue, you'll need to release a new version locally with publishLocal and change the scala version you want to use in project/Util.scala.

heathermiller commented 8 years ago

We could also cut a release – @jsuereth WDYT? I'm happy to do it so long as it doesn't mess up any of your plans.

RPGambit2 commented 7 years ago

I switched to "org.scala-lang.modules" %% "scala-pickling" % "0.11.0-M2" because my code was crashing when trying to unpickle a List. Now I am getting hundreds of warnings:

Warning:(53, 55) method lookupPicklee in package internal is deprecated: Use currentRuntime.refRegistry.pickle.registerPicklee instead val elkKMUnpickled = eiKafkaMessage.bytes.unpickle[ControlTopicMessage] Warning:(53, 55) class Ref in package refs is deprecated: Sharing is not guaranteed to be safe w/ all possible picklers. val elkKMUnpickled = eiKafkaMessage.bytes.unpickle[ControlTopicMessage] Warning:(53, 55) value refPicklerUnpickler in trait RefPicklers is deprecated: Sharing is not guaranteed to be safe w/ all possible picklers. val elkKMUnpickled = eiKafkaMessage.bytes.unpickle[ControlTopicMessage] ......