[−][src]Struct jni::objects::GlobalRef
A global JVM reference. These are "pinned" by the garbage collector and are
guaranteed to not get collected until released. Thus, this is allowed to
outlive the JNIEnv
that it came from and can be used in other threads.
GlobalRef
can be cloned to use the same global reference in different
contexts. If you want to create yet another global ref to the same java object
you may call JNIEnv#new_global_ref
just like you do when create GlobalRef
from a local reference.
Underlying global reference will be dropped, when the last instance
of GlobalRef
leaves its scope.
It is recommended that a native thread that drops the global reference is attached
to the Java thread (i.e., has an instance of JNIEnv
). If the native thread is not attached,
the GlobalRef#drop
will print a warning and implicitly attach
and detach
it, which
significantly affects performance.
Methods
impl GlobalRef
[src]
pub unsafe fn from_raw(vm: JavaVM, obj: jobject) -> Self
[src]
Creates a new global reference. This assumes that NewGlobalRef
has already been called.
pub fn as_obj(&self) -> JObject
[src]
Get the object from the global ref
This borrows the ref and prevents it from being dropped as long as the JObject sticks around.
Trait Implementations
impl<'a, 'b> Desc<'a, JClass<'b>> for &'b GlobalRef
[src]
This conversion assumes that the GlobalRef
is a pointer to a class object.
impl Sync for GlobalRef
[src]
impl Send for GlobalRef
[src]
impl<'a> From<&'a GlobalRef> for JObject<'a>
[src]
impl Clone for GlobalRef
[src]
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,