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

Function string_from_jobject

rust/src/jni_utils.rs:533–548  ·  view source on GitHub ↗
(
    obj: jobject,
    jni_env: *mut JNIEnv,
)

Source from the content-addressed store, hash-verified

531primitive_array_from_jobject!(boolean_array_from_jobject, bool, cache::get_jni_get_boolean_array_elements, cache::get_jni_release_boolean_array_elements);
532
533pub(crate) unsafe fn string_from_jobject(
534 obj: jobject,
535 jni_env: *mut JNIEnv,
536) -> errors::Result<String> {
537 if obj.is_null() {
538 Err(errors::J4RsError::JniError(
539 "Attempt to create a String from null".to_string(),
540 ))
541 } else {
542 let s = (opt_to_res(cache::get_jni_get_string_utf_chars())?)(jni_env, obj, ptr::null_mut())
543 as *mut c_char;
544 let rust_string = utils::to_rust_string(s)?;
545 (opt_to_res(cache::get_jni_release_string_utf_chars())?)(jni_env, obj, s as *const c_char);
546 Ok(rust_string)
547 }
548}
549
550pub unsafe fn jstring_to_rust_string(jvm: &Jvm, java_string: jstring) -> errors::Result<String> {
551 let s = (opt_to_res(cache::get_jni_get_string_utf_chars())?)(

Callers 2

to_rust_boxedMethod · 0.85
get_throwable_stringMethod · 0.85

Calls 5

opt_to_resFunction · 0.85
to_rust_stringFunction · 0.85
to_stringMethod · 0.80

Tested by

no test coverage detected