Ensure methods declared in Object can be invoked on a JDK proxy in SpEL
This commit ensures that methods declared in java.lang.Object (such as toString() can be invoked on a JDK proxy instance in a SpEL expression. Closes gh-25316
This commit is contained in:
@@ -19,13 +19,7 @@ package org.springframework.expression.spel.support;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import org.springframework.core.BridgeMethodResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -266,7 +260,13 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
||||
* @since 3.1.1
|
||||
*/
|
||||
protected Method[] getMethods(Class<?> type) {
|
||||
return type.getMethods();
|
||||
Set<Method> methods=new HashSet<>();
|
||||
methods.addAll(Arrays.asList(type.getMethods()));
|
||||
//Add all methods of Object to have methods like toString on Proxy-Objects
|
||||
methods.addAll(Arrays.asList(Object.class.getMethods()));
|
||||
|
||||
Method[] methods1 = methods.toArray(new Method[0]);
|
||||
return methods1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user