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