Here you can find the source of findField(Class> clazz, String name)
private static Field findField(Class<?> clazz, String name)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { private static Field findField(Class<?> clazz, String name) { Class<?> searchType = clazz; while (!Object.class.equals(searchType) && searchType != null) { Field[] fields = searchType.getDeclaredFields(); for (Field field : fields) { if ((name == null || name.equals(field.getName()))) { return field; }//from www.j a v a 2 s .c o m } searchType = searchType.getSuperclass(); } return null; } }