Skip to content

Commit 9cc3349

Browse files
committed
Introspect interface-declared methods in case of proxy (for varargs)
Issue: SPR-16122 (cherry picked from commit 419b444)
1 parent 8904de2 commit 9cc3349

File tree

2 files changed

+548
-504
lines changed

2 files changed

+548
-504
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodResolver.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.lang.reflect.Method;
2020
import java.lang.reflect.Modifier;
21+
import java.lang.reflect.Proxy;
2122
import java.util.ArrayList;
2223
import java.util.Arrays;
2324
import java.util.Collection;
@@ -232,6 +233,14 @@ private Collection<Method> getMethods(Class<?> type, Object targetObject) {
232233
result.addAll(Arrays.asList(getMethods(Class.class)));
233234
return result;
234235
}
236+
else if (Proxy.isProxyClass(type)) {
237+
Set<Method> result = new LinkedHashSet<Method>();
238+
// Expose interface methods (not proxy-declared overrides) for proper vararg introspection
239+
for (Class<?> ifc : type.getInterfaces()) {
240+
result.addAll(Arrays.asList(getMethods(ifc)));
241+
}
242+
return result;
243+
}
235244
else {
236245
return Arrays.asList(getMethods(type));
237246
}

0 commit comments

Comments
 (0)