Java tutorial
//package com.java2s; import java.lang.reflect.Field; public class Main { public static Object invokeField(Class<?> cls, Object object, String fieldName) throws Exception { Field field = cls.getDeclaredField(fieldName); boolean accessible = field.isAccessible(); try { field.setAccessible(true); return field.get(object); } finally { field.setAccessible(accessible); } } }