Skip to content

Commit 6e838d6

Browse files
committed
8371474: Wrong object class or methodID passed to JNI call in TestSharedCloseJvmti with -Xshare:off
Reviewed-by: alanb, mdoerr
1 parent 2d4f2fd commit 6e838d6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

test/jdk/java/foreign/sharedclosejvmti/TestSharedCloseJvmti.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public static class EventDuringScopedAccessRunner {
7272

7373
static final CountDownLatch MAIN_LATCH = new CountDownLatch(1);
7474
static final CountDownLatch TARGET_LATCH = new CountDownLatch(1);
75-
static final MemorySegment OTHER_SEGMENT = Arena.global().allocate(4);
7675

7776
static volatile int SINK;
7877

@@ -107,7 +106,9 @@ private static void target() {
107106
addFrames(0);
108107
} else {
109108
reentrant = true;
110-
SINK = OTHER_SEGMENT.get(ValueLayout.JAVA_INT, 0);
109+
try (Arena arena = Arena.ofConfined()) {
110+
SINK = arena.allocate(4).get(ValueLayout.JAVA_INT, 0);
111+
}
111112
reentrant = false;
112113
}
113114
}

test/jdk/java/foreign/sharedclosejvmti/libSharedCloseAgent.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static const char* TARGET_METHOD_SIG = "()V";
3535
static const char* INTERCEPT_CLASS_NAME = "Ljdk/internal/foreign/MemorySessionImpl;";
3636
static const char* INTERCEPT_METHOD_NAME = "checkValidStateRaw";
3737

38-
void start(jvmtiEnv *jvmti_env, JNIEnv* jni_env) {
38+
void start(jvmtiEnv*, JNIEnv* jni_env, jthread) {
3939

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

113113
jvmtiEventCallbacks callbacks;
114-
callbacks.VMStart = start;
114+
callbacks.VMInit = start;
115115
callbacks.MethodExit = method_exit;
116116

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

127-
err = env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, nullptr);
127+
err = env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, nullptr);
128128
if (err != JVMTI_ERROR_NONE) {
129129
return err;
130130
}

0 commit comments

Comments
 (0)