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

Function invoke_generic_method

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

Source from the content-addressed store, hash-verified

1024
1025 #[test]
1026 fn invoke_generic_method() -> errors::Result<()> {
1027 let jvm = create_tests_jvm()?;
1028
1029 // Create the MyTest instance
1030 let instance = jvm
1031 .create_instance("org.astonbitecode.j4rs.tests.MyTest", InvocationArg::empty())
1032 ?;
1033
1034 // Retrieve the annotated Map
1035 let dummy_map = jvm.invoke(&instance, "getMap", InvocationArg::empty())?;
1036
1037 // Put a new Map entry
1038 let _ = jvm
1039 .invoke(
1040 &dummy_map,
1041 "put",
1042 &[InvocationArg::try_from("three")?,
1043 InvocationArg::try_from(3)?],
1044 )
1045 ?;
1046
1047 // Get the size of the new map and assert
1048 let size: isize = jvm
1049 .into_chain(dummy_map)
1050 .invoke("size", InvocationArg::empty())
1051 ?
1052 .to_rust()
1053 ?;
1054
1055 assert!(size == 3);
1056
1057 Ok(())
1058 }
1059
1060 #[test]
1061 fn invoke_method_with_primitive_args() -> errors::Result<()> {

Callers

nothing calls this directly

Calls 5

create_tests_jvmFunction · 0.85
create_instanceMethod · 0.80
into_chainMethod · 0.80
invokeMethod · 0.65
to_rustMethod · 0.45

Tested by

no test coverage detected