Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Scala 3 #479

Closed
DieBauer opened this issue Nov 20, 2020 · 36 comments
Closed

Support Scala 3 #479

DieBauer opened this issue Nov 20, 2020 · 36 comments

Comments

@DieBauer
Copy link

Now that Scala 3 is in Milestone releases (https://dotty.epfl.ch/blog/2020/11/09/scala3-m1.html) it would be great if we can support Scala 3.

I tried to make it work with the dottyCompat mode in the sbt-dotty plugin (https://scalacenter.github.io/scala-3-migration-guide/docs/tutorials/sbt-migration.html) but then things start to break :)

The following snippet works on Scala 2.x, but fails with Scala 3.0.0-M1.

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.scala.DefaultScalaModule

case class T(x: String)

val mapper = new ObjectMapper()
mapper.registerModule(DefaultScalaModule)
val result: T = mapper.readValue("""{"x": "Hello"}""", classOf[T])

fails with:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `T` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (String)"{"x": "Hello"}"; line: 1, column: 2]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
	at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1455)
	at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1081)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1332)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:331)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3468)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3436)
	at Json$.run(main.scala:12)
	at run.main(main.scala:4)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.Run.invokeMain(Run.scala:115)
	at sbt.Run.execute$1(Run.scala:79)
	at sbt.Run.$anonfun$runWithLoader$4(Run.scala:92)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
	at sbt.TrapExit$App.run(TrapExit.scala:257)
	at java.lang.Thread.run(Thread.java:748)

This is the scastie to play with: https://scastie.scala-lang.org/2dYNr8u9TciEOU9rOCQJPQ

@pjfanning
Copy link
Member

I created https://github.com/FasterXML/jackson-module-scala/tree/dotty but there are some remaining compile problems to solve

@DieBauer
Copy link
Author

DieBauer commented Nov 22, 2020

I'll have a look at that branch.

For now the above error is thrown, I think, because of the way Jackson determines if a class is a Scala class (https://github.com/FasterXML/jackson-module-scala/blob/master/src/main/scala/com/fasterxml/jackson/module/scala/util/Classes.scala#L10-L11) and this check always evaluates to false, since scala-reflect is not available when compiling with Scala 3.
Long-story short, the propertycreator will be null because of that.

@pjfanning
Copy link
Member

@DieBauer if you could find an alternative way to differentiate a Scala class from a plain Java class, we can support that too. We do need to avoid having jackson-module-scala try to work with non-Scala classes because it leads to unexpected behaviours when users have Scala and plain Java classes in their projects.

@pjfanning
Copy link
Member

@DieBauer which version if jackson-module-scala did you test with? v2.12.0 increases the reliance on the check for the ScalaSignature annotations that you highlighted.

@DieBauer
Copy link
Author

@pjfanning I checked that with 2.11.3, but same issue occurs on 2.12.0-rc2. https://scastie.scala-lang.org/UOWvdJ7xQkS64MV94WuJEQ

Relying on the ScalaSignature runtime annotation will just not work with Scala 3, since there is no scala-reflect. I haven't heard of a viable alternative in the dotty gitter channel yet..

What kind of unexpected behaviours with non-scala classes are you talking about, if it turns out the runtime check cannot be done on scala 3?
What could be a way forward :)

@cowtowncoder
Copy link
Member

I may not have enough context here, but it might be easy enough to make "Plain Scala Object or not" detection pluggable, provide dynamically loaded default but allow override (or more specifically I suppose it should be provider for that detector).

The reason there needs to be detection is that logic for figuring out construction of Plain Old Scala Objects is bit more advanced than that for POJOs -- more ways to construct things in Java, can not rely on certain things that Scala (and some other JVM langs like Kotlin) guarantee.
Similarly Scala matches fields and accessors more tightly (although Jackson does not yet have optimal support for these variations).

@pjfanning
Copy link
Member

I started a topic at https://users.scala-lang.org/t/recognising-scala-3-classes/6922

@DieBauer would you have any pointers to specific comments of the Dotty gitter channel relating to this? Otherwise, I might being the topic above to the gitter channel to see if I can see if the Dotty team would be amenable to adding a new annotation or a marker trait/interface.

@DieBauer
Copy link
Author

