Here you can find the source of findFieldRecursively(Class> c, String fieldName)
private static Field findFieldRecursively(Class<?> c, String fieldName)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; public class Main { private static Field findFieldRecursively(Class<?> c, String fieldName) { Field f = null;//from w w w . j a va2 s. com try { f = c.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { if (!c.equals(Object.class)) f = findFieldRecursively(c.getSuperclass(), fieldName); } return f; } }