public static Object getValue ( Object instance , String fieldName ) { Field f = findFieldRecursively ( instance . getClass ( ) , fieldName ) ; if ( f == null ) throw new CacheException ( "Could not find field named '" + fieldName + "' on instance " + instance ) ; try { f . setAccessible ( true ) ; return f . get ( instance ) ; } catch ( IllegalAccessException iae ) { throw new CacheException ( "Cannot access field " + f , iae ) ; } }
Retrieves the value of a field of an object instance via reflection