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