Skip to content

Commit

Permalink
Fixed to not process constructors of Java classes
Browse files Browse the repository at this point in the history
To avoid errors when referencing Record types defined in Java.
Fixed #778.
  • Loading branch information
k163377 committed Mar 24, 2024
1 parent 32730dc commit 3ec1661
Showing 1 changed file with 9 additions and 2 deletions.
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 3ec1661

Please sign in to comment.