Here you can find the source of findField(Class> classToCheck, String propertyName)
public static Field findField(Class<?> classToCheck, String propertyName)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { public static Field findField(Class<?> classToCheck, String propertyName) { if (classToCheck == null || Object.class.equals(classToCheck)) { return null; }//from w w w . j a va 2s . c om try { return classToCheck.getDeclaredField(propertyName); } catch (NoSuchFieldException nsfe) { return findField(classToCheck.getSuperclass(), propertyName); } } }