From 3ec1661e068064cfba9fae86b1b1bf45f5343bba Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 24 Mar 2024 21:57:06 +0900 Subject: [PATCH 1/2] Fixed to not process constructors of Java classes To avoid errors when referencing Record types defined in Java. Fixed #778. --- .../jackson/module/kotlin/ReflectionCache.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt index d73450ce..bdc80096 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt @@ -59,8 +59,15 @@ internal class ReflectionCache(reflectionCacheSize: Int) : Serializable { private val valueClassBoxConverterCache: LRUMap, ValueClassBoxConverter<*, *>> = LRUMap(0, reflectionCacheSize) - fun kotlinFromJava(key: Constructor<*>): KFunction<*>? = javaExecutableToKotlin.get(key) - ?: key.valueClassAwareKotlinFunction()?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it } + // If the Record type defined in Java is processed, + // an error will occur, so if it is not defined in Kotlin, skip the process. + // see https://github.com/FasterXML/jackson-module-kotlin/issues/778 + fun kotlinFromJava(key: Constructor<*>): KFunction<*>? = if (key.declaringClass.isKotlinClass()) { + javaExecutableToKotlin.get(key) + ?: key.valueClassAwareKotlinFunction()?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it } + } else { + null + } fun kotlinFromJava(key: Method): KFunction<*>? = javaExecutableToKotlin.get(key) ?: key.kotlinFunction?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it } From 895807237c5eebec9df71a6c8f44c8db001a95d8 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 24 Mar 2024 22:01:07 +0900 Subject: [PATCH 2/2] Update release notes wrt #779 --- release-notes/CREDITS-2.x | 1 + release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+) diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index c25c4fce..d51a68d1 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -19,6 +19,7 @@ Contributors: WrongWrong (@k163377) * #776: Delete Duration conversion that was no longer needed +* #779: Fixed to not process constructors of Java classes # 2.17.0 diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index f2fa135a..c6fb0961 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -19,6 +19,7 @@ Co-maintainers: 2.17.1 (not yet released) #776: Delete Duration conversion that was no longer needed. +#779: Errors no longer occur when processing Record types defined in Java. 2.17.0 (12-Mar-2024)