Skip to content

Commit

Permalink
Add Env::throw.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Aug 28, 2024
1 parent 4856217 commit c423cf6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion java-spaghetti/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::atomic::{AtomicPtr, Ordering};

use jni_sys::*;

use crate::{AsArg, Local, ReferenceType, StringChars, ThrowableType, VM};
use crate::{AsArg, Local, Ref, ReferenceType, StringChars, ThrowableType, VM};

/// FFI: Use **Env** instead of \*const JNIEnv. This represents a per-thread Java exection environment.
///
Expand Down Expand Up @@ -799,4 +799,9 @@ impl<'env> Env<'env> {
pub unsafe fn set_static_double_field(self, class: jclass, field: jfieldID, value: jdouble) {
((**self.env).v1_2.SetStaticDoubleField)(self.env, class, field, value);
}

pub fn throw<T: ReferenceType>(self, throwable: Ref<T>) {
let res = unsafe { ((**self.env).v1_2.Throw)(self.env, throwable.as_raw()) };
assert_eq!(res, 0);
}
}

0 comments on commit c423cf6

Please sign in to comment.