JavaRef class

A handle to a Java object.

Use-after-release throws a JniError rather than passing a dangling pointer to the VM, which would be an undebuggable crash.

Constructors

JavaRef(Jvm jvm, Pointer<Void> pointer, JavaRefKind kind)

Properties

hashCode int
The hash code for this object.
no setterinherited
isNull bool
true when this handle wraps Java null.
no setter
isReleased bool
true once release has run.
no setter
jvm Jvm
final
kind JavaRefKind
Whether this handle owns a local or a global reference.
final
pointer Pointer<Void>
The raw jobject.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

isSameObject(JavaRef other) bool
true when both handles refer to the same Java object (or both are null). Reference identity, i.e. Java's ==, not equals.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release() → void
Releases the underlying reference. Idempotent, and safe on a null ref.
toGlobal() JavaRef
Promotes this reference to a global one, which survives the current thread and frame.
toLocal() JavaRef
Creates a new local reference to the same object.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited