Open
Description
Search before asking
- I searched in the issues and found nothing similar.
- I have confirmed that the same problem is not reproduced if I exclude the KotlinModule.
- I searched in the issues of databind and other modules used and found nothing similar.
- I have confirmed that the problem does not reproduce in Java and only occurs when using Kotlin and KotlinModule.
Describe the bug
It appears that 2.18 introduced a change to the constructor detection, causing existing use cases to fail. I observed it in a case where a class extending a Map without an empty constructor can no longer be instantiated. See the test case example.
To Reproduce
With jackson 2.18.0 onboard:
@Test
fun test() {
assertThrows<MissingKotlinParameterException> {
jacksonObjectMapper().readValue<Old>("""{ "key":"value" }""")
}
assertDoesNotThrow {
jacksonObjectMapper().readValue<New>("""{ "key":"value" }""")
}
}
// what was working prior to 2.18
class Old : TreeMap<String, String> {
constructor(map: Map<String, String>) : super(map)
}
// what has to be changed to work with 2.18
class New : TreeMap<String, String> {
constructor() : super()
constructor(map: Map<String, String>) : super(map)
}
Expected behavior
Changes should be backward-compatible per the versioning standard (minor version changed).
Versions
Kotlin:
Jackson-module-kotlin: 2.18.0
Jackson-databind: 2.18.0
Additional context
I'm not 100% sure if this is a Kotlin module issue or not, as I operate in Kotlin codebase only and not invested enough to test it in plane java.
Generally, the fix to the issue is simple; the questionable part is that, if this is intentional, this is technically a breaking change in a minor version change.