staticFieldId

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

Returns the field ID for a static field of a class. The field is specified by its name and signature. The getStatic<type>Field and setStatic<type>Field families of accessor functions use field IDs to retrieve static fields.

staticFieldId causes an uninitialized class to be initialized.

Receiver

a Java class object.

Return

a field ID, or null if the specified static field cannot be found.

Parameters

name

the static 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 static 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.staticFieldId(name: String, sig: String): JFieldID(source)

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

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