private void getMethodsToProxy(
      Set<MethodSetEntry> sink, Set<MethodSetEntry> seenFinalMethods, Class<?> c) {
    for (Method method : c.getDeclaredMethods()) {
      if ((method.getModifiers() & Modifier.FINAL) != 0) {
        // Skip final methods, we can't override them. We
        // also need to remember them, in case the same
        // method exists in a parent class.
        MethodSetEntry entry = new MethodSetEntry(method);
        seenFinalMethods.add(entry);
        // We may have seen this method already, from an interface
        // implemented by a child class. We need to remove it here.
        sink.remove(entry);
        continue;
      }
      if ((method.getModifiers() & STATIC) != 0) {
        // Skip static methods, overriding them has no effect.
        continue;
      }
      if (!Modifier.isPublic(method.getModifiers())
          && !Modifier.isProtected(method.getModifiers())
          && (!sharedClassLoader || Modifier.isPrivate(method.getModifiers()))) {
        // Skip private methods, since they are invoked through direct
        // invocation (as opposed to virtual). Therefore, it would not
        // be possible to intercept any private method defined inside
        // the proxy class except through reflection.

        // Skip package-private methods as well (for non-shared class
        // loaders). The proxy class does
        // not actually inherit package-private methods from the parent
        // class because it is not a member of the parent's package.
        // This is even true if the two classes have the same package
        // name, as they use different class loaders.
        continue;
      }
      if (method.getName().equals("finalize") && method.getParameterTypes().length == 0) {
        // Skip finalize method, it's likely important that it execute as normal.
        continue;
      }
      MethodSetEntry entry = new MethodSetEntry(method);
      if (seenFinalMethods.contains(entry)) {
        // This method is final in a child class.
        // We can't override it.
        continue;
      }
      sink.add(entry);
    }

    // Only visit the interfaces of this class if it is itself an interface. That prevents
    // visiting interfaces of a class before its super classes.
    if (c.isInterface()) {
      for (Class<?> i : c.getInterfaces()) {
        getMethodsToProxy(sink, seenFinalMethods, i);
      }
    }
  }
Gets all {@link Method} objects we can proxy in the hierarchy of the supplied class.
android/android_framework/dex-maker/src/main/java/com/android/dx/stock/ProxyBuilder.java