public static void setField(Object object, Field fld, Object value) {
    try {
      fld.setAccessible(true);
      fld.set(object, value);
    } catch (IllegalAccessException e) {
      String fieldName = null == fld ? "n/a" : fld.getName();
      throw new RuntimeException("Failed to set " + fieldName + " of object", e);
    }
  }
Sets a declared field in a given object.
Note: if you want to modify a field in a super class, use the {@link ReflectionUtil#setInAllFields } method.
@param object target instance
@param field name of the field to set
@param value new value
@throws RuntimeException in case the field is not found or cannot be set.
common/src/java/org/apache/hive/common/util/ReflectionUtil.java