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