From d17465af4552a0f543ce39a22ac380597fb7df7c Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 13 Oct 2024 13:08:50 +0900 Subject: [PATCH 1/4] Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName Since #835 has not been released, the serialVersionUID has not been changed. --- .../fasterxml/jackson/module/kotlin/KotlinModule.kt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) 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 843c65ab..d396324d 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt @@ -43,18 +43,9 @@ class KotlinModule private constructor( val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault, val singletonSupport: Boolean = SingletonSupport.enabledByDefault, val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault, - @Deprecated( - level = DeprecationLevel.ERROR, - message = "There was a discrepancy between the property name and the Feature name." + - " To migrate to the correct property name, it will be ERROR in 2.18 and removed in 2.19.", - replaceWith = ReplaceWith("kotlinPropertyNameAsImplicitName") - ) - val useKotlinPropertyNameForGetter: Boolean = KotlinPropertyNameAsImplicitName.enabledByDefault, + val kotlinPropertyNameAsImplicitName: Boolean = KotlinPropertyNameAsImplicitName.enabledByDefault, val useJavaDurationConversion: Boolean = UseJavaDurationConversion.enabledByDefault, ) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) { - @Suppress("DEPRECATION_ERROR") - val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter - /* * Prior to 2.18, an older Enum called SingletonSupport was used to manage feature. * To deprecate it and replace it with singletonSupport: Boolean, the following steps are in progress. From 7d8412b5920f5a5b7b77b97b94f7f88df7fb18d3 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 13 Oct 2024 13:10:16 +0900 Subject: [PATCH 2/4] Unified property name In addition, optimize imports. --- .../module/kotlin/KotlinNamesAnnotationIntrospector.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 0eb1e8ac..6489ed03 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinNamesAnnotationIntrospector.kt @@ -1,12 +1,10 @@ package com.fasterxml.jackson.module.kotlin -import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.cfg.MapperConfig import com.fasterxml.jackson.databind.introspect.Annotated import com.fasterxml.jackson.databind.introspect.AnnotatedClass -import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor import com.fasterxml.jackson.databind.introspect.AnnotatedMember import com.fasterxml.jackson.databind.introspect.AnnotatedMethod import com.fasterxml.jackson.databind.introspect.AnnotatedParameter @@ -16,18 +14,15 @@ import java.lang.reflect.Constructor import java.util.Locale import kotlin.reflect.KClass import kotlin.reflect.KFunction -import kotlin.reflect.full.companionObject -import kotlin.reflect.full.declaredFunctions import kotlin.reflect.full.hasAnnotation import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor -import kotlin.reflect.jvm.javaConstructor import kotlin.reflect.jvm.javaGetter import kotlin.reflect.jvm.javaType internal class KotlinNamesAnnotationIntrospector( private val cache: ReflectionCache, - private val useKotlinPropertyNameForGetter: Boolean + private val kotlinPropertyNameAsImplicitName: Boolean ) : NopAnnotationIntrospector() { private fun getterNameFromJava(member: AnnotatedMethod): String? { val name = member.name @@ -67,7 +62,7 @@ internal class KotlinNamesAnnotationIntrospector( return when (member) { is AnnotatedMethod -> if (member.parameterCount == 0) { - if (useKotlinPropertyNameForGetter) { + if (kotlinPropertyNameAsImplicitName) { // Fall back to default if it is a getter-like function getterNameFromKotlin(member) ?: getterNameFromJava(member) } else getterNameFromJava(member) From 639d84bc0ea58cefdd964d9554549c2528120179 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 13 Oct 2024 13:12:26 +0900 Subject: [PATCH 3/4] Fix cmp --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 043ebdb8..4671fb04 100644 --- a/pom.xml +++ b/pom.xml @@ -239,6 +239,9 @@ + + com.fasterxml.jackson.module.kotlin.KotlinModule#getUseKotlinPropertyNameForGetter() + com.fasterxml.jackson.module.kotlin.KotlinModule#getSingletonSupport() com.fasterxml.jackson.module.kotlin.SingletonSupport From d47100ec2bd52fe1114ddc5c5a651347bf54d927 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 13 Oct 2024 13:16:18 +0900 Subject: [PATCH 4/4] Update release notes wrt #839 --- release-notes/CREDITS-2.x | 1 + release-notes/VERSION-2.x | 1 + 2 files changed, 2 insertions(+) diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index c378593f..18ad194b 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -18,6 +18,7 @@ Contributors: # 2.19.0 (not yet released) WrongWrong (@k163377) +* #839: Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName * #835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport # 2.18.0 (26-Sep-2024) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 1ae9cf7e..1df0b782 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -18,6 +18,7 @@ Co-maintainers: 2.19.0 (not yet released) +#839: Remove useKotlinPropertyNameForGetter and unify with kotlinPropertyNameAsImplicitName. #835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport. 2.18.0 (26-Sep-2024)