34
34
35
35
import org .apache .commons .logging .Log ;
36
36
import org .apache .commons .logging .LogFactory ;
37
+ import org .springframework .core .BridgeMethodResolver ;
37
38
import org .springframework .util .Assert ;
38
39
import org .springframework .util .ClassUtils ;
39
40
import org .springframework .util .ReflectionUtils ;
@@ -77,7 +78,7 @@ public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
77
78
78
79
ALL_METHODS :
79
80
for (MethodDescriptor md : delegate .getMethodDescriptors ()) {
80
- Method method = md .getMethod ();
81
+ Method method = resolveMethod ( md .getMethod () );
81
82
82
83
// bypass non-getter java.lang.Class methods for efficiency
83
84
if (ReflectionUtils .isObjectMethod (method ) && !method .getName ().startsWith ("get" )) {
@@ -91,8 +92,8 @@ public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
91
92
continue ALL_METHODS ;
92
93
}
93
94
for (PropertyDescriptor pd : delegate .getPropertyDescriptors ()) {
94
- Method readMethod = pd . getReadMethod ( );
95
- Method writeMethod = pd . getWriteMethod ( );
95
+ Method readMethod = readMethodFor ( pd );
96
+ Method writeMethod = writeMethodFor ( pd );
96
97
// has the setter already been found by the wrapped BeanInfo?
97
98
if (writeMethod != null
98
99
&& writeMethod .getName ().equals (method .getName ())) {
@@ -126,10 +127,10 @@ public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
126
127
continue DELEGATE_PD ;
127
128
}
128
129
IndexedPropertyDescriptor ipd = (IndexedPropertyDescriptor ) pd ;
129
- Method readMethod = ipd . getReadMethod ( );
130
- Method writeMethod = ipd . getWriteMethod ( );
131
- Method indexedReadMethod = ipd . getIndexedReadMethod ( );
132
- Method indexedWriteMethod = ipd . getIndexedWriteMethod ( );
130
+ Method readMethod = readMethodFor ( ipd );
131
+ Method writeMethod = writeMethodFor ( ipd );
132
+ Method indexedReadMethod = indexedReadMethodFor ( ipd );
133
+ Method indexedWriteMethod = indexedWriteMethodFor ( ipd );
133
134
// has the setter already been found by the wrapped BeanInfo?
134
135
if (!(indexedWriteMethod != null
135
136
&& indexedWriteMethod .getName ().equals (method .getName ()))) {
@@ -149,33 +150,54 @@ public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException {
149
150
for (PropertyDescriptor pd : delegate .getPropertyDescriptors ()) {
150
151
// have we already copied this read method to a property descriptor locally?
151
152
String propertyName = pd .getName ();
152
- Method readMethod = pd . getReadMethod ( );
153
+ Method readMethod = readMethodFor ( pd );
153
154
Method mostSpecificReadMethod = ClassUtils .getMostSpecificMethod (readMethod , method .getDeclaringClass ());
154
155
for (PropertyDescriptor existingPD : this .propertyDescriptors ) {
155
156
if (method .equals (mostSpecificReadMethod )
156
157
&& existingPD .getName ().equals (propertyName )) {
157
- if (existingPD . getReadMethod ( ) == null ) {
158
+ if (readMethodFor ( existingPD ) == null ) {
158
159
// no -> add it now
159
- this .addOrUpdatePropertyDescriptor (pd , propertyName , method , pd . getWriteMethod ( ));
160
+ this .addOrUpdatePropertyDescriptor (pd , propertyName , method , writeMethodFor ( pd ));
160
161
}
161
162
// yes -> do not add a duplicate
162
163
continue ALL_METHODS ;
163
164
}
164
165
}
165
166
if (method .equals (mostSpecificReadMethod )
166
- || (pd instanceof IndexedPropertyDescriptor && method .equals (((IndexedPropertyDescriptor ) pd ). getIndexedReadMethod ( )))) {
167
+ || (pd instanceof IndexedPropertyDescriptor && method .equals (indexedReadMethodFor ((IndexedPropertyDescriptor ) pd )))) {
167
168
// yes -> copy it, including corresponding setter method (if any -- may be null)
168
169
if (pd instanceof IndexedPropertyDescriptor ) {
169
- this .addOrUpdatePropertyDescriptor (pd , propertyName , readMethod , pd . getWriteMethod ( ), ((IndexedPropertyDescriptor )pd ). getIndexedReadMethod (), ((IndexedPropertyDescriptor )pd ). getIndexedWriteMethod ( ));
170
+ this .addOrUpdatePropertyDescriptor (pd , propertyName , readMethod , writeMethodFor ( pd ), indexedReadMethodFor ((IndexedPropertyDescriptor )pd ), indexedWriteMethodFor ((IndexedPropertyDescriptor )pd ));
170
171
} else {
171
- this .addOrUpdatePropertyDescriptor (pd , propertyName , readMethod , pd . getWriteMethod ( ));
172
+ this .addOrUpdatePropertyDescriptor (pd , propertyName , readMethod , writeMethodFor ( pd ));
172
173
}
173
174
continue ALL_METHODS ;
174
175
}
175
176
}
176
177
}
177
178
}
178
179
180
+
181
+ private static Method resolveMethod (Method method ) {
182
+ return BridgeMethodResolver .findBridgedMethod (method );
183
+ }
184
+
185
+ private static Method readMethodFor (PropertyDescriptor pd ) {
186
+ return resolveMethod (pd .getReadMethod ());
187
+ }
188
+
189
+ private static Method writeMethodFor (PropertyDescriptor pd ) {
190
+ return resolveMethod (pd .getWriteMethod ());
191
+ }
192
+
193
+ private static Method indexedReadMethodFor (IndexedPropertyDescriptor ipd ) {
194
+ return resolveMethod (ipd .getIndexedReadMethod ());
195
+ }
196
+
197
+ private static Method indexedWriteMethodFor (IndexedPropertyDescriptor ipd ) {
198
+ return resolveMethod (ipd .getIndexedWriteMethod ());
199
+ }
200
+
179
201
private void addOrUpdatePropertyDescriptor (PropertyDescriptor pd , String propertyName , Method readMethod , Method writeMethod ) throws IntrospectionException {
180
202
addOrUpdatePropertyDescriptor (pd , propertyName , readMethod , writeMethod , null , null );
181
203
}
@@ -186,9 +208,9 @@ private void addOrUpdatePropertyDescriptor(PropertyDescriptor pd, String propert
186
208
for (PropertyDescriptor existingPD : this .propertyDescriptors ) {
187
209
if (existingPD .getName ().equals (propertyName )) {
188
210
// is there already a descriptor that captures this read method or its corresponding write method?
189
- if (existingPD . getReadMethod ( ) != null ) {
190
- if (readMethod != null && existingPD . getReadMethod ( ).getReturnType () != readMethod .getReturnType ()
191
- || writeMethod != null && existingPD . getReadMethod ( ).getReturnType () != writeMethod .getParameterTypes ()[0 ]) {
211
+ if (readMethodFor ( existingPD ) != null ) {
212
+ if (readMethod != null && readMethodFor ( existingPD ).getReturnType () != readMethod .getReturnType ()
213
+ || writeMethod != null && readMethodFor ( existingPD ).getReturnType () != writeMethod .getParameterTypes ()[0 ]) {
192
214
// no -> add a new descriptor for it below
193
215
break ;
194
216
}
@@ -205,9 +227,9 @@ private void addOrUpdatePropertyDescriptor(PropertyDescriptor pd, String propert
205
227
}
206
228
207
229
// is there already a descriptor that captures this write method or its corresponding read method?
208
- if (existingPD . getWriteMethod ( ) != null ) {
209
- if (readMethod != null && existingPD . getWriteMethod ( ).getParameterTypes ()[0 ] != readMethod .getReturnType ()
210
- || writeMethod != null && existingPD . getWriteMethod ( ).getParameterTypes ()[0 ] != writeMethod .getParameterTypes ()[0 ]) {
230
+ if (writeMethodFor ( existingPD ) != null ) {
231
+ if (readMethod != null && writeMethodFor ( existingPD ).getParameterTypes ()[0 ] != readMethod .getReturnType ()
232
+ || writeMethod != null && writeMethodFor ( existingPD ).getParameterTypes ()[0 ] != writeMethod .getParameterTypes ()[0 ]) {
211
233
// no -> add a new descriptor for it below
212
234
break ;
213
235
}
@@ -224,9 +246,9 @@ private void addOrUpdatePropertyDescriptor(PropertyDescriptor pd, String propert
224
246
IndexedPropertyDescriptor existingIPD = (IndexedPropertyDescriptor ) existingPD ;
225
247
226
248
// is there already a descriptor that captures this indexed read method or its corresponding indexed write method?
227
- if (existingIPD . getIndexedReadMethod ( ) != null ) {
228
- if (indexedReadMethod != null && existingIPD . getIndexedReadMethod ( ).getReturnType () != indexedReadMethod .getReturnType ()
229
- || indexedWriteMethod != null && existingIPD . getIndexedReadMethod ( ).getReturnType () != indexedWriteMethod .getParameterTypes ()[1 ]) {
249
+ if (indexedReadMethodFor ( existingIPD ) != null ) {
250
+ if (indexedReadMethod != null && indexedReadMethodFor ( existingIPD ).getReturnType () != indexedReadMethod .getReturnType ()
251
+ || indexedWriteMethod != null && indexedReadMethodFor ( existingIPD ).getReturnType () != indexedWriteMethod .getParameterTypes ()[1 ]) {
230
252
// no -> add a new descriptor for it below
231
253
break ;
232
254
}
@@ -243,9 +265,9 @@ private void addOrUpdatePropertyDescriptor(PropertyDescriptor pd, String propert
243
265
}
244
266
245
267
// is there already a descriptor that captures this indexed write method or its corresponding indexed read method?
246
- if (existingIPD . getIndexedWriteMethod ( ) != null ) {
247
- if (indexedReadMethod != null && existingIPD . getIndexedWriteMethod ( ).getParameterTypes ()[1 ] != indexedReadMethod .getReturnType ()
248
- || indexedWriteMethod != null && existingIPD . getIndexedWriteMethod ( ).getParameterTypes ()[1 ] != indexedWriteMethod .getParameterTypes ()[1 ]) {
268
+ if (indexedWriteMethodFor ( existingIPD ) != null ) {
269
+ if (indexedReadMethod != null && indexedWriteMethodFor ( existingIPD ).getParameterTypes ()[1 ] != indexedReadMethod .getReturnType ()
270
+ || indexedWriteMethod != null && indexedWriteMethodFor ( existingIPD ).getParameterTypes ()[1 ] != indexedWriteMethod .getParameterTypes ()[1 ]) {
249
271
// no -> add a new descriptor for it below
250
272
break ;
251
273
}
0 commit comments