Skip to content

setReflection

@JvmName
(name = "setReflectionExtension")inline fun <T, R> T.setReflection(field: String, value: R)

Extension form of setReflection; writes field (searching up the class hierarchy) on this instance.

inline fun <T, R> setReflection(
    instance: T, 
    field: String, 
    value: R
)

Writes value to a private/inaccessible declared field named field on instance via reflection, searching T and its superclasses.

Throws

NoSuchFieldException

if no field named field is found anywhere in the hierarchy.