spring-framework / org.springframework.util / ReflectionUtils / setField

setField

open static fun setField(field: Field, @Nullable target: Any, @Nullable value: Any): Unit

Set the field represented by the supplied Field on the specified Object to the specified value. In accordance with Field#set(Object, Object) semantics, the new value is automatically unwrapped if the underlying field has a primitive type.

Thrown exceptions are handled via a call to #handleReflectionException(Exception).

Parameters

field - the field to set

target - the target object on which to set the field

value - the value to set (may be null)