(
ia: &InvocationArg,
jni_env: *mut JNIEnv,
create_global: bool,
)
| 79 | } |
| 80 | |
| 81 | pub(crate) fn invocation_arg_jobject_from_rust_basic( |
| 82 | ia: &InvocationArg, |
| 83 | jni_env: *mut JNIEnv, |
| 84 | create_global: bool, |
| 85 | ) -> errors::Result<jobject> { |
| 86 | unsafe { |
| 87 | let (class_name, jinstance) = match ia { |
| 88 | _s @ &InvocationArg::Java { .. } => { |
| 89 | panic!("Called invocation_arg_jobject_from_rust_basic for an InvocationArg that contains an object from Java. Please consider opening a bug to the developers.") |
| 90 | } |
| 91 | _s @ &InvocationArg::Rust { .. } => { |
| 92 | panic!("Called invocation_arg_jobject_from_rust_basic for an InvocationArg that contains a serialized object. Please consider opening a bug to the developers.") |
| 93 | } |
| 94 | InvocationArg::RustBasic { |
| 95 | class_name, |
| 96 | instance, |
| 97 | .. |
| 98 | } => { |
| 99 | debug(&format!( |
| 100 | "Creating jobject from Rust basic for class {}", |
| 101 | class_name |
| 102 | )); |
| 103 | (class_name.to_owned(), instance.jinstance) |
| 104 | } |
| 105 | }; |
| 106 | debug(&format!( |
| 107 | "Calling the InvocationArg constructor with '{}'", |
| 108 | class_name |
| 109 | )); |
| 110 | let class_name_jstring = global_jobject_from_str(&class_name, jni_env)?; |
| 111 | |
| 112 | let inv_arg_instance = (opt_to_res(cache::get_jni_new_object())?)( |
| 113 | jni_env, |
| 114 | cache::get_invocation_arg_class()?, |
| 115 | cache::get_inv_arg_basic_rust_constructor_method()?, |
| 116 | // First argument: class_name |
| 117 | class_name_jstring, |
| 118 | // Second argument: Instance instance |
| 119 | jinstance, |
| 120 | ); |
| 121 | |
| 122 | delete_java_ref(jni_env, class_name_jstring); |
| 123 | |
| 124 | if create_global { |
| 125 | Ok(create_global_ref_from_local_ref(inv_arg_instance, jni_env)?) |
| 126 | } else { |
| 127 | Ok(inv_arg_instance) |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | pub(crate) fn invocation_arg_jobject_from_java( |
| 133 | ia: &InvocationArg, |
no test coverage detected