Here you can find the source of findField(Class> cls, String fieldName)
public static Field findField(Class<?> cls, String fieldName)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { public static Field findField(Class<?> cls, String fieldName) { Field f = null;/* www.j a va 2s . co m*/ try { f = cls.getDeclaredField(fieldName); } catch (SecurityException ex) { } catch (NoSuchFieldException ex) { } if (f != null) return f; if (cls == Object.class || cls.getSuperclass() == null) { return null; } return findField(cls.getSuperclass(), fieldName); } }