public Object getField ( Object o , String fieldName ) throws NoSuchFieldException , IllegalAccessException { Field field = o . getClass ( ) . getDeclaredField ( fieldName ) ; field . setAccessible ( true ) ; return field . get ( o ) ; }
Gets the specified field on Object o even if that field is not normally accessible . Only fields declared on the class for Object o can be accessed .