{"record":{"id":"6013662203b009f2","repo":"slint-ui/slint","slug":"jni-error-e","errorCode":null,"errorMessage":"JNI error: {e:#?}","messagePattern":"JNI error: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backends/android-activity/javahelper.rs","lineNumber":292,"sourceCode":"    is_instance_of = {\n        JClassLoader,\n    }\n}\n\nbind_java_type! {\n    DexFileClassLoader => \"dalvik.system.DexClassLoader\",\n    constructors {\n        fn new(dex_path: JString, optimized_directory: JString, library_search_path: JString, parent: JClassLoader),\n    },\n    is_instance_of = {\n        JClassLoader,\n    }\n}\n\n// See `AttachmentExceptionPolicy::PreReThrowPostCatch` in `jni` crate.\n#[track_caller]\npub fn print_jni_error(_app: &AndroidApp, e: jni::errors::Error) -> ! {\n    panic!(\"JNI error: {e:#?}\")\n}\n\n#[allow(dead_code)]\npub struct JavaHelper(jni::refs::Global<SlintAndroidJavaHelper<'static>>, AndroidApp);\n\nfn get_helper_class_loader(\n    env: &mut Env,\n    native_activity: &AndroidActivity<'_>,\n) -> Result<&'static JClassLoader<'static>, jni::errors::Error> {\n    static DEX_CLASS_LOADER: OnceLock<jni::refs::Global<JClassLoader<'static>>> = OnceLock::new();\n\n    fn build_dex_class_loader<'local>(\n        env: &mut Env<'local>,\n        native_activity: &AndroidActivity<'_>,\n    ) -> Result<JClassLoader<'local>, jni::errors::Error> {\n        let native_activity = env.new_local_ref(native_activity)?;\n        let app_context = AndroidContext::cast_local(env, native_activity)?;\n        let context_class_loader = app_context.get_class_loader(env)?;","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/backends/android-activity/javahelper.rs#L274-L310","documentation":"print_jni_error is the Android backend's centralized JNI failure handler: any jni::errors::Error returned from a JNI call (class lookup failure, wrong argument type, Java exception pending, etc.) is funneled here and turned into a panic with a debug-formatted error. It is called from many backend entry points (event processing, input method, safe-area queries, helper construction), so seeing it means a Java-side interaction failed at runtime on Android, not that Slint logic itself is wrong.","triggerScenarios":"Thrown at internal/backends/android-activity/javahelper.rs:292 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the debug-formatted {e:#?}; common causes are JavaLangException, JNIEnv getenv failures, or detached threads","Ensure every JNI call goes through a valid AndroidEnv/JNIEnv obtained for the calling thread, not cached across thread boundaries","Check exception policy: with AttachmentExceptionPolicy::PreReThrowPostCatch the jni crate re-throws; clear pending exceptions with env.exception_clear() before further calls","Verify the Java helper classes (SlintAndroidJavaHelper, DexFileClassLoader) loaded successfully at startup; a failed class load surfaces later as a JNI error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}