Skip to content

Commit

Permalink
Merge pull request #779 from k163377/fix-778
Browse files Browse the repository at this point in the history
Fixed to not process constructors of Java classes
  • Loading branch information
k163377 authored Mar 24, 2024
2 parents 32730dc + 8958072 commit ce3e046
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
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: LRUMap<KClass<*>, 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 }
Expand Down

0 comments on commit ce3e046

Please sign in to comment.