ReflectionUtils { public static List<Field> getDeclaredFieldsIncludingInherited(Class<?> clazz) { List<Field> fields = new ArrayList<Field>(); while (clazz != null) { for (Field field : clazz.getDeclaredFields()) { fields.add(field); } clazz = clazz.getSuperclass(); } return fields; }  static void setConf(Object theObject, Configuration conf); @SuppressWarnings("unchecked") static T newInstance(Class<T> theClass, Configuration conf); static void setContentionTracing(boolean val); synchronized static void printThreadInfo(PrintStream stream,
                                     String title); static void logThreadInfo(Log log,
                                   String title,
                                   long minInterval); @SuppressWarnings("unchecked") static Class<T> getClass(T o); @SuppressWarnings("unchecked") static T copy(Configuration conf, 
                                T src, T dst); @Deprecated static void cloneWritableInto(Writable dst, 
                                       Writable src); static List<Field> getDeclaredFieldsIncludingInherited(Class<?> clazz); static List<Method> getDeclaredMethodsIncludingInherited(Class<?> clazz);  }
@Test public void testGetDeclaredFieldsIncludingInherited() { Parent child = new Parent() { private int childField; @SuppressWarnings("unused") public int getChildField() { return childField; } }; List<Field> fields = ReflectionUtils.getDeclaredFieldsIncludingInherited( child.getClass()); boolean containsParentField = false; boolean containsChildField = false; for (Field field : fields) { if (field.getName().equals("parentField")) { containsParentField = true; } else if (field.getName().equals("childField")) { containsChildField = true; } } List<Method> methods = ReflectionUtils.getDeclaredMethodsIncludingInherited( child.getClass()); boolean containsParentMethod = false; boolean containsChildMethod = false; for (Method method : methods) { if (method.getName().equals("getParentField")) { containsParentMethod = true; } else if (method.getName().equals("getChildField")) { containsChildMethod = true; } } assertTrue("Missing parent field", containsParentField); assertTrue("Missing child field", containsChildField); assertTrue("Missing parent method", containsParentMethod); assertTrue("Missing child method", containsChildMethod); }