public static void setField(Object object, String field, Object value) {
    try {
      Field fieldToChange = object.getClass().getDeclaredField(field);
      setField(object, fieldToChange, value);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException("Cannot find field %s in object %s".formatted(field, object.getClass()));
    }
  }
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