diff --git a/pom.xml b/pom.xml
index 348afb9bd..eae26f879 100644
--- a/pom.xml
+++ b/pom.xml
@@ -236,6 +236,7 @@
com.fasterxml.jackson.module.kotlin.SequenceSerializer
com.fasterxml.jackson.module.kotlin.KotlinModule#serialVersionUID
+ com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector
diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x
index 6f21d2b11..f7ea18e13 100644
--- a/release-notes/CREDITS-2.x
+++ b/release-notes/CREDITS-2.x
@@ -18,6 +18,7 @@ Contributors:
# 2.17.0 (not yet released)
WrongWrong (@k163377)
+* #747: Improved performance related to KotlinModule initialization and setupModule.
* #746: The KotlinModule#serialVersionUID is set to private.
* #745: Modified isKotlinClass determination method.
* #744: API deprecation update for KotlinModule.
diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x
index 0ea6041c8..0b77866e3 100644
--- a/release-notes/VERSION-2.x
+++ b/release-notes/VERSION-2.x
@@ -18,6 +18,8 @@ Co-maintainers:
2.17.0 (not yet released)
+#747: Improved performance related to KotlinModule initialization and setupModule.
+ With this change, the KotlinModule initialization error when using Kotlin 1.4 or lower has been eliminated.
#746: The KotlinModule#serialVersionUID is set to private.
#745: Modified isKotlinClass determination method.
#744: Functions that were already marked as deprecated,
diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt
index 8846b8079..a5e35c6a9 100644
--- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt
+++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt
@@ -1,6 +1,5 @@
package com.fasterxml.jackson.module.kotlin
-import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.MapperFeature
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullIsSameAsDefault
@@ -62,16 +61,6 @@ class KotlinModule @Deprecated(
private const val serialVersionUID = 2L
}
- init {
- if (!KotlinVersion.CURRENT.isAtLeast(1, 5)) {
- // Kotlin 1.4 was deprecated when this process was introduced(jackson-module-kotlin 2.15).
- throw JsonMappingException(
- null,
- "KotlinModule requires Kotlin version >= 1.5 - Found ${KotlinVersion.CURRENT}"
- )
- }
- }
-
@Deprecated(
level = DeprecationLevel.HIDDEN,
message = "If you have no choice but to initialize KotlinModule from reflection, use this constructor."
@@ -151,7 +140,6 @@ class KotlinModule @Deprecated(
))
context.appendAnnotationIntrospector(
KotlinNamesAnnotationIntrospector(
- this,
cache,
ignoredClassesForImplyingJsonCreator,
useKotlinPropertyNameForGetter)
@@ -162,15 +150,8 @@ class KotlinModule @Deprecated(
context.addSerializers(KotlinSerializers())
context.addKeySerializers(KotlinKeySerializers())
- fun addMixIn(clazz: Class<*>, mixin: Class<*>) {
- context.setMixInAnnotations(clazz, mixin)
- }
-
// ranges
- addMixIn(IntRange::class.java, ClosedRangeMixin::class.java)
- addMixIn(CharRange::class.java, ClosedRangeMixin::class.java)
- addMixIn(LongRange::class.java, ClosedRangeMixin::class.java)
- addMixIn(ClosedRange::class.java, ClosedRangeMixin::class.java)
+ context.setMixInAnnotations(ClosedRange::class.java, ClosedRangeMixin::class.java)
}
class Builder {
diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt
index d4af91b94..710e56a1a 100644
--- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt
+++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt
@@ -26,10 +26,9 @@ import kotlin.reflect.jvm.javaType
import kotlin.reflect.jvm.kotlinFunction
internal class KotlinNamesAnnotationIntrospector(
- val module: KotlinModule,
- val cache: ReflectionCache,
- val ignoredClassesForImplyingJsonCreator: Set>,
- val useKotlinPropertyNameForGetter: Boolean
+ private val cache: ReflectionCache,
+ private val ignoredClassesForImplyingJsonCreator: Set>,
+ private val useKotlinPropertyNameForGetter: Boolean
) : NopAnnotationIntrospector() {
private fun getterNameFromJava(member: AnnotatedMethod): String? {
val name = member.name