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

BaseBeanDescriptorProvider is ignoring custom JsonCreator annotations. #137

Open
rlubke opened this issue Jun 8, 2018 · 4 comments
Open

Comments

@rlubke
Copy link

rlubke commented Jun 8, 2018

The method BaseBeanDescriptorProvider::CheckAndMerge(Type, List) looks for a constructor within the provided list to find the creator annotation. However, the check is using Genson's own creator annotation vs checking against those that may be known by other bundles.

@EugenCepoi
Copy link
Contributor

So basically your point is that this should be customizable so people could define new annotations that should be used instead of JsonCreator?

Could you describe a few practical use cases?

@rlubke
Copy link
Author

rlubke commented Jun 8, 2018

Consider the case where I have a bundle for Jackson so that Genson can leverage the Jackson equivalent of Genson's JsonProperty, JsonCreator, JsonIgnore.

This class has six constructors. A default no-arg, one annotated with Jackson's JsonCreator, and the rest are various public convenience constructors.

Stepping through BaseBeanDescriptorProvider::provideConstructorCreators, I can see that the Jackson annotation is properly resolved by the bundle.

Next when we merge the results, the BeanCreators are asked if they are annotated with Genson's JsonCreator. None of these methods are, so the BeanCreator that's used at runtime will invoked the no-arg constructor.

So if a bundle can resolve custom creators, it seems those should be used when determining the final creator.

@EugenCepoi
Copy link
Contributor

Why would someone want to use Jacksons annotations in Genson? :)

From what you describe I have the impression that it's mostly aliasing that you want, which on it's own has limited use. What if the annotation has extra properties, what should Genson do with them? To me it means that actually you would want to plug in Gensons code in order to provide support for your custom annotations.

Do you have more use cases?

@rlubke
Copy link
Author

rlubke commented Jun 8, 2018

It could be JSON-B or some other set of annotations. Our intent is to allow basic (yes, attributes variance is an issue) support of these common annotations with the Genson runtime so that consumers of our project can still use their Jackson or JSON-B based classes.

Also as we migrate from Jackson to Genson, we can limit the scope of changes by not having to remove any Jackson annotations we have in our code base.

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

No branches or pull requests

2 participants