MCPcopy Index your code
hub / github.com/astonbitecode/j4rs / use_a_java_instance_in_different_thread

Function use_a_java_instance_in_different_thread

rust/src/lib.rs:631–649  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

629
630 #[test]
631 fn use_a_java_instance_in_different_thread() -> errors::Result<()> {
632 let jvm = create_tests_jvm()?;
633 let instantiation_args = vec![InvocationArg::try_from("3")?];
634 let instance = jvm
635 .create_instance("java.lang.String", instantiation_args.as_ref())
636 ?;
637
638 let jh = thread::spawn(move || {
639 let jvm = create_tests_jvm()?;
640 let res = jvm.invoke(&instance, "isEmpty", InvocationArg::empty());
641 res
642 });
643
644 let join_res = jh.join();
645 assert!(join_res.is_ok());
646 assert!(join_res.unwrap().is_ok());
647
648 Ok(())
649 }
650
651 #[test]
652 fn drop_and_attach_main_thread() -> errors::Result<()> {

Callers

nothing calls this directly

Calls 3

create_tests_jvmFunction · 0.85
create_instanceMethod · 0.80
invokeMethod · 0.65

Tested by

no test coverage detected