setFinalField

open fun setFinalField(@Nullable instance: Any, @NonNull fieldName: String, @Nullable v: Any)

Override a final field of a class. WARNING: If this field is of a primitive type, setting it may have no effect as the compiler will inline final primitives. Please note that this does not cache the lookup result, so if you need to call this many times you should do it manually and cache the Field to improve performance drastically

Parameters

instance

Instance of the clazz or null to set static field.

fieldName

Name of the field.

v

Value to store.

Throws

If the field doesn't exist.

If the field is inaccessible. Shouldn't happen.


open fun setFinalField(@NonNull clazz: Class<out Any>, @Nullable instance: Any, @NonNull fieldName: String, @Nullable v: Any)

Override a final field of a class. WARNING: If this field is of a primitive type, setting it may have no effect as the compiler will inline final primitives. Please note that this does not cache the lookup result, so if you need to call this many times you should do it manually and cache the Field to improve performance drastically

Parameters

clazz

Class where the field is located.

instance

Instance of the clazz or null to set static field.

fieldName

Name of the field.

v

Value to store.

Throws

If the field doesn't exist.

If the field is inaccessible. Shouldn't happen.