Returns all fields of any visibility on type and all of type's superclasses.
Aka {@link Class#getFields()}, but returns all fields, not just public ones.
960512
private static Collection<Field> getAllFields(Class<?> type) {
    final Collection<Field> allFields = new ArrayList<>();

    while (type != Object.class) {
      Collections.addAll(allFields, type.getDeclaredFields());
      type = type.getSuperclass();
    }

    return Collections.unmodifiableCollection(allFields);
  }
1245678
private static Field[] getBurstableFields(Class<?> cls) {
    final List<Field> fields = new ArrayList<>();

    for (Field field : getAllFields(cls)) {
      if (field.isAnnotationPresent(Burst.class)) {

        if (Modifier.isStatic(field.getModifiers())) {
          throw new IllegalStateException("Burstable field must not be static: " + field.getName());
        }

        if (Modifier.isFinal(field.getModifiers())) {
          throw new IllegalStateException("Burstable field must not be final: " + field.getName());
        }

        fields.add(field);
      }
    }

    return fields.toArray(new Field[fields.size()]);
  }
184125
public static List<Field> findFields(final Class<?> clazz) {
        List<Field> foundFields = new ArrayList<>();
        Class<?> searchType = clazz;
        while (!Object.class.equals(searchType) && (searchType != null)) {
            Field[] fields = searchType.getDeclaredFields();
            for (Field field : fields) {
                field.setAccessible(true);
                foundFields.add(field);
            }
            searchType = searchType.getSuperclass();
        }
        return foundFields;
    }
890897
private static List<Field> findFields() {
        List<Field> result = new ArrayList<Field>();
        for (Field f : LoadStatistics.class.getFields()) {
            if (Modifier.isPublic(f.getModifiers()) && MultiStageTimeSeries.class.isAssignableFrom(f.getType())
                    && f.getAnnotation(Deprecated.class) == null) {
                result.add(f);
            }
        }
        return result;
    }
1210343
public static Field[] getDeclaredFieldsInHierarchy(Class<?> clazz) {

        if (clazz.isPrimitive()) {
            throw new IllegalArgumentException("Primitive types not supported.");
        }

        List<Field> result = new ArrayList<Field>();

        while (true) {

            if (clazz == Object.class) {
                break;
            }

            result.addAll(Arrays.asList(clazz.getDeclaredFields()));
            clazz = clazz.getSuperclass();
        }

        return result.toArray(new Field[result.size()]);
    }
898729
public static Field getField(String fieldName, Class<?> clazz) {
    Field field = null;
    try {
      field = clazz.getDeclaredField(fieldName);
    }
    catch (SecurityException e) {
      throw LOG.unableToAccessField(field, clazz.getName());
    }
    catch (NoSuchFieldException e) {
      // for some reason getDeclaredFields doesnt search superclasses
      // (which getFields() does ... but that gives only public fields)
      Class<?> superClass = clazz.getSuperclass();
      if (superClass != null) {
        return getField(fieldName, superClass);
      }
    }
    return field;
  }
429734
@Override
  public final Field[] retrieveFields(final Class<?> clazz) {
    Set<Field> fieldsSet = new HashSet<Field>();
    for (Field fld : clazz.getDeclaredFields()) {
      int modifiersMask = fld.getModifiers();
      if ((modifiersMask & Modifier.PRIVATE) > 0
            && (modifiersMask & Modifier.STATIC) == 0) {
        fieldsSet.add(fld);
      }
    }
    final Class<?> superClazz = clazz.getSuperclass();
    if (superClazz != null && superClazz != java.lang.Object.class) {
      for (Field fld : retrieveFields(superClazz)) {
        fieldsSet.add(fld);
      }
    }
    return fieldsSet.toArray(new Field[fieldsSet.size()]);
  }
1028443
public static InstanceFields allDeclaredFieldsOf(Object instance) {
        List<InstanceField> instanceFields = new ArrayList<InstanceField>();
        for (Class<?> clazz = instance.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
            instanceFields.addAll(instanceFieldsIn(instance, clazz.getDeclaredFields()));
        }
        return new InstanceFields(instance, instanceFields);
    }
231184
public static List<Field> getInstanceFields(Class type) {
        List<Field> fields = Lists.newArrayList(type.getDeclaredFields());
        return ImmutableList.copyOf(Iterables.filter(fields, InstanceFieldPredicate.PREDICATE));
    }
756066
private static Field[] getAllFieldsRec(Class clazz, List<Field> fields) {
        Class superClazz = clazz.getSuperclass();
        if (superClazz != null) {
            getAllFieldsRec(superClazz, fields);
        }

        fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
        return fields.toArray(new Field[fields.size()]);
    }
622588
public static void getFields (Class<?> clazz, List<Field> addTo)
    {
        // first get the fields of the superclass
        Class<?> pclazz = clazz.getSuperclass();
        if (pclazz != null && !pclazz.equals(Object.class)) {
            getFields(pclazz, addTo);
        }

        // then reflect on this class's declared fields
        Field[] fields;
        try {
            fields = clazz.getDeclaredFields();
        } catch (SecurityException se) {
            System.err.println("Unable to get declared fields of " + clazz.getName() + ": " + se);
            fields = new Field[0];
        }

        // override the default accessibility check for the fields
        try {
            AccessibleObject.setAccessible(fields, true);
        } catch (SecurityException se) {
            // ah well, only publics for us
        }

        for (Field field : fields) {
            int mods = field.getModifiers();
            if (Modifier.isStatic(mods) || Modifier.isTransient(mods)) {
                continue; // skip static and transient fields
            }
            addTo.add(field);
        }
    }
1087526
private List<Field> getFields(Class given) {
		Field[] fs = given.getDeclaredFields();
		return new ArrayList<>(Arrays.asList(fs));
	}
651278
public Set<VisibleField> getVisibleNeighbours() {
        return getNeighbours().stream()
                .filter(Field::isVisible)
                .map(Field::asVisibleField)
                .collect(Collectors.toSet());
    }
1167855
public static Field[] getFields(Class<?> c) {
		Field[] allFields = c.getDeclaredFields();
		Field[] fields = new Field[allFields.length];
		int n = 0;
		for(Field f : allFields) {
			f.setAccessible(true);
			IgnoreField anno = f.getAnnotation(IgnoreField.class);
			if(anno == null) {
				fields[n] = f;
				n++;
			}
		}
		return Arrays.copyOf(fields, n);
	}
1059967
public static <T> List<Field> getAnnotatedFields(Object object, Class<? extends Annotation> annotationClass) {
		return getAnnotatedFields(object.getClass(), annotationClass);
	}
43693
public static List<Field> getDeclaredFields(@NonNull Class<?> clazz, boolean recursive) {
      List<Field> fields = new ArrayList<>();
      do {
         fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
         clazz = clazz.getSuperclass();
      } while (recursive && clazz != null && clazz != Object.class);
      return fields;
   }
454300
private List<Field> getAllFields(List<Field> fields, Class<?> clazz) {
    // TODO consider caching the results of this.
    checkNotNull(fields);
    checkNotNull(clazz);

    fields.addAll(Arrays.asList(clazz.getDeclaredFields()));

    if (clazz.getSuperclass() != null) {
      getAllFields(fields, clazz.getSuperclass());
    }

    return Collections.unmodifiableList(fields);
  }