code: private static boolean getInternalPublicMethods(Class<?> cls,
                                                      Map<Signature, Method> sigs) {
          Method[] methods = null;
          try {
              /*
               * This class or interface is non-public so we
               * can't use any of it's methods. Go back and
               * try again with a superclass or superinterface.
               */
              if (!Modifier.isPublic(cls.getModifiers())) {
                  return false;
              }
              if (!ReflectUtil.isPackageAccessible(cls)) {
                  return false;
              }
  
              methods = cls.getMethods();
          } catch (SecurityException se) {
              return false;
          }
  
          /*
           * Check for inherited methods with non-public
           * declaring classes. They might override and hide
           * methods from their superclasses or
           * superinterfaces.
           */
          boolean done = true;
          for (int i=0; i < methods.length; i++) {
              Class<?> dc = methods[i].getDeclaringClass();
              if (!Modifier.isPublic(dc.getModifiers())) {
                  done = false;
                  break;
              }
          }
  
          if (done) {
              /*
               * We're done. Spray all the methods into
               * the list and then we're out of here.
               */
              for (int i=0; i < methods.length; i++) {
                  addMethod(sigs, methods[i]);
              }
          } else {
              /*
               * Simulate cls.getDeclaredMethods() by
               * stripping away inherited methods.
               */
              for (int i=0; i < methods.length; i++) {
                  Class<?> dc = methods[i].getDeclaringClass();
                  if (cls.equals(dc)) {
                      addMethod(sigs, methods[i]);
                  }
              }
          }
          return done;
      }
docs: /*
  
  Process the methods in this class or interface