Skip to content

wpeview: Build the native glue without C++ exceptions - #289

Merged
alexgcastro merged 1 commit into
mainfrom
alex/no-exceptions-native-glue
Aug 5, 2026
Merged

wpeview: Build the native glue without C++ exceptions#289
alexgcastro merged 1 commit into
mainfrom
alex/no-exceptions-native-glue

Conversation

@alexgcastro

Copy link
Copy Markdown
Collaborator

Stop using C++ exceptions for JNI error handling and compile with -fno-exceptions. Unrecoverable usage errors (missing class, method or field, native method registration failures, JNIEnv setup) now log and abort through JNI::fatalError, matching the previous outcome where the exception aborted library loading. Runtime failures use the new JNI::clearJavaException helper: it logs and clears any pending Java exception, void method invocations return a success boolean, and value returning helpers fall back to a default value. This removes all the try/catch blocks at the JNI boundaries; JNI::Class lookup by name keeps returning a null class so Init.cpp can probe for optional classes.

Comment thread wpeview/src/main/cpp/capi/WebKitWebContext.cpp
Stop using C++ exceptions for JNI error handling and compile with
-fno-exceptions. Unrecoverable usage errors (missing class, method or
field, native method registration failures, JNIEnv setup) now log and
abort through JNI::fatalError, matching the previous outcome where the
exception aborted library loading. Runtime failures use the new
JNI::clearJavaException helper: it logs the pending Java exception
description (Throwable.toString()) and clears it, void method
invocations return a success boolean, and value returning helpers fall
back to a default value. This removes all the try/catch blocks at the
JNI boundaries, which report their specific context through the
invocation result instead; JNI::Class lookup by name keeps returning a
null class so Init.cpp can probe for optional classes.

Cleanup code that used to swallow exceptions (reference and string
deleters running after the Java VM is gone) now uses the non-aborting
JNI::tryGetCurrentThreadJNIEnv and skips the release. The JNI layer now
includes Logging.h through the include path so the jni-test host
harness provides its own stderr-based version, and its tests are
adapted to the new invocation results.
@alexgcastro
alexgcastro force-pushed the alex/no-exceptions-native-glue branch from 3f5e2f3 to 6aca101 Compare August 5, 2026 11:40
@alexgcastro
alexgcastro merged commit 7cb9115 into main Aug 5, 2026
6 checks passed
@alexgcastro
alexgcastro deleted the alex/no-exceptions-native-glue branch August 5, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants