Skip to content

Commit 7ae18f4

Browse files
authored
Resolving incompatibilities in 2.13.2 (#551)
Changes to undo binary incompatibility changes.
1 parent ab2bb88 commit 7ae18f4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,13 @@
185185
<plugin>
186186
<groupId>com.github.siom79.japicmp</groupId>
187187
<artifactId>japicmp-maven-plugin</artifactId>
188-
<version>0.15.3</version>
188+
<version>0.15.7</version>
189189
<configuration>
190190
<oldVersion>
191191
<dependency>
192192
<groupId>com.fasterxml.jackson.module</groupId>
193193
<artifactId>jackson-module-kotlin</artifactId>
194-
<version>2.13.0</version>
194+
<version>2.13.1</version>
195195
<type>jar</type>
196196
</dependency>
197197
</oldVersion>

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@ object ULongSerializer : StdSerializer<ULong>(ULong::class.java) {
4949
private fun Class<*>.getStaticJsonValueGetter(): Method? = this.declaredMethods
5050
.find { method -> Modifier.isStatic(method.modifiers) && method.annotations.any { it is JsonValue } }
5151

52-
internal sealed class ValueClassSerializer<T : Any>(t: Class<T>) : StdSerializer<T>(t) {
53-
object Unbox : ValueClassSerializer<Any>(Any::class.java) {
54-
override fun serialize(value: Any, gen: JsonGenerator, provider: SerializerProvider) {
55-
val unboxed = value::class.java.getMethod("unbox-impl").invoke(value)
56-
57-
if (unboxed == null) {
58-
provider.findNullValueSerializer(null).serialize(unboxed, gen, provider)
59-
return
60-
}
52+
object ValueClassUnboxSerializer : StdSerializer<Any>(Any::class.java) {
53+
override fun serialize(value: Any, gen: JsonGenerator, provider: SerializerProvider) {
54+
val unboxed = value::class.java.getMethod("unbox-impl").invoke(value)
6155

62-
provider.findValueSerializer(unboxed::class.java).serialize(unboxed, gen, provider)
56+
if (unboxed == null) {
57+
provider.findNullValueSerializer(null).serialize(null, gen, provider)
58+
return
6359
}
60+
61+
provider.findValueSerializer(unboxed::class.java).serialize(unboxed, gen, provider)
6462
}
63+
}
6564

65+
internal sealed class ValueClassSerializer<T : Any>(t: Class<T>) : StdSerializer<T>(t) {
6666
class StaticJsonValue<T : Any>(
6767
t: Class<T>, private val staticJsonValueGetter: Method
6868
) : ValueClassSerializer<T>(t) {
@@ -83,9 +83,9 @@ internal sealed class ValueClassSerializer<T : Any>(t: Class<T>) : StdSerializer
8383
// If create a function with a JsonValue in the value class,
8484
// it will be compiled as a static method (= cannot be processed properly by Jackson),
8585
// so use a ValueClassSerializer.StaticJsonValue to handle this.
86-
fun from(t: Class<*>): ValueClassSerializer<*> = t.getStaticJsonValueGetter()
86+
fun from(t: Class<*>): StdSerializer<*> = t.getStaticJsonValueGetter()
8787
?.let { StaticJsonValue(t, it) }
88-
?: Unbox
88+
?: ValueClassUnboxSerializer
8989
}
9090
}
9191

0 commit comments

Comments
 (0)