code: private static Method[] discoverAccessibleMethods(Class<?> clazz,
                                                        boolean includeProtected,
                                                        boolean includePrivate)
      {
          Map<MethodSignature,Method> map = new HashMap<MethodSignature,Method>();
          discoverAccessibleMethods(clazz, map, includeProtected, includePrivate);
          return map.values().toArray(new Method[map.size()]);
      }
docs: Retrieves mapping of methods to accessible methods for a class.
  In case the class is not public, retrieves methods with same
  signature as its public methods from public superclasses and
  interfaces (if they exist). Basically upcasts every method to the
  nearest accessible method.