ReflectiveMethodResolver lets local static methods override java.lang.Class methods

Issue: SPR-13918
(cherry picked from commit 43bcab9)
This commit is contained in:
Juergen Hoeller
2016-02-08 13:23:02 +01:00
parent c960d9733d
commit cf3e460a8b
2 changed files with 17 additions and 2 deletions

View File

@@ -221,14 +221,15 @@ public class ReflectiveMethodResolver implements MethodResolver {
private Collection<Method> getMethods(Class<?> type, Object targetObject) {
if (targetObject instanceof Class) {
Set<Method> result = new LinkedHashSet<Method>();
result.addAll(Arrays.asList(getMethods(targetObject.getClass())));
// Add these also so that static result are invocable on the type: e.g. Float.valueOf(..)
// Add these so that static methods are invocable on the type: e.g. Float.valueOf(..)
Method[] methods = getMethods(type);
for (Method method : methods) {
if (Modifier.isStatic(method.getModifiers())) {
result.add(method);
}
}
// Also expose methods from java.lang.Class itself
result.addAll(Arrays.asList(getMethods(Class.class)));
return result;
}
else {