static private Method getMethod(Class cl, Method method) { if (method == null) { return null; } if (Modifier.isPublic (cl.getModifiers ())) { return method; } return getMethodFromInterfaceOrSuperclass(cl, method); }
private Object invokeMethod(Method m, Object base, Object[] params) { Class[] parameterTypes = m.getParameterTypes(); Object[] parameters = null; if (parameterTypes.length > 0) { ExpressionFactory exprFactory = ExpressionFactory.newInstance(); parameters = new Object[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { parameters[i] = exprFactory.coerceToType(params[i], parameterTypes[i]); } } try { // If m is a public method in a non-public class that implements a public interface // or has a public superclass, suppress Java access checking to work around JDK-4071957 if ((!Modifier.isPublic(m.getDeclaringClass().getModifiers())) && Modifier.isPublic(m.getModifiers()) && (getMethodFromInterfaceOrSuperclass(m.getDeclaringClass(), m) != null)) { setAccessible(m); } return m.invoke(base, parameters); } catch (IllegalAccessException iae) { throw new ELException(iae); } catch (InvocationTargetException ite) { throw new ELException(ite.getCause()); } }