public static void setField ( Object obj , Field field , Object value ) { boolean accessible = field . isAccessible ( ) ; //hack accessibility if ( ! accessible ) { field . setAccessible ( true ) ; } try { field . set ( obj , value ) ; } catch ( IllegalAccessException e ) { //ignore should not happen as accessibility has been updated to suit assignment e . printStackTrace ( ) ; // $COVERAGE-IGNORE$ } //restore accessibility field . setAccessible ( accessible ) ; }
Sets value to the field of the given object .