Here you can find the source of findField(final Class> klaz, final String fieldName)
public static Field findField(final Class<?> klaz, final String fieldName)
//package com.java2s; /**// w w w . j ava 2 s . c om * Copyright (C) 2010-2013 Andrei Pozolotin <Andrei.Pozolotin@gmail.com> * * All rights reserved. Licensed under the OSI BSD License. * * http://www.opensource.org/licenses/bsd-license.php */ import java.lang.reflect.Field; public class Main { public static Field findField(final Class<?> klaz, final String fieldName) { Class<?> type = klaz; do { for (final Field field : type.getDeclaredFields()) { final String name = field.getName(); if (!name.equals(fieldName)) { continue; } field.setAccessible(true); return field; } type = type.getSuperclass(); } while (klaz != null); return null; } }