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