newGlobalRef

context(env: JniEnv)
fun <T : JRef<O>, O : _jobject> T.newGlobalRef(): T?(source)

Creates and returns a new global reference to the object referred to by the receiver. The receiver may be a global or local reference.

Global references must be explicitly disposed of by calling deleteGlobalRef.

May return null if:

  • the system has run out of memory

  • the receiver was a weak global reference and has already been garbage collected.

Throws

if the system runs out of memory.