publicinterfaceMember { /** * Identifies the set of all public members of a class or interface, * including inherited members. */ public static finalint PUBLIC = 0;
/** * Identifies the set of declared members of a class or interface. * Inherited members are not included. */ public static finalint DECLARED = 1; }
private Method privateGetMethodRecursive(String name, Class<?>[] parameterTypes, boolean includeStaticMethods, MethodArray allInterfaceCandidates) { // Note: the intent is that the search algorithm this routine // uses be equivalent to the ordering imposed by // privateGetPublicMethods(). It fetches only the declared // public methods foreachclass, however, to reduce the // number ofMethod objects which have to be created for the // common casewhere the method being requested is declared in // the class which is being queried. // // Due todefault methods, unless a methodisfoundon a superclass, // methods declared inany superinterface needs to be considered. // Collect all candidates declared in superinterfaces in {@code // allInterfaceCandidates} andselect the most specific ifno match on // a superclass isfound.
// Must _not_ return root methods Method res; // Search declared public methods if ((res = searchMethods(privateGetDeclaredMethods(true), name, parameterTypes)) != null) { if (includeStaticMethods || !Modifier.isStatic(res.getModifiers())) return res; } // Search superclass's methods if (!isInterface()) { Class<? super T> c = getSuperclass(); if (c != null) { if ((res = c.getMethod0(name, parameterTypes, true)) != null) { return res; } } } // Search superinterfaces' methods Class<?>[] interfaces = getInterfaces(); for (Class<?> c : interfaces) if ((res = c.getMethod0(name, parameterTypes, false)) != null) allInterfaceCandidates.add(res); // Notfound returnnull; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
privateMethod[] privateGetDeclaredMethods(boolean publicOnly){ checkInitted(); Method[] res; ReflectionData<T> rd = reflectionData(); if (rd != null) { res = publicOnly ? rd.declaredPublicMethods : rd.declaredMethods; if (res != null) return res; } // Nocachedvalueavailable; request value from VM res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly)); if (rd != null) { if (publicOnly) { rd.declaredPublicMethods = res; }else{ rd.declaredMethods = res; } } return res; }