|
1 | 1 | /* |
2 | | - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -38,6 +38,7 @@ static jvmtiEnv *jvmti = NULL; |
38 | 38 | static jvmtiCapabilities caps; |
39 | 39 | static jvmtiEventCallbacks callbacks; |
40 | 40 | static jrawMonitorID access_lock; |
| 41 | +static jobject notifyFramePopThread = NULL; |
41 | 42 | static jint result = PASSED; |
42 | 43 | static jboolean printdump = JNI_FALSE; |
43 | 44 | static int flag = 0; |
@@ -188,25 +189,27 @@ void JNICALL MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *env, |
188 | 189 |
|
189 | 190 | if (flag) { |
190 | 191 | mark(jvmti_env, JVMTI_EVENT_METHOD_ENTRY); |
191 | | - err = jvmti_env->IsMethodNative(method, &isNative); |
192 | | - if (err != JVMTI_ERROR_NONE) { |
193 | | - result = STATUS_FAILED; |
194 | | - printf("(IsMethodNative) unexpected error: %s (%d)\n", |
195 | | - TranslateError(err), err); |
196 | | - } |
197 | | - if (isNative == JNI_FALSE) { |
198 | | - err = jvmti_env->NotifyFramePop(thr, 0); |
199 | | - if (err == JVMTI_ERROR_NONE) { |
200 | | - enable(jvmti_env, JVMTI_EVENT_FRAME_POP); |
201 | | - } else { |
| 192 | + if (env->IsSameObject(notifyFramePopThread, thr)) { |
| 193 | + err = jvmti_env->IsMethodNative(method, &isNative); |
| 194 | + if (err != JVMTI_ERROR_NONE) { |
202 | 195 | result = STATUS_FAILED; |
203 | | - printf("(NotifyFramePop) unexpected error: %s (%d)\n", |
| 196 | + printf("(IsMethodNative) unexpected error: %s (%d)\n", |
204 | 197 | TranslateError(err), err); |
205 | 198 | } |
| 199 | + if (isNative == JNI_FALSE) { |
| 200 | + err = jvmti_env->NotifyFramePop(thr, 0); |
| 201 | + if (err == JVMTI_ERROR_NONE) { |
| 202 | + enable(jvmti_env, JVMTI_EVENT_FRAME_POP); |
| 203 | + } else { |
| 204 | + result = STATUS_FAILED; |
| 205 | + printf("(NotifyFramePop) unexpected error: %s (%d)\n", |
| 206 | + TranslateError(err), err); |
| 207 | + } |
| 208 | + } |
| 209 | + enable(jvmti_env, JVMTI_EVENT_CLASS_LOAD); |
| 210 | + enable(jvmti_env, JVMTI_EVENT_CLASS_PREPARE); |
| 211 | + disable(jvmti_env, JVMTI_EVENT_METHOD_ENTRY); |
206 | 212 | } |
207 | | - enable(jvmti_env, JVMTI_EVENT_CLASS_LOAD); |
208 | | - enable(jvmti_env, JVMTI_EVENT_CLASS_PREPARE); |
209 | | - disable(jvmti_env, JVMTI_EVENT_METHOD_ENTRY); |
210 | 213 | } |
211 | 214 | } |
212 | 215 |
|
@@ -392,8 +395,9 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { |
392 | 395 |
|
393 | 396 | JNIEXPORT void JNICALL |
394 | 397 | Java_nsk_jvmti_SetEventNotificationMode_setnotif001_enableEv(JNIEnv *env, |
395 | | - jclass cls) { |
| 398 | + jclass cls, jobject framePopThread) { |
396 | 399 | setWatches(jvmti, env, cls); |
| 400 | + notifyFramePopThread = env->NewGlobalRef(framePopThread); |
397 | 401 | enable(jvmti, JVMTI_EVENT_METHOD_ENTRY); |
398 | 402 | enable(jvmti, JVMTI_EVENT_METHOD_EXIT); |
399 | 403 | enable(jvmti, JVMTI_EVENT_THREAD_START); |
|
0 commit comments