| 1112 | } |
| 1113 | |
| 1114 | pub(crate) unsafe fn get_invoke_method() -> errors::Result<jmethodID> { |
| 1115 | get_cached!( |
| 1116 | INVOKE_METHOD, |
| 1117 | { |
| 1118 | let env = get_thread_local_env()?; |
| 1119 | |
| 1120 | let invoke_method_signature = format!( |
| 1121 | "(Ljava/lang/String;[Lorg/astonbitecode/j4rs/api/dtos/InvocationArg;)L{};", |
| 1122 | INVO_IFACE_NAME |
| 1123 | ); |
| 1124 | // Get the method ID for the `Instance.invoke` |
| 1125 | let cstr1 = utils::to_c_string("invoke"); |
| 1126 | let cstr2 = utils::to_c_string(invoke_method_signature.as_ref()); |
| 1127 | let j = unsafe { |
| 1128 | (opt_to_res(get_jni_get_method_id())?)( |
| 1129 | env, |
| 1130 | get_java_instance_class()?, |
| 1131 | cstr1, |
| 1132 | cstr2, |
| 1133 | ) |
| 1134 | }; |
| 1135 | utils::drop_c_string(cstr1); |
| 1136 | utils::drop_c_string(cstr2); |
| 1137 | |
| 1138 | j |
| 1139 | }, |
| 1140 | set_invoke_method |
| 1141 | ) |
| 1142 | } |
| 1143 | |
| 1144 | pub(crate) fn set_invoke_static_method(j: jmethodID) { |
| 1145 | debug("Called set_invoke_static_method"); |