Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; public class Main { public static Field getField(Class<?> klass, String member) throws NoSuchFieldException { try { return klass.getDeclaredField(member); } catch (NoSuchFieldException e) { if (klass.getSuperclass() != null) return getField(klass.getSuperclass(), member); else throw new NoSuchFieldException(String.format("Class does not contain member %s!", member)); } } }