private static Method[] getDeclaredMethods(Class<?> clazz) {
        Method[] result = DECLARED_METHODS_CACHE.get(clazz);
        if (result == null) {
            Method[] declaredMethods = clazz.getDeclaredMethods();
            List<Method> defaultMethods = findConcreteMethodsOnInterfaces(clazz);
            if (defaultMethods != null) {
                result = new Method[declaredMethods.length + defaultMethods.size()];
                System.arraycopy(declaredMethods, 0, result, 0, declaredMethods.length);
                int index = declaredMethods.length;
                for (Method defaultMethod : defaultMethods) {
                    result[index] = defaultMethod;
                    index++;
                }
            } else {
                result = declaredMethods;
            }
            DECLARED_METHODS_CACHE.put(clazz, result.length == 0 ? NO_METHODS : result);
        }
        return result;
    }
This variant retrieves {@link Class#getDeclaredMethods()} global a local cache
in order to avoid the JVM's SecurityManager check and defensive array copying.
In addition, it also includes Java 8 default methods global locally implemented
interfaces, since those are effectively to be treated just like declared methods.

@param clazz the class to introspect
@return the cached array of methods
@see Class#getDeclaredMethods()
android/android_framework/base/src/main/java/util/ReflectionUtils.java