code: public static Field[] getMatchingFields(Class<?> clazz, final int modifiers) {
          final Set<Field> fields = new TreeSet<Field>(
                  FIELD_NAME_AND_DECLARING_CLASS_COMPARATOR);
          traverseHierarchy(clazz, new TraverseTask<Field>() {
  
              @Override
              public Field run(Class<?> clazz) {
                  Field[] fieldArray = clazz.getDeclaredFields();
                  for (int i = 0; i < fieldArray.length; i++) {
                      if ((modifiers & fieldArray[i].getModifiers()) != 0) {
                          fields.add(fieldArray[i]);
                      }
                  }
                  return null;
              }
          });
  
          return fields.toArray(new Field[fields.size()]);
      }
docs: Returns the field objects that are declared in the given class or any of
  it's super types that have any of the given modifiers. The type hierarchy
  is traversed upwards and all declared fields that match the given
  modifiers are added to the result array. The elements in the array are
  sorted by their names and declaring classes.
  
  @param clazz     The class within to look for the fields with the given
  modifiers
  @param modifiers The OR-ed together modifiers that a field must match to be
  included into the result
  @return The array of fields that match the modifiers and are within the
  type hierarchy of the given class