/** * For a given method, retrieves its publicly accessible counterpart. * This method will look for a method with same name * and signature declared in a public superclass or implemented interface of this * method's declaring class. This counterpart method is publicly callable. * * @param method a method whose publicly callable counterpart is requested. * @return the publicly callable counterpart method. Note that if the parameter * method is itself declared by a public class, this method is an identity * function. */ public static Method getPublicMethod(Method method) { Class clazz = method.getDeclaringClass(); /* * Short circuit for (hopefully the majority of) cases where the declaring * class is public. */ if((clazz.getModifiers() & Modifier.PUBLIC) != 0) { return method; } return getPublicMethod(clazz, method.getName(), method.getParameterTypes()); }
Method superclazzMethod = getPublicMethod(superclazz, name, paramTypes); Method interfaceMethod = getPublicMethod(interfaces[i], name, paramTypes);
Method publicMethod = getPublicMethod( method );