newWeakGlobalRef

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

Creates a new weak global reference. The weak global reference will not prevent garbage collection of the given object.

isSame may be used to test if the object referred to by the reference has been freed.

May return null if:

  • the system has run out of memory

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

Since

JDK/JRE 1.2

Throws

if the system runs out of memory.