code: static Method findMethod(Class<?> cl, String methodName) {
          Class<?> search = cl;
          Method method = null;
          while (search != null) {
              try {
                  method = search.getDeclaredMethod(methodName, (Class[]) null);
                  if (search == cl
                          || (method.getModifiers() & Modifier.PRIVATE) == 0) {
                      method.setAccessible(true);
                      return method;
                  }
              } catch (NoSuchMethodException nsm) {
              }
              search = search.getSuperclass();
          }
          return null;
      }
docs: Return the java.lang.reflect.Method if class <code>cl</code> implements
  <code>methodName</code> . Return null otherwise.
  
  @param cl
  a java.lang.Class which to test
  @return <code>java.lang.reflect.Method</code> if the class implements
  writeReplace <code>null</code> if the class does not implement
  writeReplace