@@ -138,6 +138,7 @@ public boolean canRead(EvaluationContext context, @Nullable Object target, Strin
138
138
// The readerCache will only contain gettable properties (let's not worry about setters for now).
139
139
Property property = new Property (type , method , null );
140
140
TypeDescriptor typeDescriptor = new TypeDescriptor (property );
141
+ method = ClassUtils .getInterfaceMethodIfPossible (method );
141
142
this .readerCache .put (cacheKey , new InvokerPair (method , typeDescriptor ));
142
143
this .typeDescriptorCache .put (cacheKey , typeDescriptor );
143
144
return true ;
@@ -180,6 +181,7 @@ public TypedValue read(EvaluationContext context, @Nullable Object target, Strin
180
181
// The readerCache will only contain gettable properties (let's not worry about setters for now).
181
182
Property property = new Property (type , method , null );
182
183
TypeDescriptor typeDescriptor = new TypeDescriptor (property );
184
+ method = ClassUtils .getInterfaceMethodIfPossible (method );
183
185
invoker = new InvokerPair (method , typeDescriptor );
184
186
this .lastReadInvokerPair = invoker ;
185
187
this .readerCache .put (cacheKey , invoker );
@@ -239,6 +241,7 @@ public boolean canWrite(EvaluationContext context, @Nullable Object target, Stri
239
241
// Treat it like a property
240
242
Property property = new Property (type , null , method );
241
243
TypeDescriptor typeDescriptor = new TypeDescriptor (property );
244
+ method = ClassUtils .getInterfaceMethodIfPossible (method );
242
245
this .writerCache .put (cacheKey , method );
243
246
this .typeDescriptorCache .put (cacheKey , typeDescriptor );
244
247
return true ;
@@ -287,6 +290,7 @@ public void write(EvaluationContext context, @Nullable Object target, String nam
287
290
if (method == null ) {
288
291
method = findSetterForProperty (name , type , target );
289
292
if (method != null ) {
293
+ method = ClassUtils .getInterfaceMethodIfPossible (method );
290
294
cachedMember = method ;
291
295
this .writerCache .put (cacheKey , cachedMember );
292
296
}
@@ -414,13 +418,24 @@ private Method findMethodForProperty(String[] methodSuffixes, String prefix, Cla
414
418
method .getParameterCount () == numberOfParams &&
415
419
(!mustBeStatic || Modifier .isStatic (method .getModifiers ())) &&
416
420
(requiredReturnTypes .isEmpty () || requiredReturnTypes .contains (method .getReturnType ()))) {
417
- return ClassUtils . getInterfaceMethodIfPossible ( method ) ;
421
+ return method ;
418
422
}
419
423
}
420
424
}
421
425
return null ;
422
426
}
423
427
428
+ /**
429
+ * Return class methods ordered with non-bridge methods appearing higher.
430
+ */
431
+ private Method [] getSortedMethods (Class <?> clazz ) {
432
+ return this .sortedMethodsCache .computeIfAbsent (clazz , key -> {
433
+ Method [] methods = key .getMethods ();
434
+ Arrays .sort (methods , (o1 , o2 ) -> (o1 .isBridge () == o2 .isBridge () ? 0 : (o1 .isBridge () ? 1 : -1 )));
435
+ return methods ;
436
+ });
437
+ }
438
+
424
439
/**
425
440
* Determine whether the given {@code Method} is a candidate for property access
426
441
* on an instance of the given target class.
@@ -434,17 +449,6 @@ protected boolean isCandidateForProperty(Method method, Class<?> targetClass) {
434
449
return true ;
435
450
}
436
451
437
- /**
438
- * Return class methods ordered with non-bridge methods appearing higher.
439
- */
440
- private Method [] getSortedMethods (Class <?> clazz ) {
441
- return this .sortedMethodsCache .computeIfAbsent (clazz , key -> {
442
- Method [] methods = key .getMethods ();
443
- Arrays .sort (methods , (o1 , o2 ) -> (o1 .isBridge () == o2 .isBridge () ? 0 : (o1 .isBridge () ? 1 : -1 )));
444
- return methods ;
445
- });
446
- }
447
-
448
452
/**
449
453
* Return the method suffixes for a given property name. The default implementation
450
454
* uses JavaBean conventions with additional support for properties of the form 'xY'
@@ -536,7 +540,9 @@ public PropertyAccessor createOptimalAccessor(EvaluationContext context, @Nullab
536
540
if (method == null ) {
537
541
method = findGetterForProperty (name , clazz , target );
538
542
if (method != null ) {
539
- invocationTarget = new InvokerPair (method , new TypeDescriptor (new MethodParameter (method , -1 )));
543
+ TypeDescriptor typeDescriptor = new TypeDescriptor (new MethodParameter (method , -1 ));
544
+ method = ClassUtils .getInterfaceMethodIfPossible (method );
545
+ invocationTarget = new InvokerPair (method , typeDescriptor );
540
546
ReflectionUtils .makeAccessible (method );
541
547
this .readerCache .put (cacheKey , invocationTarget );
542
548
}
0 commit comments