-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
JsonScalaEnumeration annotation not picked up when using a Mixin #399
Comments
@cowtowncoder I've confirmed that this is still an issue. Mixins do work for scala classes. Is it possible that this issue could be because https://github.com/FasterXML/jackson-docs/wiki/JacksonMixInAnnotations#usage-notes seems to say that only the core jackson annotations and jaxb annotations are supported |
Hmmh. I don't think this is true (i.e. I think all annotations are actually merged), but adding I suspect this could be more due to member declaration of mix-in not matching that of target for some reason (Scala compiler might add some decorations perhaps?). |
I had another look and the scala annotation is being picked up. The issue happens in com.fasterxml.jackson.module.scala.deser.EnumerationDeserializer. It seems that in mixin case that the parser events are not appearing as expected. EnumerationDeserializer works ok normally. In the mixin case, EnumerationDeserializer gets the VALUE_STRING token when it is expecting a START_OBJECT token. |
That is odd as Enums typically would be JSON Strings (or perhaps integers)? Assuming Scala |
The bean-property is based on the target class and not on the mixin class. This leads to the code in L13 returning |
I suspect the issue is in https://github.com/FasterXML/jackson-module-scala/blob/master/src/main/scala/com/fasterxml/jackson/module/scala/introspect/ScalaAnnotationIntrospectorModule.scala#L59 - I have a test case and the JsonScalaEnumeration annotation makes it to this point but the code seems to go back to the raw class at this point (instead of using the AnnotatedMember) |
Uh. That code is... all kinds of wrong, if I understand it correctly. For some odd reason it starts with accessor, but instead of using it like it should, then goes and introspects declaring class (which is not necessarily class we are introspecting; may be super-class/-interface) and does something from there. I wish I knew what is the point there... I assume there may have been a reason at some point, but there are code comments to help. |
I got the mixin tests to pass (https://github.com/FasterXML/jackson-module-scala/blob/master/src/test/scala/com/fasterxml/jackson/module/scala/experimental/EnumMixinTest.scala) - hopefully this fix should be in 2.10.0 release. |
Excellent! We still have time until 2.10.0 closes -- my best estimate is that it'd be weekend after next (Sep 21, 2019) at earliest, and I will try to communicate this over |
@pjfanning One related thing: it would be great to have release-notes for Scala module, too. I know there is In addition, there are global release notes, and for 2.10: https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.10 and I can fill that from per-repo one if necessary. But it is probably best if module author(s) can update that wiki: it should be as simple as just copy-paste comments from repo release notes; which in turn should usually be copying Github issue title next to issue id. The main benefit of combined release notes is, I think, that
|
@cowtowncoder I merged some notes into https://github.com/FasterXML/jackson-module-scala/blob/master/release-notes/VERSION.md - I'll see if I can cobble together some of the missing release notes over time |
Excellent, thank you! |
I'm using version 2.9.8 and found that the JsonScalaEnumeration annotation does not get picked up when using a Mixin. Here is code that demonstrates the behavior.
OUTPUT
The text was updated successfully, but these errors were encountered: