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

Annotations set in constructor parameter are also enabled when inherited. #658

Open
k163377 opened this issue Apr 2, 2023 · 1 comment

Comments

@k163377
Copy link
Contributor

k163377 commented Apr 2, 2023

Annotations given to someCrazyFieldName will not work for ChildClass if written as follows.

// from #151
open class SuperClass(@JsonProperty("annotationName") val someCrazyFieldName: String)
class ChildClass(s: String) : SuperClass(s)

The reason for this behavior is that the constructor of the superclass is not parsed by Jackson (note that in the sample, the annotation is given to the constructor arguments).

About Workaround

In such cases, the annotation should be given to the getter or field.

open class SuperClass(@get:JsonProperty("annotationName") val someCrazyFieldName: String)

/* or */

open class SuperClass(@field:JsonProperty("annotationName") val someCrazyFieldName: String)

About the planned implementation of this feature

There are many difficulties in implementing this feature, and it also causes performance degradation.
Therefore, we do not plan to implement this feature.

The details are summarized in this comment.

@cowtowncoder
Copy link
Member

True, jackson-databind does not support overriding of constructor annotations (as they generally make less sense than method ones which are supported), at least on Java side, and have complications (wrt different overloads).

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

2 participants