Introspect interface-declared methods in case of proxy (for varargs)

Issue: SPR-16122

(cherry picked from commit 419b444)
This commit is contained in:
Juergen Hoeller
2017-10-27 10:52:44 +02:00
parent 8904de2149
commit 9cc3349e2d
2 changed files with 538 additions and 494 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,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.Arrays;
import java.util.Collection;
@@ -232,6 +233,14 @@ public class ReflectiveMethodResolver implements MethodResolver {
result.addAll(Arrays.asList(getMethods(Class.class)));
return result;
}
else if (Proxy.isProxyClass(type)) {
Set<Method> result = new LinkedHashSet<Method>();
// Expose interface methods (not proxy-declared overrides) for proper vararg introspection
for (Class<?> ifc : type.getInterfaces()) {
result.addAll(Arrays.asList(getMethods(ifc)));
}
return result;
}
else {
return Arrays.asList(getMethods(type));
}