pickling icon indicating copy to clipboard operation
pickling copied to clipboard

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

Open elm- opened this issue 8 years ago • 6 comments

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.

elm- avatar Aug 08 '15 23:08 elm-

@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

jsuereth avatar Aug 08 '15 23:08 jsuereth

+1

jvican avatar Feb 26 '16 19:02 jvican

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

heathermiller avatar Mar 23 '16 13:03 heathermiller

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.

jvican avatar Mar 23 '16 14:03 jvican

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.

heathermiller avatar Mar 23 '16 14:03 heathermiller

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] ......

RPGambit2 avatar Feb 02 '17 19:02 RPGambit2