Skip to content

Commit

Permalink
Clear exception if JNI FindClass fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Aug 1, 2024
1 parent bdba27a commit 807b0af
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions java-spaghetti/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ impl<'env> Env<'env> {
// First try with JNI FindClass.
debug_assert!(class.ends_with('\0'));
let c = ((**self.env).v1_2.FindClass)(self.env, class.as_ptr() as *const c_char);
let exception: *mut _jobject = ((**self.env).v1_2.ExceptionOccurred)(self.env);
if !exception.is_null() {
((**self.env).v1_2.ExceptionClear)(self.env);
}
if !c.is_null() {
return c;
}
Expand Down

0 comments on commit 807b0af

Please sign in to comment.