pub struct Object<'env> { /* private fields */ }
Expand description
A type representing the
java.lang.Object
class
– the root class of Java’s class hierarchy.
Implementations§
Source§impl<'env> Object<'env>
impl<'env> Object<'env>
Sourcepub unsafe fn raw_object(&self) -> jobject
pub unsafe fn raw_object(&self) -> jobject
Get the raw object pointer.
This function provides low-level access to the Java object and thus is unsafe.
Sourcepub fn class(&self, _token: &NoException<'_>) -> Class<'env>
pub fn class(&self, _token: &NoException<'_>) -> Class<'env>
Get the object’s class.
Sourcepub fn is_same_as(&self, other: &Object<'_>, _token: &NoException<'_>) -> bool
pub fn is_same_as(&self, other: &Object<'_>, _token: &NoException<'_>) -> bool
Compare with another Java object by reference.
Sourcepub fn is_instance_of(
&self,
class: &Class<'_>,
_token: &NoException<'_>,
) -> bool
pub fn is_instance_of( &self, class: &Class<'_>, _token: &NoException<'_>, ) -> bool
Check if the object is an instance of the class.
Sourcepub fn clone(&self, token: &NoException<'env>) -> JavaResult<'env, Object<'env>>
pub fn clone(&self, token: &NoException<'env>) -> JavaResult<'env, Object<'env>>
Clone the Object
. This is not a deep clone of the Java object,
but a Rust-like clone of the value. Since Java objects are reference counted, this will
increment the reference count.
This method has a different signature from the one in the
Clone
trait because
cloning a Java object is only safe when there is no pending exception and because
cloning a java object cat throw an exception.
Source§impl<'env> Object<'env>
impl<'env> Object<'env>
Sourcepub fn get_class(
env: &'env JniEnv<'env>,
token: &NoException<'env>,
) -> JavaResult<'env, Class<'env>>
pub fn get_class( env: &'env JniEnv<'env>, token: &NoException<'env>, ) -> JavaResult<'env, Class<'env>>
Get the Java class object for
Object
.
Sourcepub fn to_string(
&self,
token: &NoException<'env>,
) -> JavaResult<'env, String<'env>>
pub fn to_string( &self, token: &NoException<'env>, ) -> JavaResult<'env, String<'env>>
Convert the object to a string.
Sourcepub fn equals(
&self,
other: &Object<'_>,
token: &NoException<'env>,
) -> JavaResult<'env, bool>
pub fn equals( &self, other: &Object<'_>, token: &NoException<'env>, ) -> JavaResult<'env, bool>
Compare to another Java object.
Trait Implementations§
Source§impl<'env> Debug for Object<'env>
Allow displaying Java objects for debug purposes.
impl<'env> Debug for Object<'env>
Allow displaying Java objects for debug purposes.
This is mostly a convenience for debugging. Always prefer using
to_string
to printing the object as is, because
the former checks for a pending exception in compile-time rather than the run-time.
Source§impl<'env> Display for Object<'env>
Allow displaying Java objects.
impl<'env> Display for Object<'env>
Allow displaying Java objects.
This is mostly a convenience for debugging. Always prefer using
to_string
to printing the object as is, because
the former checks for a pending exception in compile-time rather than the run-time.
Source§impl<'env> Drop for Object<'env>
Make Object
-s reference be deleted when the value is dropped.
impl<'env> Drop for Object<'env>
Make Object
-s reference be deleted when the value is dropped.
Source§impl<'env, T> PartialEq<T> for Object<'env>
impl<'env, T> PartialEq<T> for Object<'env>
Will panic if there is a pending exception in the current thread.
This is mostly a convenience for using assert_eq!()
in tests. Always prefer using
is_same_as
to comparing with ==
, because
the former checks for a pending exception in compile-time rather than the run-time.
impl<'env> Eq for Object<'env>
Will panic if there is a pending exception in the current thread.
This is mostly a convenience for using assert_eq!()
in tests. Always prefer using
is_same_as
to comparing with ==
, because
the former checks for a pending exception in compile-time rather than the run-time.