jvmti_rs/wrapper/objects/
jheap_reference_info.rs

1use jni_sys::jint;
2use std::marker::PhantomData;
3use crate::sys::{jlong, jlocation, jvmtiHeapReferenceInfoReserved, jvmtiHeapReferenceInfoJniLocal, jvmtiHeapReferenceInfoStackLocal};
4use crate::wrapper::objects::JMethodID;
5
6#[derive(Debug)]
7pub struct JHeapReferenceInfoStackLocal<'a> {
8    internal: jvmtiHeapReferenceInfoStackLocal,
9
10    pub thread_tag: jlong,
11    pub thread_id: jlong,
12    pub depth: jint,
13    pub method: JMethodID<'a>,
14    pub location: jlocation,
15    pub slot: jint,
16}
17
18impl<'a> From<jvmtiHeapReferenceInfoStackLocal> for JHeapReferenceInfoStackLocal<'a> {
19    fn from(info: jvmtiHeapReferenceInfoStackLocal) -> Self {
20        return JHeapReferenceInfoStackLocal {
21            internal: info,
22
23            thread_tag: info.thread_tag,
24            thread_id: info.thread_id,
25            depth: info.depth,
26            method: info.method.into(),
27            location: info.location,
28            slot: info.slot,
29        };
30    }
31}
32
33impl<'a> ::std::ops::Deref for JHeapReferenceInfoStackLocal<'a> {
34    type Target = jvmtiHeapReferenceInfoStackLocal;
35
36    fn deref(&self) -> &Self::Target {
37        &self.internal
38    }
39}
40
41#[derive(Debug)]
42pub struct JHeapReferenceInfoJniLocal<'a> {
43    internal: jvmtiHeapReferenceInfoJniLocal,
44
45    pub thread_tag: jlong,
46    pub thread_id: jlong,
47    pub depth: jint,
48    pub method: JMethodID<'a>,
49}
50
51impl<'a> From<jvmtiHeapReferenceInfoJniLocal> for JHeapReferenceInfoJniLocal<'a> {
52    fn from(info: jvmtiHeapReferenceInfoJniLocal) -> Self {
53        return JHeapReferenceInfoJniLocal {
54            internal: info,
55
56            thread_tag: info.thread_tag,
57            thread_id: info.thread_id,
58            depth: info.depth,
59            method: info.method.into(),
60        };
61    }
62}
63
64impl<'a> ::std::ops::Deref for JHeapReferenceInfoJniLocal<'a> {
65    type Target = jvmtiHeapReferenceInfoJniLocal;
66
67    fn deref(&self) -> &Self::Target {
68        &self.internal
69    }
70}
71
72#[derive(Debug)]
73pub struct JHeapReferenceInfoReserved<'a> {
74    internal: jvmtiHeapReferenceInfoReserved,
75    lifetime: PhantomData<&'a ()>,
76
77    pub reserved1: jlong,
78    pub reserved2: jlong,
79    pub reserved3: jlong,
80    pub reserved4: jlong,
81    pub reserved5: jlong,
82    pub reserved6: jlong,
83    pub reserved7: jlong,
84    pub reserved8: jlong,
85}
86
87impl<'a> From<jvmtiHeapReferenceInfoReserved> for JHeapReferenceInfoReserved<'a> {
88    fn from(info: jvmtiHeapReferenceInfoReserved) -> Self {
89        return JHeapReferenceInfoReserved {
90            internal: info,
91            lifetime: PhantomData,
92
93            reserved1: info.reserved1,
94            reserved2: info.reserved2,
95            reserved3: info.reserved3,
96            reserved4: info.reserved4,
97            reserved5: info.reserved5,
98            reserved6: info.reserved6,
99            reserved7: info.reserved7,
100            reserved8: info.reserved8,
101        };
102    }
103}
104
105impl<'a> ::std::ops::Deref for JHeapReferenceInfoReserved<'a> {
106    type Target = jvmtiHeapReferenceInfoReserved;
107
108    fn deref(&self) -> &Self::Target {
109        &self.internal
110    }
111}