public static Object getFieldValue ( Object object , String fieldName ) { try { return getDeclaredFieldInHierarchy ( object . getClass ( ) , fieldName ) . get ( object ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } }
Convenience method for getting the value of a private object field without the stress of checked exceptions in the reflection API .