private static void addNonPrivateMethods()

in webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java [306:379]


    private static void addNonPrivateMethods(Class<?> topClass, boolean excludeFinalMethods,
                                             Map<String, List<Method>> methodMap, List<Method> allMethods,
                                             Class<?> clazz)
    {
        List<Method> temp = new ArrayList<>(Arrays.asList(clazz.getMethods()));
        for (Method method : clazz.getDeclaredMethods())
        {
            if (!temp.contains(method))
            {
                temp.add(method);
            }
        }

        for (Method method : temp)
        {
            if (allMethods.contains(method))
            {
                continue;
            }

            if (method.isBridge())
            {
                // we have no interest in generics bridge methods
                continue;
            }

            int modifiers = method.getModifiers();

            if (Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers))
            {
                continue;
            }
            if (excludeFinalMethods && Modifier.isFinal(modifiers))
            {
                continue;
            }

            if ("finalize".equals(method.getName()))
            {
                // we do not proxy finalize()
                continue;
            }

            // check for package-private methods from a different package
            if (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers))
            {
                // private already got handled above, so we only had to check for not public nor protected
                // we cannot see those methods if they are not in the same package as the rootClazz
                if (!clazz.getPackage().getName().equals(topClass.getPackage().getName()))
                {
                    continue;
                }

            }

            List<Method> methods = methodMap.get(method.getName());
            if (methods == null)
            {
                methods = new ArrayList<>();
                methods.add(method);
                allMethods.add(method);
                methodMap.put(method.getName(), methods);
            }
            else
            {
                if (!isOverridden(methods, method))
                {
                    // method is not overridden, so add it
                    methods.add(method);
                    allMethods.add(method);
                }
            }
        }
    }