Function
call_string_method
(
env: &'l JNIEnv<'j>,
obj: &JObject<'j>,
method: &str,
)
Source from the content-addressed store, hash-verified
| 124 | } |
| 125 | |
| 126 | fn 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 | } |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…