Skip to content

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

@k163377

Description

@k163377

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions