ReflectionHelper { List<Field> getFields(Class<?> clazz) { List<Field> result = new ArrayList<>(); Set<String> fieldNames = new HashSet<>(); Class<?> searchType = clazz; while (!Object.class.equals(searchType) && searchType != null) { Field[] fields = searchType.getDeclaredFields(); for (Field field : fields) { if (!fieldNames.contains(field.getName())) { fieldNames.add(field.getName()); makeAccessible(field); result.add(field); } } searchType = searchType.getSuperclass(); } return result; }  T newInstance(Class<T> clazz); T newInstance(String className);  }
@Test public void testGetFields() throws Exception { List<Field> fields = reflectionHelper.getFields(SimpleExtendedDomain.class); assertThat(fields).hasSize(4). extracting("name").contains("a", "b", "c", "i"); }