pub struct JObject<'local> { /* private fields */ }Expand description
A java.lang.Object reference, tied to a JNI local reference frame.
This is a #[repr(transparent)] wrapper around a jobject JNI reference.
Since it is #[repr(transparent)], it can be used to capture references
passed to native methods while also associating them with a local reference
frame lifetime for the method call.
§Casting
Most other types in the objects module implement Into<JObject> or
AsRef<JObject> to allow easy upcasting to JObject.
For downcasting (i.e converting to a more specific type), with runtime checks, use one of these APIs:
or look for a cast_local API like JString::cast_local.
§Local Reference Frame Lifetime
The lifetime 'local represents the local reference frame that this
reference belongs to. See the Env documentation for more information
about local reference frames.
The lifetime may be 'static if the reference has a Global or Weak
wrapper that indicates that the reference is global or weak (i.e it does not
belong to a local reference frame).
Note that an owned JObject is always a local reference and will never
have the 'static lifetime. Global does implement
AsRef<JObject<’static>>, but this only yields a
borrowed &JObject<'static>, never an owned JObject<'static>.
Local references belong to a single thread and are not safe to share across
threads. This type implements Send and Sync if and only if the
lifetime 'local is 'static.
Implementations§
Source§impl JObject<'_>
impl JObject<'_>
Sourcepub unsafe fn from_raw<'local>(
_env: &Env<'local>,
raw: jobject,
) -> JObject<'local>
pub unsafe fn from_raw<'local>( _env: &Env<'local>, raw: jobject, ) -> JObject<'local>
Trait Implementations§
Source§impl<'local> AsRef<JObject<'local>> for JArrayIndexOutOfBoundsException<'local>
impl<'local> AsRef<JObject<'local>> for JArrayIndexOutOfBoundsException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JArrayStoreException<'local>
impl<'local> AsRef<JObject<'local>> for JArrayStoreException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JByteBuffer<'local>
impl<'local> AsRef<JObject<'local>> for JByteBuffer<'local>
Source§impl<'local> AsRef<JObject<'local>> for JCharSequence<'local>
impl<'local> AsRef<JObject<'local>> for JCharSequence<'local>
Source§impl<'local> AsRef<JObject<'local>> for JClassCircularityError<'local>
impl<'local> AsRef<JObject<'local>> for JClassCircularityError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JClassFormatError<'local>
impl<'local> AsRef<JObject<'local>> for JClassFormatError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JClassLoader<'local>
impl<'local> AsRef<JObject<'local>> for JClassLoader<'local>
Source§impl<'local> AsRef<JObject<'local>> for JClassNotFoundException<'local>
impl<'local> AsRef<JObject<'local>> for JClassNotFoundException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JCollection<'local>
impl<'local> AsRef<JObject<'local>> for JCollection<'local>
Source§impl<'local> AsRef<JObject<'local>> for JExceptionInInitializerError<'local>
impl<'local> AsRef<JObject<'local>> for JExceptionInInitializerError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JIllegalArgumentException<'local>
impl<'local> AsRef<JObject<'local>> for JIllegalArgumentException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JIllegalMonitorStateException<'local>
impl<'local> AsRef<JObject<'local>> for JIllegalMonitorStateException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JInstantiationException<'local>
impl<'local> AsRef<JObject<'local>> for JInstantiationException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JLinkageError<'local>
impl<'local> AsRef<JObject<'local>> for JLinkageError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JNoClassDefFoundError<'local>
impl<'local> AsRef<JObject<'local>> for JNoClassDefFoundError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JNoSuchFieldError<'local>
impl<'local> AsRef<JObject<'local>> for JNoSuchFieldError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JNoSuchMethodError<'local>
impl<'local> AsRef<JObject<'local>> for JNoSuchMethodError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JNumberFormatException<'local>
impl<'local> AsRef<JObject<'local>> for JNumberFormatException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JOutOfMemoryError<'local>
impl<'local> AsRef<JObject<'local>> for JOutOfMemoryError<'local>
Source§impl<'local> AsRef<JObject<'local>> for JRuntimeException<'local>
impl<'local> AsRef<JObject<'local>> for JRuntimeException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JSecurityException<'local>
impl<'local> AsRef<JObject<'local>> for JSecurityException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JStackTraceElement<'local>
impl<'local> AsRef<JObject<'local>> for JStackTraceElement<'local>
Source§impl<'local> AsRef<JObject<'local>> for JStringIndexOutOfBoundsException<'local>
impl<'local> AsRef<JObject<'local>> for JStringIndexOutOfBoundsException<'local>
Source§impl<'local> AsRef<JObject<'local>> for JThrowable<'local>
impl<'local> AsRef<JObject<'local>> for JThrowable<'local>
Source§impl<'local> From<JArrayIndexOutOfBoundsException<'local>> for JObject<'local>
impl<'local> From<JArrayIndexOutOfBoundsException<'local>> for JObject<'local>
Source§fn from(other: JArrayIndexOutOfBoundsException<'local>) -> JObject<'local>
fn from(other: JArrayIndexOutOfBoundsException<'local>) -> JObject<'local>
Source§impl<'local> From<JArrayStoreException<'local>> for JObject<'local>
impl<'local> From<JArrayStoreException<'local>> for JObject<'local>
Source§fn from(other: JArrayStoreException<'local>) -> JObject<'local>
fn from(other: JArrayStoreException<'local>) -> JObject<'local>
Source§impl<'local> From<JByteBuffer<'local>> for JObject<'local>
impl<'local> From<JByteBuffer<'local>> for JObject<'local>
Source§fn from(other: JByteBuffer<'local>) -> JObject<'local>
fn from(other: JByteBuffer<'local>) -> JObject<'local>
Source§impl<'local> From<JCharSequence<'local>> for JObject<'local>
impl<'local> From<JCharSequence<'local>> for JObject<'local>
Source§fn from(other: JCharSequence<'local>) -> JObject<'local>
fn from(other: JCharSequence<'local>) -> JObject<'local>
Source§impl<'local> From<JClassCircularityError<'local>> for JObject<'local>
impl<'local> From<JClassCircularityError<'local>> for JObject<'local>
Source§fn from(other: JClassCircularityError<'local>) -> JObject<'local>
fn from(other: JClassCircularityError<'local>) -> JObject<'local>
Source§impl<'local> From<JClassFormatError<'local>> for JObject<'local>
impl<'local> From<JClassFormatError<'local>> for JObject<'local>
Source§fn from(other: JClassFormatError<'local>) -> JObject<'local>
fn from(other: JClassFormatError<'local>) -> JObject<'local>
Source§impl<'local> From<JClassLoader<'local>> for JObject<'local>
impl<'local> From<JClassLoader<'local>> for JObject<'local>
Source§fn from(other: JClassLoader<'local>) -> JObject<'local>
fn from(other: JClassLoader<'local>) -> JObject<'local>
Source§impl<'local> From<JClassNotFoundException<'local>> for JObject<'local>
impl<'local> From<JClassNotFoundException<'local>> for JObject<'local>
Source§fn from(other: JClassNotFoundException<'local>) -> JObject<'local>
fn from(other: JClassNotFoundException<'local>) -> JObject<'local>
Source§impl<'local> From<JCollection<'local>> for JObject<'local>
impl<'local> From<JCollection<'local>> for JObject<'local>
Source§fn from(other: JCollection<'local>) -> JObject<'local>
fn from(other: JCollection<'local>) -> JObject<'local>
Source§impl<'local> From<JExceptionInInitializerError<'local>> for JObject<'local>
impl<'local> From<JExceptionInInitializerError<'local>> for JObject<'local>
Source§fn from(other: JExceptionInInitializerError<'local>) -> JObject<'local>
fn from(other: JExceptionInInitializerError<'local>) -> JObject<'local>
Source§impl<'local> From<JIllegalArgumentException<'local>> for JObject<'local>
impl<'local> From<JIllegalArgumentException<'local>> for JObject<'local>
Source§fn from(other: JIllegalArgumentException<'local>) -> JObject<'local>
fn from(other: JIllegalArgumentException<'local>) -> JObject<'local>
Source§impl<'local> From<JIllegalMonitorStateException<'local>> for JObject<'local>
impl<'local> From<JIllegalMonitorStateException<'local>> for JObject<'local>
Source§fn from(other: JIllegalMonitorStateException<'local>) -> JObject<'local>
fn from(other: JIllegalMonitorStateException<'local>) -> JObject<'local>
Source§impl<'local> From<JInstantiationException<'local>> for JObject<'local>
impl<'local> From<JInstantiationException<'local>> for JObject<'local>
Source§fn from(other: JInstantiationException<'local>) -> JObject<'local>
fn from(other: JInstantiationException<'local>) -> JObject<'local>
Source§impl<'local> From<JLinkageError<'local>> for JObject<'local>
impl<'local> From<JLinkageError<'local>> for JObject<'local>
Source§fn from(other: JLinkageError<'local>) -> JObject<'local>
fn from(other: JLinkageError<'local>) -> JObject<'local>
Source§impl<'local> From<JNoClassDefFoundError<'local>> for JObject<'local>
impl<'local> From<JNoClassDefFoundError<'local>> for JObject<'local>
Source§fn from(other: JNoClassDefFoundError<'local>) -> JObject<'local>
fn from(other: JNoClassDefFoundError<'local>) -> JObject<'local>
Source§impl<'local> From<JNoSuchFieldError<'local>> for JObject<'local>
impl<'local> From<JNoSuchFieldError<'local>> for JObject<'local>
Source§fn from(other: JNoSuchFieldError<'local>) -> JObject<'local>
fn from(other: JNoSuchFieldError<'local>) -> JObject<'local>
Source§impl<'local> From<JNoSuchMethodError<'local>> for JObject<'local>
impl<'local> From<JNoSuchMethodError<'local>> for JObject<'local>
Source§fn from(other: JNoSuchMethodError<'local>) -> JObject<'local>
fn from(other: JNoSuchMethodError<'local>) -> JObject<'local>
Source§impl<'local> From<JNumberFormatException<'local>> for JObject<'local>
impl<'local> From<JNumberFormatException<'local>> for JObject<'local>
Source§fn from(other: JNumberFormatException<'local>) -> JObject<'local>
fn from(other: JNumberFormatException<'local>) -> JObject<'local>
Source§impl<'local, E: Reference> From<JObjectArray<'local, E>> for JObject<'local>
impl<'local, E: Reference> From<JObjectArray<'local, E>> for JObject<'local>
Source§fn from(other: JObjectArray<'local, E>) -> JObject<'local>
fn from(other: JObjectArray<'local, E>) -> JObject<'local>
Source§impl<'local> From<JOutOfMemoryError<'local>> for JObject<'local>
impl<'local> From<JOutOfMemoryError<'local>> for JObject<'local>
Source§fn from(other: JOutOfMemoryError<'local>) -> JObject<'local>
fn from(other: JOutOfMemoryError<'local>) -> JObject<'local>
Source§impl<'local, T: TypeArray> From<JPrimitiveArray<'local, T>> for JObject<'local>
impl<'local, T: TypeArray> From<JPrimitiveArray<'local, T>> for JObject<'local>
Source§fn from(other: JPrimitiveArray<'local, T>) -> JObject<'local>
fn from(other: JPrimitiveArray<'local, T>) -> JObject<'local>
Source§impl<'local> From<JRuntimeException<'local>> for JObject<'local>
impl<'local> From<JRuntimeException<'local>> for JObject<'local>
Source§fn from(other: JRuntimeException<'local>) -> JObject<'local>
fn from(other: JRuntimeException<'local>) -> JObject<'local>
Source§impl<'local> From<JSecurityException<'local>> for JObject<'local>
impl<'local> From<JSecurityException<'local>> for JObject<'local>
Source§fn from(other: JSecurityException<'local>) -> JObject<'local>
fn from(other: JSecurityException<'local>) -> JObject<'local>
Source§impl<'local> From<JStackTraceElement<'local>> for JObject<'local>
impl<'local> From<JStackTraceElement<'local>> for JObject<'local>
Source§fn from(other: JStackTraceElement<'local>) -> JObject<'local>
fn from(other: JStackTraceElement<'local>) -> JObject<'local>
Source§impl<'local> From<JStringIndexOutOfBoundsException<'local>> for JObject<'local>
impl<'local> From<JStringIndexOutOfBoundsException<'local>> for JObject<'local>
Source§fn from(other: JStringIndexOutOfBoundsException<'local>) -> JObject<'local>
fn from(other: JStringIndexOutOfBoundsException<'local>) -> JObject<'local>
Source§impl<'local> From<JThrowable<'local>> for JObject<'local>
impl<'local> From<JThrowable<'local>> for JObject<'local>
Source§fn from(other: JThrowable<'local>) -> JObject<'local>
fn from(other: JThrowable<'local>) -> JObject<'local>
Source§impl Reference for JObject<'_>
impl Reference for JObject<'_>
Source§type Kind<'env> = JObject<'env>
type Kind<'env> = JObject<'env>
Self::Kind type corresponds to the underlying
class type (such as JObject or JString), parameterized by the
lifetime that indicates whether the type holds a global reference
('static) or a local reference that’s tied to a JNI stack frame. Read moreSource§type GlobalKind = JObject<'static>
type GlobalKind = JObject<'static>
GlobalKind type should be equivalent to
Kind<'static>, with the additional bound that ensures the type is
Send + Sync Read moreSource§fn as_raw(&self) -> jobject
fn as_raw(&self) -> jobject
crate::sys::jobject reference.Source§fn class_name() -> Cow<'static, JNIStr>
fn class_name() -> Cow<'static, JNIStr>
Source§fn lookup_class<'caller>(
env: &Env<'_>,
_loader_context: &LoaderContext<'_, '_>,
) -> Result<impl Deref<Target = Global<JClass<'static>>> + 'caller>
fn lookup_class<'caller>( env: &Env<'_>, _loader_context: &LoaderContext<'_, '_>, ) -> Result<impl Deref<Target = Global<JClass<'static>>> + 'caller>
Source§unsafe fn kind_from_raw<'env>(local_ref: jobject) -> Self::Kind<'env>
unsafe fn kind_from_raw<'env>(local_ref: jobject) -> Self::Kind<'env>
Self::Kind for the given reference that is tied
to the specified lifetime. Read moreSource§unsafe fn global_kind_from_raw(global_ref: jobject) -> Self::GlobalKind
unsafe fn global_kind_from_raw(global_ref: jobject) -> Self::GlobalKind
Source§fn null<'any>() -> Self::Kind<'any>
fn null<'any>() -> Self::Kind<'any>
null reference based on Self::Kind