Spring has a nice Utility class ReflectionUtils that does just that: it defines a method to loop over all fields of all super classes with a callback: ReflectionUtils.doWithFields()
Documentation:Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.
- clazz - the target class to analyze
- fc - the callback to invoke for each field
- ff - the filter that determines the fields to apply the callback to
Found field private int java.util.ArrayList.size in type class java.util.ArrayList