< prev index next >

test/hotspot/jtreg/serviceability/jvmti/events/MonitorContendedEnter/mcontenter01/libmcontenter01.cpp

Print this page
@@ -33,11 +33,10 @@
  extern "C" {
  
  /* ========================================================================== */
  
  /* scaffold objects */
- static JNIEnv *jni = nullptr;
  static jvmtiEnv *jvmti = nullptr;
  static jlong timeout = 0;
  
  /* test objects */
  static jthread expected_thread = nullptr;

@@ -69,11 +68,11 @@
    }
  }
  
  /* ========================================================================== */
  
- static int prepare() {
+ static int prepare(JNIEnv* jni) {
    jvmtiError err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_MONITOR_CONTENDED_ENTER, nullptr);
    if (err != JVMTI_ERROR_NONE) {
      jni->FatalError("Error enabling JVMTI_EVENT_MONITOR_CONTENDED_ENTER.");
    }
    return JNI_TRUE;

@@ -90,19 +89,18 @@
  }
  
  /* agent algorithm
   */
  static void JNICALL
- agentProc(jvmtiEnv *jvmti, JNIEnv *agentJNI, void *arg) {
-   jni = agentJNI;
+ agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) {
  
    /* wait for initial sync */
    if (!agent_wait_for_sync(timeout)) {
      return;
    }
  
-   if (!prepare()) {
+   if (!prepare(jni)) {
      set_agent_fail_status();
      return;
    }
  
    /* clear events count */
< prev index next >