@@ -13,7 +13,6 @@ import java.lang.reflect.AccessibleObject
13
13
import java.lang.reflect.Constructor
14
14
import java.lang.reflect.Field
15
15
import java.lang.reflect.Method
16
- import java.lang.reflect.Modifier
17
16
import kotlin.reflect.KClass
18
17
import kotlin.reflect.KFunction
19
18
import kotlin.reflect.KMutableProperty1
@@ -71,7 +70,16 @@ internal class KotlinAnnotationIntrospector(
71
70
72
71
override fun findSerializationConverter (a : Annotated ): Converter <* , * >? = when (a) {
73
72
// Find a converter to handle the case where the getter returns an unboxed value from the value class.
74
- is AnnotatedMethod -> a.findValueClassReturnType()?.let { cache.getValueClassBoxConverter(a.rawReturnType, it) }
73
+ is AnnotatedMethod -> a.findValueClassReturnType()?.let {
74
+ if (useJavaDurationConversion && it == Duration ::class ) {
75
+ if (a.rawReturnType == Duration ::class .java)
76
+ KotlinToJavaDurationConverter
77
+ else
78
+ KotlinDurationValueToJavaDurationConverter
79
+ } else {
80
+ cache.getValueClassBoxConverter(a.rawReturnType, it)
81
+ }
82
+ }
75
83
is AnnotatedClass -> lookupKotlinTypeConverter(a)
76
84
else -> null
77
85
}
@@ -94,11 +102,6 @@ internal class KotlinAnnotationIntrospector(
94
102
?.takeIf { it.requireRebox() }
95
103
?.let { cache.getValueClassBoxConverter(am.rawReturnType, it).delegatingSerializer }
96
104
97
- override fun findSerializer (am : Annotated ): Any? = when ((am as ? AnnotatedMethod )?.findValueClassReturnType()) {
98
- Duration ::class -> KotlinToJavaDurationConverter .delegatingSerializer.takeIf { useJavaDurationConversion }
99
- else -> null
100
- } ? : super .findSerializer(am)
101
-
102
105
override fun findDeserializationConverter (a : Annotated ): Any? {
103
106
if (! useJavaDurationConversion) return null
104
107
0 commit comments