private static int getAccessibleMethods()

in src/main/java/org/apache/maven/shared/utils/introspection/ClassMap.java [275:348]


    private static int getAccessibleMethods(Class<?> clazz, MethodInfo[] methodInfos, int upcastCount) {
        int l = methodInfos.length;

        /*
         *  if this class is public, then check each of the currently
         *  'non-upcasted' methods to see if we have a match
         */

        if (Modifier.isPublic(clazz.getModifiers())) {
            for (int i = 0; i < l && upcastCount < l; ++i) {
                try {
                    MethodInfo methodInfo = methodInfos[i];

                    if (!methodInfo.upcast) {
                        methodInfo.tryUpcasting(clazz);
                        upcastCount++;
                    }
                } catch (NoSuchMethodException e) {
                    /*
                     *  Intentionally ignored - it means
                     *  it wasn't found in the current class
                     */
                }
            }

            /*
             *  Short circuit if all methods were upcast
             */

            if (upcastCount == l) {
                return upcastCount;
            }
        }

        /*
         *   Examine superclass
         */

        Class<?> superclazz = clazz.getSuperclass();

        if (superclazz != null) {
            upcastCount = getAccessibleMethods(superclazz, methodInfos, upcastCount);

            /*
             *  Short circuit if all methods were upcast
             */

            if (upcastCount == l) {
                return upcastCount;
            }
        }

        /*
         *  Examine interfaces. Note we do it even if superclazz == null.
         *  This is redundant as currently java.lang.Object does not implement
         *  any interfaces, however nothing guarantees it will not in future.
         */

        Class<?>[] interfaces = clazz.getInterfaces();

        for (int i = interfaces.length; i-- > 0; ) {
            upcastCount = getAccessibleMethods(interfaces[i], methodInfos, upcastCount);

            /*
             *  Short circuit if all methods were upcast
             */

            if (upcastCount == l) {
                return upcastCount;
            }
        }

        return upcastCount;
    }