@@ -97,34 +97,8 @@ private void registerReflectionHints(ReflectionHints hints, Set<Type> seen, Type
97
97
BeanInfo beanInfo = Introspector .getBeanInfo (clazz );
98
98
PropertyDescriptor [] propertyDescriptors = beanInfo .getPropertyDescriptors ();
99
99
for (PropertyDescriptor propertyDescriptor : propertyDescriptors ) {
100
- Method writeMethod = propertyDescriptor .getWriteMethod ();
101
- if (writeMethod != null && writeMethod .getDeclaringClass () != Object .class
102
- && writeMethod .getDeclaringClass () != Enum .class ) {
103
- hints .registerMethod (writeMethod , INVOKE );
104
- MethodParameter methodParameter = MethodParameter .forExecutable (writeMethod , 0 );
105
- Type methodParameterType = methodParameter .getGenericParameterType ();
106
- if (!seen .contains (methodParameterType )) {
107
- registerReflectionHints (hints , seen , methodParameterType );
108
- }
109
- }
110
- Method readMethod = propertyDescriptor .getReadMethod ();
111
- if (readMethod != null && readMethod .getDeclaringClass () != Object .class
112
- && readMethod .getDeclaringClass () != Enum .class ) {
113
- hints .registerMethod (readMethod , INVOKE );
114
- MethodParameter methodParameter = MethodParameter .forExecutable (readMethod , -1 );
115
- Type methodParameterType = methodParameter .getGenericParameterType ();
116
- if (!seen .contains (methodParameterType )) {
117
- registerReflectionHints (hints , seen , methodParameterType );
118
- }
119
- }
120
- }
121
- String companionClassName = clazz .getCanonicalName () + KOTLIN_COMPANION_SUFFIX ;
122
- if (KotlinDetector .isKotlinType (clazz ) && ClassUtils .isPresent (companionClassName , null )) {
123
- Class <?> companionClass = ClassUtils .resolveClassName (companionClassName , null );
124
- Method serializerMethod = ClassUtils .getMethodIfAvailable (companionClass , "serializer" );
125
- if (serializerMethod != null ) {
126
- hints .registerMethod (serializerMethod );
127
- }
100
+ registerPropertyHints (hints , seen , propertyDescriptor .getWriteMethod (), 0 );
101
+ registerPropertyHints (hints , seen , propertyDescriptor .getReadMethod (), -1 );
128
102
}
129
103
}
130
104
catch (IntrospectionException ex ) {
@@ -133,15 +107,39 @@ private void registerReflectionHints(ReflectionHints hints, Set<Type> seen, Type
133
107
}
134
108
}
135
109
}
110
+ registerKotlinSerializationHints (hints , clazz );
136
111
});
137
112
}
138
113
Set <Class <?>> referencedTypes = new LinkedHashSet <>();
139
114
collectReferencedTypes (seen , referencedTypes , type );
140
115
referencedTypes .forEach (referencedType -> registerReflectionHints (hints , seen , referencedType ));
141
116
}
142
117
143
- private void collectReferencedTypes (Set <Type > seen , Set <Class <?>> types , @ Nullable Type type ) {
144
- if (type == null || seen .contains (type )) {
118
+ private void registerPropertyHints (ReflectionHints hints , Set <Type > seen , @ Nullable Method method , int parameterIndex ) {
119
+ if (method != null && method .getDeclaringClass () != Object .class
120
+ && method .getDeclaringClass () != Enum .class ) {
121
+ hints .registerMethod (method , INVOKE );
122
+ MethodParameter methodParameter = MethodParameter .forExecutable (method , parameterIndex );
123
+ Type methodParameterType = methodParameter .getGenericParameterType ();
124
+ if (!seen .contains (methodParameterType )) {
125
+ registerReflectionHints (hints , seen , methodParameterType );
126
+ }
127
+ }
128
+ }
129
+
130
+ private void registerKotlinSerializationHints (ReflectionHints hints , Class <?> clazz ) {
131
+ String companionClassName = clazz .getCanonicalName () + KOTLIN_COMPANION_SUFFIX ;
132
+ if (KotlinDetector .isKotlinType (clazz ) && ClassUtils .isPresent (companionClassName , null )) {
133
+ Class <?> companionClass = ClassUtils .resolveClassName (companionClassName , null );
134
+ Method serializerMethod = ClassUtils .getMethodIfAvailable (companionClass , "serializer" );
135
+ if (serializerMethod != null ) {
136
+ hints .registerMethod (serializerMethod );
137
+ }
138
+ }
139
+ }
140
+
141
+ private void collectReferencedTypes (Set <Type > seen , Set <Class <?>> types , Type type ) {
142
+ if (seen .contains (type )) {
145
143
return ;
146
144
}
147
145
ResolvableType resolvableType = ResolvableType .forType (type );
0 commit comments