pub struct SharedJNIEnv<'mc> { /* private fields */ }
Expand description

Wrapper struct for JNIEnv that has interior mutability and several other helper functions.

Implementations§

source§

impl<'mc> SharedJNIEnv<'mc>

source

pub fn new(jni: JNIEnv<'mc>) -> Self

source

pub fn define_class<S>( &self, name: S, loader: &JObject<'_>, buf: &[u8] ) -> Result<JClass<'mc>, Error>where S: Into<JNIString>,

source

pub fn define_unnamed_class( &self, loader: &JObject<'_>, buf: &[u8] ) -> Result<JClass<'mc>, Error>

source

pub fn define_class_bytearray<S>( &self, name: S, loader: &JObject<'_>, buf: &AutoElements<'_, '_, '_, jbyte> ) -> Result<JClass<'mc>, Error>where S: Into<JNIString>,

source

pub fn find_class<S>(&self, name: S) -> Result<JClass<'mc>, Error>where S: Into<JNIString>,

source

pub fn get_superclass<'other_local, T>( &self, class: T ) -> Result<Option<JClass<'mc>>, Error>where T: Desc<'mc, JClass<'other_local>>,

source

pub fn is_assignable_from<'other_local_1, 'other_local_2, T, U>( &self, class1: T, class2: U ) -> Result<bool, Error>where T: Desc<'mc, JClass<'other_local_1>>, U: Desc<'mc, JClass<'other_local_2>>,

source

pub fn is_instance_of<'other_local_1, 'other_local_2, O, T>( &self, object: O, class: T ) -> Result<bool, Error>where O: AsRef<JObject<'other_local_1>>, T: Desc<'mc, JClass<'other_local_2>>,

source

pub fn throw<'other_local, E>(&self, obj: E) -> Result<(), Error>where E: Desc<'mc, JThrowable<'other_local>>,

source

pub fn throw_new<'other_local, S, T>( &self, class: T, msg: S ) -> Result<(), Error>where S: Into<JNIString>, T: Desc<'mc, JClass<'other_local>>,

source

pub fn exception_occurred(&self) -> Result<JThrowable<'mc>, Error>

source

pub unsafe fn new_direct_byte_buffer( &self, data: *mut u8, len: usize ) -> Result<JByteBuffer<'mc>, Error>

source

pub fn with_local_frame<F, T, E>(&self, capacity: i32, f: F) -> Result<T, E>where F: FnOnce(&mut JNIEnv<'_>) -> Result<T, E>, E: From<Error>,

source

pub fn with_local_frame_returning_local<F, E>( &self, capacity: i32, f: F ) -> Result<JObject<'mc>, E>where F: for<'new_local> FnOnce(&mut JNIEnv<'new_local>) -> Result<JObject<'new_local>, E>, E: From<Error>,

source

pub fn alloc_object<'other_local, T>( &self, class: T ) -> Result<JObject<'mc>, Error>where T: Desc<'mc, JClass<'other_local>>,

source

pub fn get_method_id<'other_local, T, U, V>( &self, class: T, name: U, sig: V ) -> Result<JMethodID, Error>where T: Desc<'mc, JClass<'other_local>>, U: Into<JNIString>, V: Into<JNIString>,

source

pub fn get_static_method_id<'other_local, T, U, V>( &self, class: T, name: U, sig: V ) -> Result<JStaticMethodID, Error>where T: Desc<'mc, JClass<'other_local>>, U: Into<JNIString>, V: Into<JNIString>,

source

pub fn get_field_id<'other_local, T, U, V>( &self, class: T, name: U, sig: V ) -> Result<JFieldID, Error>where T: Desc<'mc, JClass<'other_local>>, U: Into<JNIString>, V: Into<JNIString>,

source

pub fn get_static_field_id<'other_local, T, U, V>( &self, class: T, name: U, sig: V ) -> Result<JStaticFieldID, Error>where T: Desc<'mc, JClass<'other_local>>, U: Into<JNIString>, V: Into<JNIString>,

source

pub unsafe fn call_static_method_unchecked<'other_local, T, U>( &self, class: T, method_id: U, ret: ReturnType, args: &[jvalue] ) -> Result<JValueOwned<'mc>, Error>where T: Desc<'mc, JClass<'other_local>>, U: Desc<'mc, JStaticMethodID>,

source

pub unsafe fn call_method_unchecked<'other_local, O, T>( &self, obj: O, method_id: T, ret: ReturnType, args: &[jvalue] ) -> Result<JValueOwned<'mc>, Error>where O: AsRef<JObject<'other_local>>, T: Desc<'mc, JMethodID>,

source

pub fn call_method<'other_local, O, S, T>( &self, obj: O, name: S, sig: T, args: Vec<JValueGen<JObject<'mc>>> ) -> Result<JValueOwned<'mc>, Error>where O: AsRef<JObject<'other_local>>, S: Into<JNIString>, T: Into<JNIString> + AsRef<str>,

source

pub fn call_static_method<'other_local, T, U, V>( &self, class: T, name: U, sig: V, args: Vec<JValueGen<JObject<'mc>>> ) -> Result<JValueOwned<'mc>, Error>where T: Desc<'mc, JClass<'other_local>>, U: Into<JNIString>, V: Into<JNIString> + AsRef<str>,

source

pub fn new_object<'other_local, T, U>( &self, class: T, ctor_sig: U, ctor_args: Vec<JValueGen<JObject<'mc>>> ) -> Result<JObject<'mc>, Error>where T: Desc<'mc, JClass<'other_local>>, U: Into<JNIString> + AsRef<str>,

source

pub unsafe fn new_object_unchecked<'other_local, T>( &self, class: T, ctor_id: JMethodID, ctor_args: &[jvalue] ) -> Result<JObject<'mc>, Error>where T: Desc<'mc, JClass<'other_local>>,

source

pub fn get_list<'other_local_1, 'obj_ref>( &self, obj: &'obj_ref JObject<'other_local_1> ) -> Result<JList<'mc, 'other_local_1, 'obj_ref>, Error>where 'other_local_1: 'obj_ref,

source

pub fn get_map<'other_local_1, 'obj_ref>( &self, obj: &'obj_ref JObject<'other_local_1> ) -> Result<JMap<'mc, 'other_local_1, 'obj_ref>, Error>where 'other_local_1: 'obj_ref,

source

pub fn get_string<'other_local: 'obj_ref, 'obj_ref>( &self, obj: &'obj_ref JString<'other_local> ) -> Result<JavaStr<'mc, 'other_local, 'obj_ref>, Error>

source

pub fn new_object_array<'other_local_1, 'other_local_2, T, U>( &self, length: jsize, element_class: T, initial_element: U ) -> Result<JObjectArray<'mc>, Error>where T: Desc<'mc, JClass<'other_local_2>>, U: AsRef<JObject<'other_local_1>>,

source

pub fn get_object_array_element<'other_local>( &self, array: impl AsRef<JObjectArray<'other_local>>, index: jsize ) -> Result<JObject<'mc>, Error>

source

pub fn get_field_unchecked<'other_local, O, T>( &self, obj: O, field: T, ty: ReturnType ) -> Result<JValueOwned<'mc>, Error>where O: AsRef<JObject<'other_local>>, T: Desc<'mc, JFieldID>,

source

pub fn set_field_unchecked<'other_local, O, T>( &self, obj: O, field: T, val: JValue<'_, '_> ) -> Result<(), Error>where O: AsRef<JObject<'other_local>>, T: Desc<'mc, JFieldID>,

source

pub fn get_field<'other_local, O, S, T>( &self, obj: O, name: S, ty: T ) -> Result<JValueOwned<'mc>, Error>where O: AsRef<JObject<'other_local>>, S: Into<JNIString>, T: Into<JNIString> + AsRef<str>,

source

pub fn set_field<'other_local, O, S, T>( &self, obj: O, name: S, ty: T, val: JValue<'_, '_> ) -> Result<(), Error>where O: AsRef<JObject<'other_local>>, S: Into<JNIString>, T: Into<JNIString> + AsRef<str>,

source

pub fn get_static_field_unchecked<'other_local, T, U>( &self, class: T, field: U, ty: JavaType ) -> Result<JValueOwned<'mc>, Error>where T: Desc<'mc, JClass<'other_local>>, U: Desc<'mc, JStaticFieldID>,

source

pub fn get_static_field<'other_local, T, U, V>( &self, class: T, field: U, sig: V ) -> Result<JValueOwned<'mc>, Error>where T: Desc<'mc, JClass<'other_local>>, U: Into<JNIString>, V: Into<JNIString> + AsRef<str>,

source

pub fn set_static_field<'other_local, T, U>( &self, class: T, field: U, value: JValue<'_, '_> ) -> Result<(), Error>where T: Desc<'mc, JClass<'other_local>>, U: Desc<'mc, JStaticFieldID>,

source

pub unsafe fn set_rust_field<'other_local, O, S, T>( &self, obj: O, field: S, rust_object: T ) -> Result<(), Error>where O: AsRef<JObject<'other_local>>, S: AsRef<str>, T: Send + 'static,

source

pub unsafe fn take_rust_field<'other_local, O, S, T>( &self, obj: O, field: S ) -> Result<T, Error>where O: AsRef<JObject<'other_local>>, S: AsRef<str>, T: Send + 'static,

source

pub fn register_native_methods<'other_local, T>( &self, class: T, methods: &[NativeMethod] ) -> Result<(), Error>where T: Desc<'mc, JClass<'other_local>>,

source

pub fn unregister_native_methods<'other_local, T>( &self, class: T ) -> Result<(), Error>where T: Desc<'mc, JClass<'other_local>>,

source

pub unsafe fn get_array_elements<'other_local, 'array, T: TypeArray>( &self, array: &'array JPrimitiveArray<'other_local, T>, mode: ReleaseMode ) -> Result<AutoElements<'mc, 'other_local, 'array, T>, Error>

source

pub fn get_array_length<'other_local, 'array>( &self, array: &'array impl AsJArrayRaw<'other_local> ) -> Result<jsize, Error>

source

pub fn get_raw(&self) -> *mut JNIEnv

source

pub fn get_version(&self) -> Result<JNIVersion, Error>

source

pub fn is_same_object<'other_local_1, 'other_local_2, O, T>( &self, ref1: O, ref2: T ) -> Result<bool, Error>where O: AsRef<JObject<'other_local_1>>, T: AsRef<JObject<'other_local_2>>,

source

pub fn exception_describe(&self) -> Result<(), Error>

source

pub fn exception_clear(&self) -> Result<(), Error>

source

pub fn fatal_error<S: Into<JNIString>>(&self, msg: S) -> !

source

pub fn exception_check(&self) -> Result<bool, Error>

source

pub fn get_direct_buffer_capacity( &self, buf: &JByteBuffer<'_> ) -> Result<usize, Error>

source

pub fn new_global_ref<'other_local, O>( &self, obj: O ) -> Result<GlobalRef, Error>where O: AsRef<JObject<'other_local>>,

source

pub fn new_weak_ref<'other_local, O>( &self, obj: O ) -> Result<Option<WeakRef>, Error>where O: AsRef<JObject<'other_local>>,

source

pub fn new_local_ref<'other_local, O>( &self, obj: O ) -> Result<JObject<'mc>, Error>where O: AsRef<JObject<'other_local>>,

source

pub fn auto_local<O>(&self, obj: O) -> AutoLocal<'mc, O>where O: Into<JObject<'mc>>,

source

pub fn push_local_frame(&self, capacity: i32) -> Result<(), Error>

source

pub fn get_object_class<'other_local, O>( &self, obj: O ) -> Result<JClass<'_>, Error>where O: AsRef<JObject<'other_local>>,

source

pub fn new_string<S: Into<JNIString>>( &self, from: S ) -> Result<JString<'mc>, Error>

source

pub fn set_object_array_element<'other_local_1, 'other_local_2>( &self, array: impl AsRef<JObjectArray<'other_local_1>>, index: jsize, value: impl AsRef<JObject<'other_local_2>> ) -> Result<(), Error>

source

pub fn byte_array_from_slice( &self, buf: &[u8] ) -> Result<JByteArray<'mc>, Error>

source

pub fn convert_byte_array<'other_local>( &self, array: impl AsRef<JByteArray<'other_local>> ) -> Result<Vec<u8>, Error>

source

pub fn new_boolean_array( &self, length: jsize ) -> Result<JBooleanArray<'mc>, Error>

source

pub fn new_byte_array(&self, length: jsize) -> Result<JByteArray<'mc>, Error>

source

pub fn new_char_array(&self, length: jsize) -> Result<JCharArray<'mc>, Error>

source

pub fn new_short_array(&self, length: jsize) -> Result<JShortArray<'mc>, Error>

source

pub fn new_int_array(&self, length: jsize) -> Result<JIntArray<'mc>, Error>

source

pub fn new_long_array(&self, length: jsize) -> Result<JLongArray<'mc>, Error>

source

pub fn new_float_array(&self, length: jsize) -> Result<JFloatArray<'mc>, Error>

source

pub fn new_double_array( &self, length: jsize ) -> Result<JDoubleArray<'mc>, Error>

source

pub fn get_boolean_array_region<'other_local>( &self, array: impl AsRef<JBooleanArray<'other_local>>, start: jsize, buf: &mut [jboolean] ) -> Result<(), Error>

