Skip to content

Commit b8153b6

Browse files
committed
Remove class to KClass cache
Because the conversion from Class to KClass is cached on the Kotlin side
1 parent 97cd0c8 commit b8153b6

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal class KotlinNamesAnnotationIntrospector(val module: KotlinModule, val c
6363
private fun hasCreatorAnnotation(member: AnnotatedConstructor): Boolean {
6464
// don't add a JsonCreator to any constructor if one is declared already
6565

66-
val kClass = cache.kotlinFromJava(member.declaringClass as Class<Any>)
66+
val kClass = member.declaringClass.kotlin
6767
.apply { if (this in ignoredClassesForImplyingJsonCreator) return false }
6868
val kConstructor = cache.kotlinFromJava(member.annotated as Constructor<Any>) ?: return false
6969

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

-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import com.fasterxml.jackson.databind.util.LRUMap
88
import java.lang.reflect.Constructor
99
import java.lang.reflect.Executable
1010
import java.lang.reflect.Method
11-
import kotlin.reflect.KClass
1211
import kotlin.reflect.KFunction
1312
import kotlin.reflect.jvm.kotlinFunction
1413

15-
1614
internal class ReflectionCache(reflectionCacheSize: Int) {
1715
sealed class BooleanTriState(val value: Boolean?) {
1816
class True : BooleanTriState(true)
@@ -34,16 +32,12 @@ internal class ReflectionCache(reflectionCacheSize: Int) {
3432
}
3533
}
3634

37-
private val javaClassToKotlin = LRUMap<Class<Any>, KClass<Any>>(reflectionCacheSize, reflectionCacheSize)
3835
private val javaConstructorToKotlin = LRUMap<Constructor<Any>, KFunction<Any>>(reflectionCacheSize, reflectionCacheSize)
3936
private val javaMethodToKotlin = LRUMap<Method, KFunction<*>>(reflectionCacheSize, reflectionCacheSize)
4037
private val javaExecutableToValueCreator = LRUMap<Executable, ValueCreator<*>>(reflectionCacheSize, reflectionCacheSize)
4138
private val javaConstructorIsCreatorAnnotated = LRUMap<AnnotatedConstructor, Boolean>(reflectionCacheSize, reflectionCacheSize)
4239
private val javaMemberIsRequired = LRUMap<AnnotatedMember, BooleanTriState?>(reflectionCacheSize, reflectionCacheSize)
4340

44-
fun kotlinFromJava(key: Class<Any>): KClass<Any> = javaClassToKotlin.get(key)
45-
?: key.kotlin.let { javaClassToKotlin.putIfAbsent(key, it) ?: it }
46-
4741
fun kotlinFromJava(key: Constructor<Any>): KFunction<Any>? = javaConstructorToKotlin.get(key)
4842
?: key.kotlinFunction?.let { javaConstructorToKotlin.putIfAbsent(key, it) ?: it }
4943

0 commit comments

Comments
 (0)