code: public static Field[] getDeclaredAndInheritedFields(final Class type, final boolean returnFinalFields) {
          final List<Field> allFields = new ArrayList<Field>();
          allFields.addAll(getValidFields(type.getDeclaredFields(), returnFinalFields));
          Class parent = type.getSuperclass();
          while ((parent != null) && (parent != Object.class)) {
              allFields.addAll(getValidFields(parent.getDeclaredFields(), returnFinalFields));
              parent = parent.getSuperclass();
          }
          return allFields.toArray(new Field[allFields.size()]);
      }
docs: Get an array of all fields declared in the supplied class, and all its superclasses (except java.lang.Object).
  
  @param type              the class for which we want to retrieve the Fields
  @param returnFinalFields specifies whether to return final fields
  @return an array of all declared and inherited fields