source

pub fn get_byte_array_region<'other_local>( &self, array: impl AsRef<JByteArray<'other_local>>, start: jsize, buf: &mut [jbyte] ) -> Result<(), Error>

source

pub fn get_char_array_region<'other_local>( &self, array: impl AsRef<JCharArray<'other_local>>, start: jsize, buf: &mut [jchar] ) -> Result<(), Error>

source

pub fn get_short_array_region<'other_local>( &self, array: impl AsRef<JShortArray<'other_local>>, start: jsize, buf: &mut [jshort] ) -> Result<(), Error>

source

pub fn get_int_array_region<'other_local>( &self, array: impl AsRef<JIntArray<'other_local>>, start: jsize, buf: &mut [jint] ) -> Result<(), Error>

source

pub fn get_long_array_region<'other_local>( &self, array: impl AsRef<JLongArray<'other_local>>, start: jsize, buf: &mut [jlong] ) -> Result<(), Error>

source

pub fn get_float_array_region<'other_local>( &self, array: impl AsRef<JFloatArray<'other_local>>, start: jsize, buf: &mut [jfloat] ) -> Result<(), Error>

source

pub fn get_double_array_region<'other_local>( &self, array: impl AsRef<JDoubleArray<'other_local>>, start: jsize, buf: &mut [jdouble] ) -> Result<(), Error>

