Retrieves the static class `class_name`.
(&self, class_name: &str)
| 520 | |
| 521 | /// Retrieves the static class `class_name`. |
| 522 | pub fn static_class(&self, class_name: &str) -> errors::Result<Instance> { |
| 523 | debug(&format!("Retrieving static class {}", class_name)); |
| 524 | unsafe { |
| 525 | // Factory invocation - first argument: create a jstring to pass as argument for the class_name |
| 526 | let class_name_jstring: jstring = |
| 527 | jni_utils::global_jobject_from_str(class_name, self.jni_env)?; |
| 528 | |
| 529 | // Call the method of the factory that creates a Instance for static calls to methods of class `class_name`. |
| 530 | // This returns a Instance that acts like a proxy to the Java world. |
| 531 | let java_instance = (opt_to_res(cache::get_jni_call_static_object_method())?)( |
| 532 | self.jni_env, |
| 533 | cache::get_factory_class()?, |
| 534 | cache::get_factory_create_for_static_method()?, |
| 535 | class_name_jstring, |
| 536 | ); |
| 537 | |
| 538 | jni_utils::delete_java_ref(self.jni_env, class_name_jstring); |
| 539 | |
| 540 | // Create and return the Instance. |
| 541 | Self::do_return( |
| 542 | self.jni_env, |
| 543 | Instance::from_jobject_with_global_ref(java_instance)?, |
| 544 | ) |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | /// Creates a new Java Array with elements of the class `class_name`. |
| 549 | /// The array will have the `InvocationArg`s populated. |