Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Pickling fails with a weird issue #455

Open
opensorceror opened this issue Sep 1, 2018 · 0 comments
Open

Pickling fails with a weird issue #455

opensorceror opened this issue Sep 1, 2018 · 0 comments

Comments

@opensorceror
Copy link

opensorceror commented Sep 1, 2018

I'm trying to serialize an object to JSON using scala-pickling 0.10.1 and Scala 2.11, but am having a very strange issue. I've replicated a minimal example below:

import org.apache.hadoop.io.compress.CompressionCodecFactory
import scala.pickling.Defaults._
import scala.pickling.json._
    
trait foo {
  var compressionCodecFactory1: CompressionCodecFactory = _
  val compressionCodecFactory2: CompressionCodecFactory = null
}
    
class blah extends foo
 
object FooFoo {
  def main(args: Array[String]) = {
        
  val k = new blah
  val pkl = k.pickle // compilation fails with error "Cannot generate a pickler for blah"
  }
}

However, if I remove or comment out var compressionCodecFactory1: CompressionCodecFactory = _ within the trait foo, it compiles and pickles perfectly. I've also tried adding the @transient notation to this var, but it fails with the same error.

Why could this possibly be happening?

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

No branches or pull requests

1 participant