code: public static void setFieldValue(Field field, Object obj, Object value) {
      if (Modifier.isFinal(field.getModifiers())) {
        Object finalValue = getFieldValue(field, obj);
        if (value == null ? finalValue != null : !value.equals(finalValue)) {
          throw new IllegalArgumentException(
              "expected final value <"
                  + finalValue
                  + "> but was <"
                  + value
                  + "> on "
                  + field.getName()
                  + " field in "
                  + obj.getClass().getName());
        }
      } else {
        try {
          field.set(obj, value);
        } catch (SecurityException e) {
          throw new IllegalArgumentException(e);
        } catch (IllegalAccessException e) {
          throw new IllegalArgumentException(e);
        }
      }
    }
docs: Sets the given field in the given object to the given value using reflection.
  
  <p>If the field is final, it checks that the value being set is identical to the existing
  value.