Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Field getDeclaredField(Object object, String fieldName) { Class<?> clz = object.getClass(); for (; clz != Object.class; clz = clz.getSuperclass()) { try { Field field = clz.getDeclaredField(fieldName); return field; } catch (Exception e) { } } return null; } }