pjfanning / jackson-scala3-reflection-extensions

Jackson scala3 support that uses gzoller/scala-reflection to get type info
Apache License 2.0
4 stars 1 forks source link

Scala 3.5.1 dotty.tools.tasty.UnpickleException: TASTy signature has wrong version. #6

Open steffenlaursen opened 3 days ago

steffenlaursen commented 3 days ago

Got this: Exception in thread "main" dotty.tools.tasty.UnpickleException: TASTy signature has wrong version. expected: {majorVersion: 28, minorVersion: 3} found : {majorVersion: 28, minorVersion: 5}

Attached code in zip and dumped it here.

SBT - build.sbt:

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "3.5.1"

lazy val root = (project in file("."))
  .settings(
    name := "XmlCodecExperiments",
    libraryDependencies += "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.2",
    libraryDependencies += "com.github.pjfanning" %% "jackson-scala3-reflection-extensions" % "2.16.0"
  )

Code - Main.scala:

object Main :

  @main def run() : Unit =

    import com.fasterxml
    import com.fasterxml.jackson.databind.ObjectMapper
    import com.fasterxml.jackson.databind.json.JsonMapper
    import com.fasterxml.jackson.module.scala.DefaultScalaModule
    import com.github.pjfanning.jackson.reflection.ScalaReflectionExtensions

    val mapperBuilder = JsonMapper.builder()
      .addModule(DefaultScalaModule)

    val mapper = mapperBuilder.build() :: ScalaReflectionExtensions

    // this should also work but Jackson is moving to supporting only creating mapper instances from a builder
    val mapper2 = new ObjectMapper with ScalaReflectionExtensions
    mapper2.registerModule(DefaultScalaModule)

    val holder = Holder("I am holder of data",Seq(Field("a"),Field("b")))

    val serialized = mapper.writeValueAsString(holder)
    println(serialized)

    val deserialized = mapper.readValue[Holder](serialized)
    println(deserialized)

case class Holder(name : String,fields : Seq[Field])

case class Field(name : String)

sample.zip

pjfanning commented 3 days ago

I've lost interest in this project. This software comes with no warranties and no free support.

All I can recommend is that this lib and its dependencies expose dependencies on Scala 3.3 libs. You probably need to override them to force them all to be Scala 3.5 - if that is the version that you insist on using - despite it not being an LTS release.

Try using sbt dependencyTree to work out the dependencies and their versions. Look in particular for scala3-tasty-inspector.

steffenlaursen commented 3 days ago

Ok, thanks for your fast response. I'm sort of a noob in all of this, so trying to make my way getting a simple XML case class serializer/deserializer (for JSON I use upickle)... This was sort of the simplest looking library. Didn't get further than to Json and deserilization... I'll see what I can do.

pjfanning commented 3 days ago

This library is not a simple library. Please use another one. This is based on all sorts of Reflection libs. How is any of what you attempting to do relate to the FAQ Entry linked on the https://github.com/pjfanning/jackson-scala3-reflection-extensions page?

I think you might be able to simply use the jackson-module-scala ClassTagExtensions instead of this lib's ScalaReflectionExtensions.