com-lihaoyi / upickle

uPickle: a simple, fast, dependency-free JSON & Binary (MessagePack) serialization library for Scala
https://com-lihaoyi.github.io/upickle
MIT License
707 stars 158 forks source link

Error "java.lang.AbstractMethodError: Receiver class .. does not define or inherit an implementation of the resolved method 'abstract void upickle$implicits$Readers$_setter_$JavaBooleanReader_$eq(upickle.core.Types$Reader)" #482

Closed programmatix closed 1 year ago

programmatix commented 1 year ago

I'm using your (excellent, btw) library from inside the Couchbase Scala SDK library for JSON duties. And I'm hitting an obscure runtime error that's not meaning much to me:

java.lang.AbstractMethodError: Receiver class com.couchbase.client.scala.util.CouchbasePickler$ does not define or inherit an implementation of the resolved method 'abstract void upickle$implicits$Readers$_setter_$JavaBooleanReader_$eq(upickle.core.Types$Reader)' of interface upickle.implicits.Readers.
    at upickle.implicits.Readers.$init$(Readers.scala:370)
    at com.couchbase.client.scala.util.CouchbasePickler$.<clinit>(CouchbasePickler.scala:22)
    at com.couchbase.client.scala.manager.bucket.CreateBucketSettings$.<clinit>(BucketSettings.scala:280)
    at com.couchbase.situational.SituationalRunner$.createBucket(SituationalRunner.scala:341)

The line that's throwing the runtime error:

val settings = CreateBucketSettings(rp.bucketName, 1000)

Some of the other relevant code:

// Contents omitted as probably not relevant?
case class CreateBucketSettings(...)

object CreateBucketSettings {
  implicit val rw: CouchbasePickler.ReadWriter[CreateBucketSettings] = CouchbasePickler.macroRW
  implicit val rwd: CouchbasePickler.ReadWriter[Durability] = BucketSettings.rw
}

object CouchbasePickler extends upickle.AttributeTagged {
  // upickle writes Options as [] and ["value"] by default
  override implicit def OptionWriter[T: Writer]: Writer[Option[T]] =
    implicitly[Writer[T]].comap[Option[T]] {
      case None    => null.asInstanceOf[T]
      case Some(x) => x
    }

  override implicit def OptionReader[T: Reader]: Reader[Option[T]] =
    implicitly[Reader[T]].mapNulls {
      case null => None
      case x    => Some(x)
    }
}

The odd thing is, I have other Scala Junit tests that create and use CreateBucketSettings without issues. I'm only hitting problems now I'm trying to use it from another project. This project mixes Scala and Java, which might be relevant going from the JavaBooleanReader in the error.

I'm not sure what the error is trying to tell me. Are there any clues you could provide to point me in the right direction?

Uisng upickle 1.6.0. Which I appreciate is a year old now and I should upgrade - I'll give that a try, in fact.

lihaoyi commented 1 year ago

Seems like a version conflict between your libraries. Going to close this for now since it's unlikely to be a code issue, but feel free to post your dependency tree (including evictions) and maybe I can see where the conflict is