This is the question I asked https://gitter.im/lampepfl/dotty?at=5fbf67a566dcfa77e2a3cb08, only 1 person responded though.

Indeed as mentioned in the topic, the classfile contains scala references. But that doesn't help you at runtime :)

@pjfanning
Copy link
Member

The dotty branch has a number of compile issues associated with higher-kinds - affects 3 classes, in the main.

I might have time over the Christmas period to look at trying to support dotty compiled classes in the 2.13 build. I think this is a more useful starting point than supporting a scala 3 build.

[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericFactoryDeserializerResolver.scala:21:26 
[error] 21 |  val CLASS_DOMAIN: Class[Collection[_]]
[error]    |                          ^^^^^^^^^^^^^
[error]    |unreducible application of higher-kinded type [A] =>> CC[A] to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericFactoryDeserializerResolver.scala:52:30 
[error] 52 |    def setInitialValue(init: Collection[_]): Unit = init.asInstanceOf[Iterable[A]].foreach(add)
[error]    |                              ^^^^^^^^^^^^^
[error]    |unreducible application of higher-kinded type [A] =>> CC[A] to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericFactoryDeserializerResolver.scala:65:38 
[error] 65 |    extends ContainerDeserializerBase[CC[_]](collectionType)
[error]    |                                      ^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericFactoryDeserializerResolver.scala:81:76 
[error] 81 |    override def deserialize(jp: JsonParser, ctxt: DeserializationContext): CC[_] = {
[error]    |                                                                            ^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericFactoryDeserializerResolver.scala:87:86 
[error] 87 |    override def deserialize(jp: JsonParser, ctxt: DeserializationContext, intoValue: CC[_]): CC[_] = {
[error]    |                                                                                      ^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericFactoryDeserializerResolver.scala:87:94 
[error] 87 |    override def deserialize(jp: JsonParser, ctxt: DeserializationContext, intoValue: CC[_]): CC[_] = {
[error]    |                                                                                              ^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericMapFactoryDeserializerResolver.scala:19:26 
[error] 19 |  val CLASS_DOMAIN: Class[Collection[_, _]]
[error]    |                          ^^^^^^^^^^^^^^^^
[error]    |unreducible application of higher-kinded type [K, V] =>> CC[K, V] to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericMapFactoryDeserializerResolver.scala:53:30 
[error] 53 |    def setInitialValue(init: Collection[_, _]): Unit = {
[error]    |                              ^^^^^^^^^^^^^^^^
[error]    |unreducible application of higher-kinded type [K, V] =>> CC[K, V] to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericMapFactoryDeserializerResolver.scala:67:38 
[error] 67 |    extends ContainerDeserializerBase[CC[_, _]](mapType) with ContextualDeserializer {
[error]    |                                      ^^^^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericMapFactoryDeserializerResolver.scala:82:76 
[error] 82 |    override def deserialize(jp: JsonParser, ctxt: DeserializationContext): CC[_, _] = {
[error]    |                                                                            ^^^^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericMapFactoryDeserializerResolver.scala:88:86 
[error] 88 |    override def deserialize(jp: JsonParser, ctxt: DeserializationContext, intoValue: CC[_, _]): CC[_, _] = {
[error]    |                                                                                      ^^^^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/GenericMapFactoryDeserializerResolver.scala:88:97 
[error] 88 |    override def deserialize(jp: JsonParser, ctxt: DeserializationContext, intoValue: CC[_, _]): CC[_, _] = {
[error]    |                                                                                                 ^^^^^^^^
[error]    |  unreducible application of higher-kinded type CC to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/util/FactorySorter.scala:11:64 
[error] 11 |class FactorySorter[CM[_], CF[+X[_]]] extends TopologicalSorter[CM[_], CF[CM]] {
[error]    |                                                                ^^^^^
[error]    |  unreducible application of higher-kinded type CM to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/util/FactorySorter.scala:12:42 
[error] 12 |  type HKClassManifest[CC2[_]] = ClassTag[CC2[_]]
[error]    |                                          ^^^^^^
[error]    | unreducible application of higher-kinded type CC2 to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/util/FactorySorter.scala:20:73 
[error] 20 |class MapFactorySorter[CM[_, _], CF[+X[_, _]]] extends TopologicalSorter[CM[_, _], CF[CM]] {
[error]    |                                                                         ^^^^^^^^
[error]    |  unreducible application of higher-kinded type CM to wildcard arguments
[error] -- [E043] Type Error: /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/util/FactorySorter.scala:21:45 
[error] 21 |  type HKClassManifest[CC2[_, _]] = ClassTag[CC2[_, _]]
[error]    |                                             ^^^^^^^^^
[error]    | unreducible application of higher-kinded type CC2 to wildcard arguments
[error] 16 errors found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 11 s, completed 5 Dec 2020, 23:49:47

@pjfanning
Copy link
Member

@DieBauer I created a test that shows that jackson-module-scala can handle a scala 3.0.0-M1 case class. See https://github.com/FasterXML/jackson-module-scala/tree/dotty-test -- the equivalent case object test would not compile though -- seems like the TastyReader doesn't support case objects in the way I expected.

@SethTisue
Copy link
Contributor

seems like the TastyReader doesn't support case objects in the way I expected

summon[@bishabosha]

@bishabosha
Copy link

@DieBauer I created a test that shows that jackson-module-scala can handle a scala 3.0.0-M1 case class. See https://github.com/FasterXML/jackson-module-scala/tree/dotty-test -- the equivalent case object test would not compile though -- seems like the TastyReader doesn't support case objects in the way I expected.

It seems the problem here is that Scala3CaseObject is a class not a case object, so it can't be used as a value.
https://github.com/pjfanning/scala3-sample-classes/blob/d499620aeefc87d42e7f7956b8973af8975e0770/src/main/scala/com/github/pjfanning/scala3/Scala3CaseObject.scala#L3

I get the same error if I paste the following in scala 2 repl:

scala> :paste
// Entering paste mode (ctrl-D to finish)

package com.github.pjfanning.scala3

class Scala3CaseObject {
  val field1: String = "test"
  val field2: Int = 42
}



// Exiting paste mode, now interpreting.


scala> val x = com.github.pjfanning.scala3.Scala3CaseObject
                                           ^
       error: object Scala3CaseObject is not a member of package com.github.pjfanning.scala3
       note: class Scala3CaseObject exists, but it has no companion object.

@pjfanning
Copy link
Member

@bishabosha thanks for checking that - I have now fixed the Scala3CaseObject

@pjfanning
Copy link
Member

The 'dotty' branch now compiles (with a few test cases removed - ones related to ScalaObjectMapper which will not work in Scala3 - due to Manifest support being removed along with other scala-reflect features).

Many tests fail due to scala/scala3#6349

@changvvb
Copy link

@pjfanning scala/scala3#6349 is fixed by scala/scala3#10936. Maybe it could be unblocked.

@nbauernfeind
Copy link
Member

Are these changes totally dropping Scala 2 support? Poking around at the work being done here strongly suggests that this will ruin the experience for [some] scala 2 users.

If the main branch is now going to be scala 3 only - then the changes make more sense to me, but you may want to drop all of the awkwardness around trying to support 2.11 / 2.12 / 2.13 and update the readme to be a bit more clear on your current vision for the project.

@pjfanning
Copy link
Member

@nbauernfeind no plan to drop scala 2 support - the dotty branch is purely for experimentation with scala 3

If we decide to try to support Scala 2 and 3 in same jackson-module-scala

  • there are already plenty of changes in jackson-module-scala 2.12 and master branches that make it easier to compile with scala 3
  • we'll probably remove ScalaObjectMapper which won't work with Scala 3 and is just a convenience anyway - I have deprecated ScalaObjectMapper and will remove the deprecation if we choose to keep it for Scala 2 users
  • there will be a scala 3 specific unmanaged source folder
  • plenty of tests that are broken in dotty branch will need investigation

@pjfanning pjfanning removed the blocked label Jan 7, 2021
@cowtowncoder
Copy link
Member

I don't know too much about Scala 2/3, but one thing that may be useful is this: strong +1 for deprecating sub-classing of ObjectMapper (assuming ScalaObjectMapper extends ObjectMapper) -- Jackson 3.x is moving towards sub-classing of ObjectMapper being required for different formats, which in turn makes it impractical to extend it for other purposes.
(why sub-classing? To support pluggability of underlying TokenStreamFactory, as well as format-specific configuration beyond simple on/off features).

So that makes sense, regardless of other reasons.

@nbauernfeind
Copy link
Member

nbauernfeind commented Jan 8, 2021

Thanks for the update. I am mostly just curious. (Also sad to see some of my favorite contributions disappear 😿.)

The ScalaObjectMapper is/was a mixin that can be "attached" to any subclass of ObjectMapper as long as it is mixed in at the mapper's construction time. I'm not familiar with the changes in Scala3 (my focus has been elsewhere for far too long), but I am surprised to read that there is no TypeTag equivalent! The Manifest/TypeTag concepts have absolutely been one of my favorite features of Scala -- and I'm sad to see it disappear! It was extremely powerful for improving readability of boiler-plate-like code. </reminiscing>

@cowtowncoder
Copy link
Member

Ok, in that case change to sub-classing should be irrelevant.

@pjfanning
Copy link
Member

Upgrading dotty branch to scala 3.0.0-RC1 fixed some tests - still over 100 broken - scala/scala3#11486 is the cause of some of these test failures

@pjfanning
Copy link
Member

going back to using paranamer when scala3 is in use helps me work around scala/scala3#11486 so that leaves a little over 30 broken tests

@cowtowncoder
Copy link
Member

@pjfanning Interesting -- can Paranamer do something more than what JDK provides via bytecode? (Jackson-databind 3.0 has embedded code from jackson-module-parameter-names)

@pjfanning
Copy link
Member

@cowtowncoder scala compiler generates java classes and with scala 2.12 and 2.13, there is enough detail in the generated classes to avoid paranamer. Scala 2.11 and before did not have enough detail and require paranamer. Looks like Scala 3.0.0-RC1 needs paranamer again. Jackson-Module-Scala has explicit dependencies on paranamer (if the scala version needs it).

@cowtowncoder
Copy link
Member

@pjfanning ok, thanks.

@SethTisue
Copy link
Contributor

Looks like Scala 3.0.0-RC1 needs paranamer again

Seems like a regression... is there a ticket?

@pjfanning
Copy link
Member

@SethTisue I raised scala/scala3#11486

@pjfanning
Copy link
Member

Latest situation is that most features of jackson-module-scala work with Scala 3.0.0-RC1. There is a snapshot release available for jackson-module-scala v2.13.0-SNAPSHOT (the code used to release this is in the dotty branch).

scalaVersion := "3.0.0-RC1"

resolvers += Resolver.sonatypeRepo("snapshots")

"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.13.0-SNAPSHOT"

https://oss.sonatype.org/content/repositories/snapshots/com/fasterxml/jackson/module/jackson-module-scala_3.0.0-RC1/2.13.0-SNAPSHOT/

@pjfanning
Copy link
Member

pjfanning commented Mar 28, 2021

The issues with the Scala 3 support

  • ScalaObjectMapper mix-in is not supported at all (because it relies on Scala-Reflect Manifests and these are not supported in Scala 3)
  • Value Classes -- the tests for many of these are failing
  • Lazy vals are not properly supported yet
  • A number of tests that relate to applying Jackson annotations to classes are not yet working with Scala 3 build

https://travis-ci.com/github/FasterXML/jackson-module-scala/builds/221433492 will give you an idea of the tests that are still failing

@pjfanning
Copy link
Member

jackson-module-scala 2.13.0-SNAPSHOT is now available for Scala 3.0.0-RC2

https://oss.sonatype.org/content/repositories/snapshots/com/fasterxml/jackson/module/jackson-module-scala_3.0.0-RC2/2.13.0-SNAPSHOT/

@felixbr
Copy link

felixbr commented May 29, 2021

Any chance to get this released for Scala 3.0.0? I'm currently trying to port twitter/util to Scala 3 and it's used there. 🙂

edit: It's not super urgent, so please don't feel pressured or anything. There are lots of other blockers as well 😅

@pjfanning
Copy link
Member

v2.13.0-SNAPSHOT is available for scala 3.0.0

@GavinRay97
Copy link

GavinRay97 commented Jul 9, 2021

v2.13.0-SNAPSHOT is available for scala 3.0.0

Thank you and all the other contributors for your hard work on this fantastic library!! It is much, much appreciated.

@pjfanning One question I have -- what's the functional difference between the 3.0 lib and the current one?
I've been using this:

<!-- JSON Serialization Dependencies -->
<dependency>
    <groupId>com.github.pjfanning</groupId>
    <artifactId>jackson-module-scala3-enum_3</artifactId>
    <version>2.12.3</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.module</groupId>
    <artifactId>jackson-module-scala_2.13</artifactId>
    <version>2.12.3</version>
</dependency>

And with stuff like this, mind-blowingly it "just works". I noticed some notes about how the 3.0 version has some problems/shortcomings -- would it be better just to continue using the 2.0 with Scala 3?

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.github.pjfanning.`enum`.EnumModule
import io.quarkus.jackson.ObjectMapperCustomizer

import javax.inject.Singleton

// https://quarkus.io/guides/rest-json#jackson
@Singleton
class Scala3ObjectMapperCustomizer extends ObjectMapperCustomizer:
  def customize(mapper: ObjectMapper): Unit =
    // General Scala support
    // https://github.com/FasterXML/jackson-module-scala
    mapper.registerModule(DefaultScalaModule)
    // Suport for Scala 3 Enums
    // https://github.com/pjfanning/jackson-module-scala3-enum
    mapper.registerModule(EnumModule)
import com.fasterxml.jackson.databind.ObjectMapper
import io.quarkus.test.junit.QuarkusTest
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.{DisplayName, Test}
import javax.inject.Inject
import scala.collection.JavaConverters.*

enum AnEnum:
  case A extends AnEnum
  case B extends AnEnum
case class Other(foo: String)
case class Something(name: String, someEnum: AnEnum, other: Other)

@QuarkusTest
class Scala3ObjectMapperCustomizerTest:

  @Inject
  var objectMapper: ObjectMapper = null

  @Test
  def `Quarkus CDI Jackson ObjectMapper has Scala 3 modules registered`: Unit =
  	val moduleIds = objectMapper.getRegisteredModuleIds.asScala
    val expectedModules =
      List("com.fasterxml.jackson.module.scala.DefaultScalaModule", "com.github.pjfanning.enum.EnumModule$1")
    expectedModules.foreach(it => {
      assertTrue(moduleIds.contains(it), f"Expected ObjectMapper registered Module Ids to contain '$it'")
    })

   @Test
   def `Jackson ObjectMapper can parse Scala 3 members`:
     val sampleSomethingJSON: String = """
  	 {
    	"name": "My Something",
    	"someEnum": "A",
    	"other": {
      		"foo": "bar"
     	} 
  	 }
  	 """
  	 val parsed = objectMapper.readValue[Something](sampleSomethingJSON, classOf[Something])
     assertEquals(parsed.name, "My Something")
     assertEquals(parsed.someEnum, AnEnum.A)
     assertEquals(parsed.other.foo, "bar")

@pjfanning
Copy link
Member

@GavinRay97 thanks for interest in this library.

https://github.com/FasterXML/jackson-module-scala#scala-3 is the current status of Scala3 support. So far, the support is experimental and it is only by doing lots of testing in various scenarios that we will become more confident about whether jackson-module-scala works well with Scala3. If people run into issues and report them, we can look at seeing if they can be fixed.

jackson-module-scala uses Java reflection to try to work out how to work out the structure of Scala types. Other Scala libs for JSON support use alternative approaches that probably mean you get better results when you have just to worry about Scala classes. jackson-module-scala is aimed more at use cases where you also have to worry about Java classes.

@GavinRay97
Copy link

GavinRay97 commented Jul 9, 2021

Well for whatever it's worth, jackson-module-scala_2.13 with your jackson-module-scala3-enum_3 for Scala 3 works easier than even Circe or similar alternatives from my experimentation :)

With this setup, I don't have to define manual decoders/encoder givens, or tell it how to decode enums -- it "just works" (using readValue[T]) even for Scala 3 enums and without configuring any kind of implicits.

👏

@pjfanning pjfanning added the 2.13 label Jul 14, 2021
@pjfanning
Copy link
Member

jackson-module-scala 2.13.0-rc1 is released

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

No branches or pull requests

9 participants