public static Field getDeclaredField(Class clazz, String fieldName)
          throws NoSuchFieldException {
    Field f = getField(clazz, fieldName);
    if (f == null) {
      // Try the parent class
      Class parent = clazz.getSuperclass();
      if (parent != null) {
        return getDeclaredField(parent, fieldName);
      } else {
        throw new NoSuchFieldException("The field '" + fieldName + "' could not be "
                                       + "found in the class of any of its parent "
                                       + "classes.");
      }
    } else {
      return f;
    }
  }
public static Field getDeclaredField(Class clazz, String fieldName)
          throws NoSuchFieldException {
    Field f = getField(clazz, fieldName);
    if (f == null) {
      
      Class parent = clazz.getSuperclass();
      if (parent != null) {
        return getDeclaredField(parent, fieldName);
      } else {
        throw new NoSuchFieldException("The field '" + fieldName + "' could not be "
                                       + "found in the class of any of its parent "
                                       + "classes.");
      }
    } else {
      return f;
    }
  }
public static Field getDeclaredField ( Class clazz , String fieldName ) throws NoSuchFieldException { Field f = getField ( clazz , fieldName ) ; if ( f == null ) { // Try the parent class Class parent = clazz . getSuperclass ( ) ; if ( parent != null ) { return getDeclaredField ( parent , fieldName ) ; } else { throw new NoSuchFieldException ( "The field '" + fieldName + "' could not be " + "found in the class of any of its parent " + "classes." ) ; } } else { return f ; } }
Recursively searches for the field specified by the fieldName in the class and all
the super classes until it either finds it, or runs out of parents.
@param clazz The Class to start searching from.
@param fieldName The name of the field to retrieve.
@return The {@link Field} identified by the field name.
@throws NoSuchFieldException If the field was not found in the class or any of its
super classes.
Recursively searches for the field specified by the fieldName in the class and all the super classes until it either finds it or runs out of parents .