pub struct Class<'env> { /* private fields */ }
Expand description
A type representing a Java
Class
.
Implementations§
Source§impl<'env> Class<'env>
impl<'env> Class<'env>
Sourcepub fn find<'a>(
env: &'a JniEnv<'a>,
class_name: &str,
token: &NoException<'a>,
) -> JavaResult<'a, Class<'a>>
pub fn find<'a>( env: &'a JniEnv<'a>, class_name: &str, token: &NoException<'a>, ) -> JavaResult<'a, Class<'a>>
Find an existing Java class by it’s name. The name is a fully qualified class or array type name.
Sourcepub fn define<'a>(
env: &'a JniEnv<'a>,
bytes: &[u8],
token: &NoException<'a>,
) -> JavaResult<'a, Class<'a>>
pub fn define<'a>( env: &'a JniEnv<'a>, bytes: &[u8], token: &NoException<'a>, ) -> JavaResult<'a, Class<'a>>
Define a new Java class from a .class
file contents.
Sourcepub fn parent(&self, _token: &NoException<'_>) -> Option<Class<'env>>
pub fn parent(&self, _token: &NoException<'_>) -> Option<Class<'env>>
Sourcepub fn is_subtype_of(&self, class: &Class<'_>, _token: &NoException<'_>) -> bool
pub fn is_subtype_of(&self, class: &Class<'_>, _token: &NoException<'_>) -> bool
Check if this class is a subtype of the other class.
In Java a class is a subtype of the other class if that other class is a direct or an indirect parent of this class or an interface this class or any it’s parent is implementing.
Source§impl<'env> Class<'env>
impl<'env> Class<'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
Class
.
Source§impl<'env> Class<'env>
impl<'env> Class<'env>
Sourcepub fn clone(&self, token: &NoException<'env>) -> JavaResult<'env, Self>where
Self: Sized,
pub fn clone(&self, token: &NoException<'env>) -> JavaResult<'env, Self>where
Self: Sized,
Clone the
Class
. 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.
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.
Methods from Deref<Target = 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.
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> Display for Class<'env>
Allow displaying
Class
.
impl<'env> Display for Class<'env>
Allow displaying
Class
.
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, T> PartialEq<T> for Class<'env>
impl<'env, T> PartialEq<T> for Class<'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 Class<'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.