Skip to content

Auto-detect multi-argument constructor with implicit names if it is the only visible creator #725

@cowtowncoder

Description

@cowtowncoder

As part of continuing work to more seamlessly support addition of argument name information (by JDK8, paranamer, or other mechanism), it makes sense to allow auto-detect of creators even without @JsonCreator annotation if:

  1. All parameters have name (implicit or explicit), or are marked as injectable AND
  2. There are no other visible constructors AND
  3. There is no default (no-arg) constructor (which otherwise would be detected regardless of visibility)

In addition, there is one practical limitation due to existing resolution rules:

  • Single-argument constructor will default to "delegating" constructor, so implicit names are only used if @JsonCreator is used to indicate "property-based" constructor use, or explicit names.

Note, too, that language modules (like jackson-module-scala) may refine rules for more accurate detection of the "main" constructor; this functionality refers to vanilla handling for Java.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions