public static void setStaticFinalFieldsModifiable(Field field) {
    try {
      field.setAccessible(true);
      VarHandle modifiersHandle = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup())
              .findVarHandle(Field.class, "modifiers", int.class);
      int modifiers = field.getModifiers();
      modifiersHandle.set(field, modifiers & ~Modifier.FINAL);
    } catch (NoSuchFieldException | IllegalAccessException e) {
      throw new RuntimeException("Cannot make static final field %s modifiable".formatted(field));
    }
  }
Sets a declared field in a given object. It finds the field, even if it is declared in a super class.
@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