Skip to content

Cannot deserialize Scala case class when JsonProperty annotation is used with var constructor parameter #781

@aimboden

Description

@aimboden

Hi all, we encountered the following regression while migrating our Scala 2.13.x projects to Jackson 3.

When deserializing JSON to Scala case classes with mutable var fields, Jackson now throws an IllegalStateException if a var is declared as a constructor parameter, but works correctly when declared in the class body.

So this is supported, for both serialization and de-serialization

    case class VarTestBody() {
        @JsonProperty("t") var test: Int = _
    }

But this fails

    case class VarTestConstructor(
        @JsonProperty("t") var test: Int
    )

with

java.lang.IllegalStateException: Conflicting/ambiguous property name definitions (implicit name 'test'): found multiple explicit names: [test, t], but also implicit accessor

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xSomething that likely has to be done in 3.x, not 2.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions