private static Method getAccessibleMethodFromSuperclass(
      final Class<?> cls, final String methodName, final Class<?>... parameterTypes) {
    Class<?> parentClass = cls.getSuperclass();
    while (parentClass != null) {
      if (Modifier.isPublic(parentClass.getModifiers())) {
        try {
          return parentClass.getMethod(methodName, parameterTypes);
        } catch (final NoSuchMethodException e) {
          return null;
        }
      }
      parentClass = parentClass.getSuperclass();
    }
    return null;
  }
private static Method getAccessibleMethodFromSuperclass(
      final Class<?> cls, final String methodName, final Class<?>... parameterTypes) {
    Class<?> parentClass = cls.getSuperclass();
    while (parentClass != null) {
      if (Modifier.isPublic(parentClass.getModifiers())) {
        try {
          return parentClass.getMethod(methodName, parameterTypes);
        } catch (final NoSuchMethodException e) {
          return null;
        }
      }
      parentClass = parentClass.getSuperclass();
    }
    return null;
  }
private static Method getAccessibleMethodFromSuperclass ( final Class < ? > cls , final String methodName , final Class < ? > ... parameterTypes ) { Class < ? > parentClass = cls . getSuperclass ( ) ; while ( parentClass != null ) { if ( Modifier . isPublic ( parentClass . getModifiers ( ) ) ) { try { return parentClass . getMethod ( methodName , parameterTypes ) ; } catch ( final NoSuchMethodException e ) { return null ; } } parentClass = parentClass . getSuperclass ( ) ; } return null ; }
Returns an accessible method (that is, one that can be invoked via reflection) by scanning
through the superclasses. If no such method can be found, return {@code null}.

@param cls Class to be checked
@param methodName Method name of the method we wish to call
@param parameterTypes The parameter type signatures
@return the accessible method or {@code null} if not found
Returns an accessible method ( that is one that can be invoked via reflection ) by scanning through the superclasses . If no such method can be found return { @code null } .