MCPcopy Create free account
hub / github.com/astonbitecode/j4rs / check_equals

Method check_equals

rust/src/api/mod.rs:1209–1233  ·  view source on GitHub ↗

Checks whether an Instance a is equal to some InvocationArg. The check is actually against the Java `Object.equals`, taking into consideration the possibility of null. `NullPointerException` will not be thrown, even if one of the inputs is null.

(
        &self,
        instance: impl Borrow<Instance>,
        inv_arg: impl Borrow<InvocationArg>,
    )

Source from the content-addressed store, hash-verified

1207 /// The check is actually against the Java `Object.equals`, taking into consideration the possibility of null.
1208 /// `NullPointerException` will not be thrown, even if one of the inputs is null.
1209 pub fn check_equals(
1210 &self,
1211 instance: impl Borrow<Instance>,
1212 inv_arg: impl Borrow<InvocationArg>,
1213 ) -> errors::Result<bool> {
1214 debug(&format!(
1215 "Checking equality between instances of {} and {}",
1216 instance.borrow().class_name(),
1217 inv_arg.borrow().class_name()
1218 ));
1219 unsafe {
1220 // Create InvocationArg Java Objects
1221 let inv_arg_java_b = inv_arg.borrow().as_java_ptr_with_global_ref(self.jni_env)?;
1222 // Call the checkEquals method
1223 let java_boolean = (opt_to_res(cache::get_jni_call_boolean_method())?)(
1224 self.jni_env,
1225 instance.borrow().jinstance,
1226 cache::get_check_equals_method()?,
1227 inv_arg_java_b,
1228 );
1229
1230 // Create and return the boolean
1231 Self::do_return(self.jni_env, java_boolean)
1232 }
1233 }
1234
1235 /// Consumes an `Instance` and returns its jobject. The returned jobject is a JNI local reference.
1236 pub fn instance_into_raw_object(&self, instance: Instance) -> errors::Result<jobject> {

Callers

nothing calls this directly

Calls 6

debugFunction · 0.85
opt_to_resFunction · 0.85
get_check_equals_methodFunction · 0.85
do_returnFunction · 0.85

Tested by

no test coverage detected