pub struct Global<T: ReferenceType> { /* private fields */ }Expand description
A Global, non-null, reference to a Java object (+ VM).
Unlike Local, this can be stored statically and shared between threads. This has a few caveats:
Not FFI Safe: #[repr(rust)], and exact layout is likely to change - depending on exact features used - in the
future. Specifically, on Android, since we’re guaranteed to only have a single ambient VM, we can likely store the
*const JavaVM in static and/or thread local storage instead of lugging it around in every Global. Of course, there’s
no guarantee that’s actually an optimization…
Implementations§
Source§impl<T: ReferenceType> Global<T>
impl<T: ReferenceType> Global<T>
Sourcepub unsafe fn from_raw(vm: VM, object: jobject) -> Self
pub unsafe fn from_raw(vm: VM, object: jobject) -> Self
Wraps an owned raw JNI global reference, taking the ownership.
§Safety
object must be an owned non-null JNI global reference to an object of type T,
not to be deleted by another wrapper.
Sourcepub fn into_raw(self) -> jobject
pub fn into_raw(self) -> jobject
Leaks the Global and turns it into a raw pointer, preserving the ownership of
one JNI global reference; prevents DeleteGlobalRef from being called on dropping.