#10 Fix For bsh.Reflect.findAccessibleMethod For Proxies

open
nobody
None
5
2005-09-16
2005-09-16
Anonymous
No

The following code should be added to the beginning of
the method in order to unproxy the proxies as their
first implemented interface. This fixes issues where
the proxy is actually from beanshell having created a
proxy for an anonymous class.

// We will have to "unproxy" all of the proxies here
because the
// java reflection mechanism will not find methods
if we provide
// proxies as the types of the arguments of the
method rather than
// the actual Class object.
Class[] unProxiedTypes = new Class[types.length];
for (int i=0; i<types.length; i++) {
Class c = types[i];

if (c != null && Proxy.isProxyClass(c)) {
// We will unproxy as the first implemented interface.
unProxiedTypes[i] = types[i].getInterfaces()[0];
} else {
unProxiedTypes[i] = types[i];
}
}

types = unProxiedTypes;

Discussion


Log in to post a comment.