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

add Scala3 equivalent of ScalaObjectMapper #503

Closed
pjfanning opened this issue Feb 23, 2021 · 11 comments
Closed

add Scala3 equivalent of ScalaObjectMapper #503

pjfanning opened this issue Feb 23, 2021 · 11 comments

Comments

@pjfanning
Copy link
Member

ScalaObjectMapper is a mixin for Jackson ObjectMapper that provides some helper functions that use Scala Manifests to implicitly access type information.

Scala Manifests are not supported for Scala3.

The options would appear to be.

@gaeljw
Copy link
Contributor

gaeljw commented Feb 27, 2021

I didn't look closely to the code yet but what do you use from Manifests ?

If you need to access type parameters of a generic type, this is exactly the use case I'm currently dealing with in a library (Cucumber Scala) and after looking at izumi I built a minimal library to cover the need: https://github.com/gaeljw/typetrees.

Maybe you can grab some ideas there 🤷 (Not saying you should use my library, I wouldn't be confident using it in such a big project as Jackson for now 😅 )

@pjfanning
Copy link
Member Author

@gaeljw the manifests are basically used here - https://github.com/FasterXML/jackson-module-scala/blob/2.12/src/main/scala/com/fasterxml/jackson/module/scala/ScalaObjectMapper.scala#L67

I see this as a convenience because in most cases, it's possible to use the Jackson ObjectMapper java methods directly and pass the type reference explicitly.

@gaeljw
Copy link
Contributor

gaeljw commented May 19, 2021

I've open a draft proposal without using macros at #518 but I may be missing some stuff that make this proposal inadequate.

@pjfanning
Copy link
Member Author

This code is merged but causes build problems with Scala 2.13 - see #522

@gaeljw
Copy link
Contributor

gaeljw commented Jun 23, 2021

That's weird. I'll give it a look event though I'm not sure I have useful knowledge to understand such behaviour.

@pjfanning
Copy link
Member Author

pjfanning commented Jun 23, 2021

@gaeljw in #522, I have added a comment with a link to a commit that disables the unit test that seems to cause the issue - a test with mapper.readValue[Map[String, Any]]

@pjfanning
Copy link
Member Author

jackson-module-scala 2.13.0-rc1 is released

@tnielens
Copy link

tnielens commented Sep 20, 2021

scala.reflect.Manifest[T] seems still supported by scala3, see https://dotty.epfl.ch/api/scala/reflect/Manifest.html . TypeTag not though. Wasn't Manifest[T] part of scala3 at the time of this issue creation? Could this library consider adding ScalaObjectMapper again?

@pjfanning
Copy link
Member Author

@tnielens try doing a PR of your own - ScalaObjectMapper has never compiled under Scala 3 for me - we have ClassTagExtensions as a like for like replacement for ScalaObjectMapper and that works with Scala 3 (see the jackson-scala-module 2.13.0-rc2 release)

@tnielens
Copy link

tnielens commented Sep 20, 2021

My bad, indeed two level of nesting seems to be unsupported List[GenericTestClass[Int]].

@gaeljw
Copy link
Contributor

gaeljw commented Sep 20, 2021

@tnielens the trait still exists but at compile time no value for the implicits instances will be provided by the compiler (or is it at runtime that there's an error? I don't remember exactly). But pretty sure that it doesn't work anymore and even if it works it's been deprecated since Scala 2.11, thus we should not rely on it.

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

3 participants