Here you can find the source of findField(Class> clazz, String fieldName)
public static Field findField(Class<?> clazz, String fieldName) throws NoSuchFieldException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; public class Main { public static Field findField(Class<?> clazz, String fieldName) throws NoSuchFieldException { Class<?> current = clazz; do {//w w w .j av a 2 s . co m try { return current.getDeclaredField(fieldName); } catch (Exception e) { } } while ((current = current.getSuperclass()) != null); throw new NoSuchFieldException(fieldName); } }