Skip to content

Commit ce3e046

Browse files
authored
Merge pull request #779 from k163377/fix-778
Fixed to not process constructors of Java classes
2 parents 32730dc + 8958072 commit ce3e046

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

release-notes/CREDITS-2.x

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Contributors:
1919

2020
WrongWrong (@k163377)
2121
* #776: Delete Duration conversion that was no longer needed
22+
* #779: Fixed to not process constructors of Java classes
2223

2324
# 2.17.0
2425

release-notes/VERSION-2.x

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Co-maintainers:
1919
2.17.1 (not yet released)
2020

2121
#776: Delete Duration conversion that was no longer needed.
22+
#779: Errors no longer occur when processing Record types defined in Java.
2223

2324
2.17.0 (12-Mar-2024)
2425

src/main/kotlin/com/fasterxml/jackson/module/kotlin/ReflectionCache.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,15 @@ internal class ReflectionCache(reflectionCacheSize: Int) : Serializable {
5959
private val valueClassBoxConverterCache: LRUMap<KClass<*>, ValueClassBoxConverter<*, *>> =
6060
LRUMap(0, reflectionCacheSize)
6161

62-
fun kotlinFromJava(key: Constructor<*>): KFunction<*>? = javaExecutableToKotlin.get(key)
63-
?: key.valueClassAwareKotlinFunction()?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it }
62+
// If the Record type defined in Java is processed,
63+
// an error will occur, so if it is not defined in Kotlin, skip the process.
64+
// see https://github.com/FasterXML/jackson-module-kotlin/issues/778
65+
fun kotlinFromJava(key: Constructor<*>): KFunction<*>? = if (key.declaringClass.isKotlinClass()) {
66+
javaExecutableToKotlin.get(key)
67+
?: key.valueClassAwareKotlinFunction()?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it }
68+
} else {
69+
null
70+
}
6471

6572
fun kotlinFromJava(key: Method): KFunction<*>? = javaExecutableToKotlin.get(key)
6673
?: key.kotlinFunction?.let { javaExecutableToKotlin.putIfAbsent(key, it) ?: it }

0 commit comments

Comments
 (0)