Repository navigation
fix: turn every C++ exception of a JNI entry point into a Java one - #530
Merged
Merged
Conversation
GetFieldID on an object and the class name lookup of JavaContext left the class of GetObjectClass behind. On a native thread attached for a callback, nothing frees local references until the thread detaches. The class loader no longer creates a global reference while an exception is pending.
The jni-check job also runs on macOS arm64 and Windows x86_64, whose device modules, capturers and codecs reach Java on code paths of their own. Ahead of that, the paths only real devices take check their JNI calls: an AudioSource that throws on the playout thread is reported instead of leaving the exception pending, and a device whose Java constructor threw is not filled in.
A C++ exception that reaches the VM ends the process. jni::CallFromJava runs the body of an entry point and turns any into a Java exception, the way the entry points with a try block of their own do. It now guards those that had none, or that called a throwing helper before their try block.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jni::CallFromJavaruns the body of a JNI entry point and hands any C++ exception to Java, since one crossing the JNI boundary ends the JVM. 104 entry points use it now. Those in the files offix/dispose-edge-casesand of the classes it is related to follow in a separate change.jni-checkjob also runs on macOS arm64 and Windows x86_64.AudioSourcethat throws on the playout thread is reported and plays nothing for that pull, a negative result of it counts as 0 samples, and device objects whose constructor threw are not filled anymore.