source

pub fn set_boolean_array_region<'other_local>( &self, array: impl AsRef<JBooleanArray<'other_local>>, start: jsize, buf: &[jboolean] ) -> Result<(), Error>

source

pub fn set_byte_array_region<'other_local>( &self, array: impl AsRef<JByteArray<'other_local>>, start: jsize, buf: &[jbyte] ) -> Result<(), Error>

source

pub fn set_char_array_region<'other_local>( &self, array: impl AsRef<JCharArray<'other_local>>, start: jsize, buf: &[jchar] ) -> Result<(), Error>

source

pub fn set_short_array_region<'other_local>( &self, array: impl AsRef<JShortArray<'other_local>>, start: jsize, buf: &[jshort] ) -> Result<(), Error>

source

pub fn set_int_array_region<'other_local>( &self, array: impl AsRef<JIntArray<'other_local>>, start: jsize, buf: &[jint] ) -> Result<(), Error>

source

pub fn set_long_array_region<'other_local>( &self, array: impl AsRef<JLongArray<'other_local>>, start: jsize, buf: &[jlong] ) -> Result<(), Error>

source

pub fn set_float_array_region<'other_local>( &self, array: impl AsRef<JFloatArray<'other_local>>, start: jsize, buf: &[jfloat] ) -> Result<(), Error>

