jvmti_rs/wrapper/jvmtifns/
jni_function_interception.rs1use std::ptr;
2
3use jni::sys::JNIEnv;
4
5use crate::{
6 errors::*,
7 JVMTIEnv,
8};
9
10impl<'a> JVMTIEnv<'a> {
11 pub fn set_jni(&self, jni: &JNIEnv) -> Result<()> {
12 jvmti_call!(self.jvmti_raw(), SetJNIFunctionTable,
13 *jni
14 )
15 }
16
17 pub fn get_jni(&self) -> Result<jni::JNIEnv<'a>> {
18 let mut jni_env = ptr::null_mut();
19 let res = jvmti_call_result!(self.jvmti_raw(), GetJNIFunctionTable,
20 &mut jni_env
21 );
22 jvmti_error_code_to_result(res)?;
23 unsafe {
24 let mut jni = jni_env as JNIEnv;
25 Ok(jni!(&mut jni as *mut JNIEnv))
26 }
27 }
28}