Java tutorial
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { @SuppressWarnings("rawtypes") public static Object getFieldObject(Object target, Class clazz, String fieldName) { try { Field field = clazz.getDeclaredField(fieldName); if (!field.isAccessible()) { field.setAccessible(true); } return field.get(target); } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; } }