MCPcopy Create free account
hub / github.com/bluejekyll/wasmtime-java / call_string_method

Function call_string_method

wasmtime-jni/src/wasm_exception.rs:126–145  ·  view source on GitHub ↗
(
    env: &'l JNIEnv<'j>,
    obj: &JObject<'j>,
    method: &str,
)

Source from the content-addressed store, hash-verified

124}
125
126fn call_string_method<'j: 'l, 'l>(
127 env: &'l JNIEnv<'j>,
128 obj: &JObject<'j>,
129 method: &str,
130) -> Result<Option<JavaStr<'j, 'l>>, anyhow::Error> {
131 let jstring = env
132 .call_method(*obj, method, "()Ljava/lang/String;", &[])
133 .map_err(|_| fmt::Error)?
134 .l()
135 .map_err(|_| fmt::Error)
136 .map(JString::from)?;
137
138 if jstring.is_null() {
139 return Ok(None);
140 }
141
142 env.get_string(jstring)
143 .with_context(|| format!("Failed to get_string for Exception: {:?}", obj))
144 .map(Some)
145}

Callers 1

fmtMethod · 0.85

Calls 1

is_nullMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…