Find field 2
import java.lang.reflect.Field; public class Util{ /** * @param clz * @param expression * @return introspected field */ public static Field findField(Class<?> clz, String expression) { Field field = null; try { field = clz.getField(expression); } catch (Exception e) { Class<?> tmp = clz; while(tmp != null && tmp != Object.class) { Field[] fields = tmp.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { if(fields[i].getName().equals(expression)) { fields[i].setAccessible(true); return fields[i]; } } tmp = tmp.getSuperclass(); } } return field; } }