@@ -47,7 +47,7 @@ internal class ReflectionCache(reflectionCacheSize: Int) {
47
47
? : key.kotlin.let { javaClassToKotlin.putIfAbsent(key, it) ? : it }
48
48
49
49
fun kotlinFromJava (key : Constructor <Any >): KFunction <Any >? = javaConstructorToKotlin.get(key)
50
- ? : key.kotlinFunction ?.let { javaConstructorToKotlin.putIfAbsent(key, it) ? : it }
50
+ ? : key.getKotlinConstructor() ?.let { javaConstructorToKotlin.putIfAbsent(key, it) ? : it }
51
51
52
52
fun kotlinFromJava (key : Method ): KFunction <* >? = javaMethodToKotlin.get(key)
53
53
? : key.kotlinFunction?.let { javaMethodToKotlin.putIfAbsent(key, it) ? : it }
@@ -89,4 +89,25 @@ internal class ReflectionCache(reflectionCacheSize: Int) {
89
89
90
90
fun isKotlinGeneratedMethod (key : AnnotatedMethod , calc : (AnnotatedMethod ) -> Boolean ): Boolean = kotlinGeneratedMethod.get(key)
91
91
? : calc(key).let { kotlinGeneratedMethod.putIfAbsent(key, it) ? : it }
92
+
93
+ companion object {
94
+ private fun Constructor<Any>.getKotlinConstructor (): KFunction <Any >? {
95
+ kotlinFunction?.apply { return this }
96
+
97
+ // The javaConstructor that corresponds to the KFunction of the constructor that
98
+ // takes value class as an argument is a synthetic constructor.
99
+ // Therefore, in Kotlin 1.5.30, KFunction cannot be obtained from a constructor that is processed
100
+ // by jackson-module-kotlin.
101
+ // To deal with this situation, a synthetic constructor is obtained and a KFunction is obtained from it.
102
+ return try {
103
+ // The arguments of the synthetic constructor are the normal constructor arguments
104
+ // with the DefaultConstructorMarker appended to the end.
105
+ declaringClass
106
+ .getDeclaredConstructor(* parameterTypes, Constants .DEFAULT_CONSTRUCTOR_MARKER )
107
+ .kotlinFunction
108
+ } catch (t: Throwable ) {
109
+ null
110
+ }
111
+ }
112
+ }
92
113
}
0 commit comments