fieldId

context(env: JniEnv, autofreeScope: AutofreeScope)
fun JClass.fieldId(name: CValuesRef<ByteVar>, sig: CValuesRef<ByteVar>): JFieldID?(source)

Returns the field ID for an instance (nonstatic) field of a class. The field is specified by its name and signature. The get<type>Field and set<type>Field families of accessor functions use field IDs to retrieve object fields.

fieldId causes an uninitialized class to be initialized.

fieldId cannot be used to get the length field of an array. Use JArray.length instead.

Return

a field ID, or null if the operation fails.

Parameters

this

@GetFieldID a Java class object.

name

the field name in the null-terminated modified UTF-8.

sig

the field signature in the null-terminated modified UTF-8. Use String.modifiedUtf8 to get it, or if you are sure that your string doesn't have illegal characters you may use optimized String.utf8.

Throws

NoSuchFieldError

if the specified field cannot be found.

ExceptionInInitializerError

if the class initializer fails due to an exception.

if the system runs out of memory.


context(env: JniEnv, autofreeScope: AutofreeScope)
inline fun JClass.fieldId(name: String, sig: String): JFieldID(source)

Alias for JClass.fieldId which accepts the field name and sig as Kotlin Strings.

Throws instead of returning null if the field cannot be found.