jvmti_rs/wrapper/jvmtifns/
object.rs

1use std::ptr;
2
3use crate::{
4    errors::*,
5    JVMTIEnv,
6    objects::*,
7    sys::*,
8};
9
10impl<'a> JVMTIEnv<'a> {
11    pub fn get_object_size(&self, obj: &JObject) -> Result<jlong> {
12        Ok(jvmti_call_number_result!(self.jvmti_raw(), jlong,
13            GetObjectSize,
14            obj.into_inner()
15        ))
16    }
17
18    pub fn get_object_hash_code(&self, obj: &JObject) -> Result<jint> {
19        Ok(jvmti_call_number_result!(self.jvmti_raw(), jint,
20            GetObjectHashCode,
21            obj.into_inner()
22        ))
23    }
24
25    pub fn get_object_monitor_usage(&self, obj: &JObject) -> Result<JMonitorUsage> {
26        let mut usage: jvmtiMonitorUsage = jvmtiMonitorUsage {
27            owner: ptr::null_mut(),
28            entry_count: 0,
29            waiter_count: 0,
30            waiters: ptr::null_mut(),
31            notify_waiter_count: 0,
32            notify_waiters: ptr::null_mut(),
33        };
34        let res = jvmti_call_result!(self.jvmti_raw(), GetObjectMonitorUsage,
35            obj.into_inner(),
36            &mut usage
37        );
38        jvmti_error_code_to_result(res)?;
39        Ok(JMonitorUsage::new(usage, self))
40    }
41}