Search before asking

  • [x] I searched in the issues and found nothing similar.

Describe the bug

The new kotlin annotation defaulting rule described here: https://youtrack.jetbrains.com/issue/KT-73255 is introduced in kotlin 2.2.0 as opt-in (-Xannotation-default-target=param-property). Enabling it causes this test to fail with:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Problem with definition of [AnnotedClass com.trib3.json.InjectedValueBean]: Duplicate injectable value with id 'Key[type=com.trib3.json.SimpleBean, annotation=[none]]' (of type `com.google.inject.Key`)
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1]

Version Information

2.19.0

Reproduction

https://github.com/josephlbarnett/leakycauldron/blob/main/json/src/test/kotlin/com/trib3/json/ObjectMapperTest.kt#L171-L179 tries to read an InjectedValueBean from json with this bean definition:

private data class SimpleBean(
    val foo: String,
    val bar: Int,
    val maybe: String?,
    val date: LocalDate?,
    val ignoreMe: String? = null,
)

private data class InjectedValueBean(
    val foo: String,
    val bar: Int,
    @JacksonInject
    val injectedBeanDefault: SimpleBean,
    @JacksonInject(useInput = OptBoolean.TRUE)
    val injectedBeanTrue: SimpleBean,
    @JacksonInject(useInput = OptBoolean.FALSE)
    val injectedBeanFalse: SimpleBean,
)

Expected behavior

changing the @JacksonInjects to @param:JacksonInjects in the InjectedValueBean definition fixes the issue, but would be nice to not have to

Additional context

No response

Comment From: pjfanning

@josephlbarnett Could you move this to https://github.com/FasterXML/jackson-module-kotlin ? jackson-databind only tests Java use cases.

Comment From: josephlbarnett

https://github.com/FasterXML/jackson-module-kotlin/issues/1012