code: public static final <T> Field getField(Class<T> cls, String fieldName) {
          try {
              Field f = cls.getDeclaredField(fieldName);
              f.setAccessible(true);
              return f;
          } catch (SecurityException e) {
              throw new RuntimeException(e);
          } catch (NoSuchFieldException e) {
              if (cls.getSuperclass() != null) {
                  return getField(cls.getSuperclass(), fieldName);
              }
              throw new RuntimeException(e);
          }
      }
docs: Gets the field <tt>fieldName</tt> from class <tt>cls</tt>, makes it
  accessible with <tt>Field.setAccessible(true)</tt> and returns it.
  @param <T> The type
  @param cls The class
  @param fieldName The field name
  @return the requested <tt>Field</tt> instance.