source

pub fn set_double_array_region<'other_local>( &self, array: impl AsRef<JDoubleArray<'other_local>>, start: jsize, buf: &[jdouble] ) -> Result<(), Error>

source

pub fn lock_obj<'other_local, O>( &self, obj: O ) -> Result<MonitorGuard<'mc>, Error>where O: AsRef<JObject<'other_local>>,

source

pub fn get_native_interface(&self) -> *mut JNIEnv

source

pub fn get_java_vm(&self) -> Result<JavaVM, Error>

source

pub fn ensure_local_capacity(&self, capacity: jint) -> Result<(), Error>

source

pub fn translate_error<T>( &self, res: Result<JValueGen<T>, Error> ) -> Result<JValueGen<T>, Box<dyn Error>>where T: Into<JObject<'mc>>,

source

pub fn translate_error_with_class( &self, res: Result<JClass<'mc>, Error> ) -> Result<JClass<'_>, Box<dyn Error>>

source

pub fn translate_error_no_gen<T>( &self, res: Result<T, Error> ) -> Result<T, Box<dyn Error>>where T: Into<JObject<'mc>>,

source

pub fn validate_name<O>( &self, obj: O, expected_class: &str ) -> Result<(bool, String), Box<dyn Error>>where O: AsRef<JObject<'mc>>,

Trait Implementations§

source§

impl<'mc> Clone for SharedJNIEnv<'mc>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'mc> !RefUnwindSafe for SharedJNIEnv<'mc>

§

impl<'mc> !Send for SharedJNIEnv<'mc>

§

impl<'mc> !Sync for SharedJNIEnv<'mc>

§

impl<'mc> Unpin for SharedJNIEnv<'mc>

§

impl<'mc> UnwindSafe for SharedJNIEnv<'mc>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.