Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public static class EventDuringScopedAccessRunner {

static final CountDownLatch MAIN_LATCH = new CountDownLatch(1);
static final CountDownLatch TARGET_LATCH = new CountDownLatch(1);
static final MemorySegment OTHER_SEGMENT = Arena.global().allocate(4);

static volatile int SINK;

Expand Down Expand Up @@ -107,7 +106,9 @@ private static void target() {
addFrames(0);
} else {
reentrant = true;
SINK = OTHER_SEGMENT.get(ValueLayout.JAVA_INT, 0);
try (Arena arena = Arena.ofConfined()) {
SINK = arena.allocate(4).get(ValueLayout.JAVA_INT, 0);
}
reentrant = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static const char* TARGET_METHOD_SIG = "()V";
static const char* INTERCEPT_CLASS_NAME = "Ljdk/internal/foreign/MemorySessionImpl;";
static const char* INTERCEPT_METHOD_NAME = "checkValidStateRaw";

void start(jvmtiEnv *jvmti_env, JNIEnv* jni_env) {
void start(jvmtiEnv*, JNIEnv* jni_env, jthread) {

jclass cls = jni_env->FindClass(TARGET_CLASS_NAME);
if (cls == nullptr) {
Expand Down Expand Up @@ -111,7 +111,7 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
}

jvmtiEventCallbacks callbacks;
callbacks.VMStart = start;
callbacks.VMInit = start;
callbacks.MethodExit = method_exit;

err = env->SetEventCallbacks(&callbacks, (jint) sizeof(callbacks));
Expand All @@ -124,7 +124,7 @@ Agent_OnLoad(JavaVM *vm, char *options, void *reserved) {
return err;
}

err = env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr);
err = env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr);
if (err != JVMTI_ERROR_NONE) {
return err;
}
Expand Down