pub struct AutoLocal<'a: 'b, 'b> { /* private fields */ }
Expand description
Auto-delete wrapper for local refs.
Anything passed to a foreign method and returned from JNI methods is considered a local ref unless it is specified otherwise. These refs are automatically deleted once the foreign method exits, but it’s possible that they may reach the JVM-imposed limit before that happens.
This wrapper provides automatic local ref deletion when it goes out of scope.
NOTE: This comes with some potential safety risks. DO NOT use this to wrap something unless you’re SURE it won’t be used after this wrapper gets dropped. Otherwise, you’ll get a nasty JVM crash.
See also the JNI specification for details on referencing Java objects and some extra information.
Implementations
sourceimpl<'a, 'b> AutoLocal<'a, 'b>
impl<'a, 'b> AutoLocal<'a, 'b>
sourcepub fn new(env: &'b JNIEnv<'a>, obj: JObject<'a>) -> Self
pub fn new(env: &'b JNIEnv<'a>, obj: JObject<'a>) -> Self
Creates a new auto-delete wrapper for a local ref.
Once this wrapper goes out of scope, the delete_local_ref
will be
called on the object. While wrapped, the object can be accessed via
the Deref
impl.
Trait Implementations
sourceimpl<'a, 'b, 'c> Desc<'a, JClass<'b>> for &'b AutoLocal<'c, '_> where
'c: 'b,
impl<'a, 'b, 'c> Desc<'a, JClass<'b>> for &'b AutoLocal<'c, '_> where
'c: 'b,
This conversion assumes that the AutoLocal
is a pointer to a class object.
Auto Trait Implementations
impl<'a, 'b> RefUnwindSafe for AutoLocal<'a, 'b>
impl<'a, 'b> !Send for AutoLocal<'a, 'b>
impl<'a, 'b> !Sync for AutoLocal<'a, 'b>
impl<'a, 'b> Unpin for AutoLocal<'a, 'b> where
'a: 'b,
impl<'a, 'b> UnwindSafe for AutoLocal<'a, 'b>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more