diff --git a/pom.xml b/pom.xml
index ba0558421..043ebdb84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -224,7 +224,7 @@
-->
- 2.17.0
+ 2.18.0
jar
@@ -239,43 +239,9 @@
-
- com.fasterxml.jackson.module.kotlin.KotlinModule#KotlinModule(int,boolean,boolean,boolean,com.fasterxml.jackson.module.kotlin.SingletonSupport,boolean,boolean,boolean)
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullIsSameAsDefault()
-
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullIsSameAsDefault(boolean)
-
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullToEmptyCollection()
-
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullToEmptyCollection(boolean)
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getNullToEmptyMap()
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#nullToEmptyMap(boolean)
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getSingletonSupport()
-
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#singletonSupport(com.fasterxml.jackson.module.kotlin.SingletonSupport)
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#getStrictNullChecks()
-
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#strictNullChecks(boolean)
-
- com.fasterxml.jackson.module.kotlin.KotlinModule$Builder#reflectionCacheSize(int)
-
+ com.fasterxml.jackson.module.kotlin.KotlinModule#getSingletonSupport()
+ com.fasterxml.jackson.module.kotlin.SingletonSupport
-
- com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector#KotlinNamesAnnotationIntrospector(com.fasterxml.jackson.module.kotlin.ReflectionCache,java.util.Set,boolean)
-
-
- com.fasterxml.jackson.module.kotlin.ReflectionCache#checkConstructorIsCreatorAnnotated(com.fasterxml.jackson.databind.introspect.AnnotatedConstructor,kotlin.jvm.functions.Function1)
-
diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x
index 63110ae29..c378593f0 100644
--- a/release-notes/CREDITS-2.x
+++ b/release-notes/CREDITS-2.x
@@ -15,6 +15,11 @@ Authors:
Contributors:
+# 2.19.0 (not yet released)
+
+WrongWrong (@k163377)
+* #835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport
+
# 2.18.0 (26-Sep-2024)
WrongWrong (@k163377)
diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x
index 8a0edebd5..1ae9cf7e6 100644
--- a/release-notes/VERSION-2.x
+++ b/release-notes/VERSION-2.x
@@ -18,7 +18,7 @@ Co-maintainers:
2.19.0 (not yet released)
-- No changes since 2.18
+#835: Remove old SingletonSupport class and unified with KotlinFeature.SingletonSupport.
2.18.0 (26-Sep-2024)
diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt
index f8da63d4a..bbbbbc240 100644
--- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt
+++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinFeature.kt
@@ -30,7 +30,6 @@ enum class KotlinFeature(internal val enabledByDefault: Boolean) {
* Deserializing a singleton overwrites the value of the single instance.
*
* See [jackson-module-kotlin#225]: keep Kotlin singletons as singletons.
- * @see com.fasterxml.jackson.module.kotlin.SingletonSupport
*/
SingletonSupport(enabledByDefault = false),
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 3ddc3dd10..0e106e0fd 100644
--- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt
+++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt
@@ -5,11 +5,11 @@ import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullIsSameAsDefault
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyCollection
import com.fasterxml.jackson.module.kotlin.KotlinFeature.NullToEmptyMap
+import com.fasterxml.jackson.module.kotlin.KotlinFeature.SingletonSupport
import com.fasterxml.jackson.module.kotlin.KotlinFeature.StrictNullChecks
import com.fasterxml.jackson.module.kotlin.KotlinFeature.KotlinPropertyNameAsImplicitName
import com.fasterxml.jackson.module.kotlin.KotlinFeature.UseJavaDurationConversion
import java.util.*
-import kotlin.reflect.KClass
fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class.java)
@@ -23,8 +23,8 @@ fun Class<*>.isKotlinClass(): Boolean = this.isAnnotationPresent(Metadata::class
* map object.
* @property nullIsSameAsDefault Default false. Whether to treat null values as absent when deserializing, thereby
* using the default value provided in Kotlin.
- * @property singletonSupport Default: DISABLED. Mode for singleton handling.
- * See {@link com.fasterxml.jackson.module.kotlin.SingletonSupport label}
+ * @property singletonSupport Default: false. Mode for singleton handling.
+ * See [KotlinFeature.SingletonSupport]
* @property enabledSingletonSupport Default: false. A temporary property that is maintained until the return value of `singletonSupport` is changed.
* It will be removed in 2.21.
* @property strictNullChecks Default: false. Whether to check deserialized collections. With this disabled,
@@ -41,13 +41,7 @@ class KotlinModule private constructor(
val nullToEmptyCollection: Boolean = NullToEmptyCollection.enabledByDefault,
val nullToEmptyMap: Boolean = NullToEmptyMap.enabledByDefault,
val nullIsSameAsDefault: Boolean = NullIsSameAsDefault.enabledByDefault,
- @property:Deprecated(
- level = DeprecationLevel.ERROR,
- message = "The return value will be Boolean in 2.19. Until then, use enabledSingletonSupport.",
- replaceWith = ReplaceWith("enabledSingletonSupport")
- )
- @Suppress("DEPRECATION_ERROR")
- val singletonSupport: SingletonSupport = SingletonSupport.DISABLED,
+ val singletonSupport: Boolean = SingletonSupport.enabledByDefault,
val strictNullChecks: Boolean = StrictNullChecks.enabledByDefault,
@Deprecated(
level = DeprecationLevel.ERROR,
@@ -60,12 +54,28 @@ class KotlinModule private constructor(
) : SimpleModule(KotlinModule::class.java.name, PackageVersion.VERSION) {
@Suppress("DEPRECATION_ERROR")
val kotlinPropertyNameAsImplicitName: Boolean get() = useKotlinPropertyNameForGetter
- @Suppress("DEPRECATION_ERROR")
- val enabledSingletonSupport: Boolean get() = singletonSupport == SingletonSupport.CANONICALIZE
+
+ /*
+ * 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.
+ *
+ * 1. add enabledSingletonSupport: Boolean property
+ * 2. delete SingletonSupport class and change the property to singletonSupport: Boolean
+ * 3. remove the enabledSingletonSupport property
+ *
+ * Now that 2 is complete, deprecation is in progress for 3.
+ */
+ @Deprecated(
+ level = DeprecationLevel.WARNING,
+ message = "This property is scheduled to be removed in 2.21 or later" +
+ " in order to unify the use of KotlinFeature.",
+ replaceWith = ReplaceWith("singletonSupport")
+ )
+ val enabledSingletonSupport: Boolean get() = singletonSupport
companion object {
// Increment when option is added
- private const val serialVersionUID = 2L
+ private const val serialVersionUID = 3L
}
@Deprecated(
@@ -79,11 +89,7 @@ class KotlinModule private constructor(
builder.isEnabled(NullToEmptyCollection),
builder.isEnabled(NullToEmptyMap),
builder.isEnabled(NullIsSameAsDefault),
- @Suppress("DEPRECATION_ERROR")
- when {
- builder.isEnabled(KotlinFeature.SingletonSupport) -> SingletonSupport.CANONICALIZE
- else -> SingletonSupport.DISABLED
- },
+ builder.isEnabled(SingletonSupport),
builder.isEnabled(StrictNullChecks),
builder.isEnabled(KotlinPropertyNameAsImplicitName),
builder.isEnabled(UseJavaDurationConversion),
diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/SingletonSupport.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/SingletonSupport.kt
deleted file mode 100644
index 7e2d83d9b..000000000
--- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/SingletonSupport.kt
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.fasterxml.jackson.module.kotlin
-
-/**
- * Special handling for singletons.
- */
-@Deprecated(
- level = DeprecationLevel.ERROR,
- message = "It will be removed in 2.19 to unify with KotlinFeature.",
- replaceWith = ReplaceWith("KotlinFeature.SingletonSupport")
-)
-enum class SingletonSupport {
- // No special handling of singletons (pre-2.10 behavior)
- // Each time a Singleton object is deserialized a new instance is created.
- DISABLED,
- // Deserialize then canonicalize (was the default in 2.10)
- // Deserializing a singleton overwrites the value of the single instance.
- // [jackson-module-kotlin#225]: keep Kotlin singletons as singletons
- CANONICALIZE
-}