Skip to content

Commit

Permalink
Merge remote-tracking branch 'FasterXML/2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Mar 24, 2024
2 parents 20d998a + ce3e046 commit aa57bfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 9 additions & 2 deletions src/main/kotlin/tools/jackson/module/kotlin/ReflectionCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ internal class ReflectionCache(reflectionCacheSize: Int) : Serializable {
private val valueClassBoxConverterCache: SimpleLookupCache<KClass<*>, ValueClassBoxConverter<*, *>> =
SimpleLookupCache(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 }
Expand Down

0 comments on commit aa57bfe

Please sign in to comment.