Skip to content

Commit 013d0e4

Browse files
committed
runtime: stub implement more JVMTI functions
1 parent 36380c9 commit 013d0e4

5 files changed

Lines changed: 228 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use jni::objects::JObject;
2+
use jni::sys::{jdouble, jfloat, jint, jlong};
3+
use jvmti::env::JvmtiEnv;
4+
use jvmti::error::JvmtiError;
5+
use jvmti::objects::JThread;
6+
use native_macros::jvmti_call;
7+
8+
macro_rules! force_early_return {
9+
($($fun:ident => $ty:ty),+ $(,)?) => {
10+
$(
11+
paste::paste! {
12+
#[jvmti_call]
13+
pub extern "system" fn $fun(
14+
_env: JvmtiEnv,
15+
_thread: JThread,
16+
_value: $ty,
17+
) -> JvmtiError {
18+
unimplemented!("jvmtiEnv::{}", stringify!($ty))
19+
}
20+
}
21+
)+
22+
};
23+
}
24+
25+
force_early_return! {
26+
ForceEarlyReturnObject => JObject,
27+
ForceEarlyReturnInt => jint,
28+
ForceEarlyReturnLong => jlong,
29+
ForceEarlyReturnFloat => jfloat,
30+
ForceEarlyReturnDouble => jdouble,
31+
}
32+
33+
#[jvmti_call]
34+
pub extern "system" fn ForceEarlyReturnVoid(_env: JvmtiEnv, _thread: JThread) -> JvmtiError {
35+
unimplemented!("jvmtiEnv::ForceEarlyReturnVoid")
36+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use std::ffi::c_void;
2+
3+
use jni::objects::{JClass, JObject};
4+
use jni::sys::{jint, jlong, jobject};
5+
use jvmti::env::JvmtiEnv;
6+
use jvmti::error::JvmtiError;
7+
use jvmti::sys::jvmtiHeapCallbacks;
8+
use native_macros::jvmti_call;
9+
10+
mod v1_0;
11+
12+
#[jvmti_call]
13+
pub extern "system" fn FollowReferences(
14+
_env: JvmtiEnv,
15+
_heap_filter: jint,
16+
_klass: JClass,
17+
_initial_object: JObject,
18+
_callbacks: *const jvmtiHeapCallbacks,
19+
_user_data: *const c_void,
20+
) -> JvmtiError {
21+
unimplemented!("jvmtiEnv::FollowReferences")
22+
}
23+
24+
#[jvmti_call]
25+
pub extern "system" fn IterateThroughHeap(
26+
_env: JvmtiEnv,
27+
_heap_filter: jint,
28+
_klass: JClass,
29+
_callbacks: *const jvmtiHeapCallbacks,
30+
_user_data: *const c_void,
31+
) -> JvmtiError {
32+
unimplemented!("jvmtiEnv::IterateThroughHeap")
33+
}
34+
35+
#[jvmti_call]
36+
pub extern "system" fn GetTag(
37+
_env: JvmtiEnv,
38+
_object: JObject,
39+
_tag_ptr: *mut jlong,
40+
) -> JvmtiError {
41+
unimplemented!("jvmtiEnv::GetTag")
42+
}
43+
44+
#[jvmti_call]
45+
pub extern "system" fn SetTag(_env: JvmtiEnv, _object: JObject, _tag: jlong) -> JvmtiError {
46+
unimplemented!("jvmtiEnv::SetTag")
47+
}
48+
49+
#[jvmti_call]
50+
pub extern "system" fn GetObjectsWithTags(
51+
_env: JvmtiEnv,
52+
_tag_count: jint,
53+
_tags: *const jlong,
54+
_count_ptr: *mut jint,
55+
_object_result_ptr: *mut *mut jobject,
56+
_tag_result_ptr: *mut *mut jlong,
57+
) -> JvmtiError {
58+
unimplemented!("jvmtiEnv::GetObjectsWithTags")
59+
}
60+
61+
#[jvmti_call]
62+
pub extern "system" fn ForceGarbageCollection(_env: JvmtiEnv) -> JvmtiError {
63+
unimplemented!("jvmtiEnv::ForceGarbageCollection")
64+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use std::ffi::c_void;
2+
3+
use jni::objects::{JClass, JObject};
4+
use jvmti::env::JvmtiEnv;
5+
use jvmti::error::JvmtiError;
6+
use jvmti::sys::{
7+
jvmtiHeapObjectCallback, jvmtiHeapObjectFilter, jvmtiHeapRootCallback,
8+
jvmtiObjectReferenceCallback, jvmtiStackReferenceCallback,
9+
};
10+
use native_macros::jvmti_call;
11+
12+
#[jvmti_call]
13+
pub extern "system" fn IterateOverObjectsReachableFromObject(
14+
_env: JvmtiEnv,
15+
_object: JObject,
16+
_object_reference_callback: jvmtiObjectReferenceCallback,
17+
_user_data: *const c_void,
18+
) -> JvmtiError {
19+
unimplemented!("jvmtiEnv::IterateOverObjectsReachableFromObject")
20+
}
21+
22+
#[jvmti_call]
23+
pub extern "system" fn IterateOverReachableObjects(
24+
_env: JvmtiEnv,
25+
_heap_root_callback: jvmtiHeapRootCallback,
26+
_stack_ref_callback: jvmtiStackReferenceCallback,
27+
_object_ref_callback: jvmtiObjectReferenceCallback,
28+
_user_data: *const c_void,
29+
) -> JvmtiError {
30+
unimplemented!("jvmtiEnv::IterateOverReachableObjects")
31+
}
32+
33+
#[jvmti_call]
34+
pub extern "system" fn IterateOverHeap(
35+
_env: JvmtiEnv,
36+
_object_filter: jvmtiHeapObjectFilter,
37+
_heap_object_callback: jvmtiHeapObjectCallback,
38+
_user_data: *const c_void,
39+
) -> JvmtiError {
40+
unimplemented!("jvmtiEnv::IterateOverHeap")
41+
}
42+
43+
#[jvmti_call]
44+
pub extern "system" fn IterateOverInstancesOfClass(
45+
_env: JvmtiEnv,
46+
_klass: JClass,
47+
_object_filter: jvmtiHeapObjectFilter,
48+
_heap_object_callback: jvmtiHeapObjectCallback,
49+
_user_data: *const c_void,
50+
) -> JvmtiError {
51+
unimplemented!("jvmtiEnv::IterateOverInstancesOfClass")
52+
}

runtime/src/native/jvmti/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
55
#![allow(non_snake_case)]
66

7+
mod force_early_return;
8+
mod heap;
79
mod memory_management;
10+
mod stack_frame;
811
mod thread;
912
mod thread_group;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
use jni::sys::{jint, jmethodID};
2+
use jvmti::env::JvmtiEnv;
3+
use jvmti::error::JvmtiError;
4+
use jvmti::objects::JThread;
5+
use jvmti::sys::{jlocation, jthread, jvmtiFrameInfo, jvmtiStackInfo};
6+
use native_macros::jvmti_call;
7+
8+
#[jvmti_call]
9+
pub extern "system" fn GetStackTrace(
10+
_env: JvmtiEnv,
11+
_thread: JThread,
12+
_start_depth: jint,
13+
_max_frame_count: jint,
14+
_frame_buffer: *mut jvmtiFrameInfo,
15+
_count_ptr: *mut jint,
16+
) -> JvmtiError {
17+
unimplemented!("jvmtiEnv::GetStackTrace")
18+
}
19+
20+
#[jvmti_call]
21+
pub extern "system" fn GetAllStackTraces(
22+
_env: JvmtiEnv,
23+
_max_frame_count: jint,
24+
_stack_info_ptr: *mut jvmtiStackInfo,
25+
_thread_count_ptr: *mut jint,
26+
) -> JvmtiError {
27+
unimplemented!("jvmtiEnv::GetAllStackTraces")
28+
}
29+
30+
#[jvmti_call]
31+
pub extern "system" fn GetThreadListStackTraces(
32+
_env: JvmtiEnv,
33+
_thread_count: jint,
34+
_thread_list: *const jthread,
35+
_max_frame_count: jint,
36+
_stack_info_ptr: *mut *mut jvmtiStackInfo,
37+
) -> JvmtiError {
38+
unimplemented!("jvmtiEnv::GetThreadListStackTraces")
39+
}
40+
41+
#[jvmti_call]
42+
pub extern "system" fn GetFrameCount(
43+
_env: JvmtiEnv,
44+
_thread: JThread,
45+
_count_ptr: *mut jint,
46+
) -> JvmtiError {
47+
unimplemented!("jvmtiEnv::GetFrameCount")
48+
}
49+
50+
#[jvmti_call]
51+
pub extern "system" fn PopFrame(_env: JvmtiEnv, _thread: JThread) -> JvmtiError {
52+
unimplemented!("jvmtiEnv::PopFrame")
53+
}
54+
55+
#[jvmti_call]
56+
pub extern "system" fn GetFrameLocation(
57+
_env: JvmtiEnv,
58+
_thread: JThread,
59+
_depth: jint,
60+
_method_ptr: *mut jmethodID,
61+
_location_ptr: *mut jlocation,
62+
) -> JvmtiError {
63+
unimplemented!("jvmtiEnv::GetFrameLocation")
64+
}
65+
66+
#[jvmti_call]
67+
pub extern "system" fn NotifyFramePop(
68+
_env: JvmtiEnv,
69+
_thread: JThread,
70+
_depth: jint,
71+
) -> JvmtiError {
72+
unimplemented!("jvmtiEnv::NotifyFramePop")
73+
}

0 commit comments

Comments
 (0)