< prev index next >

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

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

*** 69,11 ***
    }
  }
  
  /* ========================================================================== */
  
! static int prepare() {
    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;
--- 68,11 ---
    }
  }
  
  /* ========================================================================== */
  
! 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 ***
  }
  
  /* agent algorithm
   */
  static void JNICALL
! agentProc(jvmtiEnv *jvmti, JNIEnv *agentJNI, void *arg) {
-   jni = agentJNI;
  
    /* wait for initial sync */
    if (!agent_wait_for_sync(timeout)) {
      return;
    }
  
!   if (!prepare()) {
      set_agent_fail_status();
      return;
    }
  
    /* clear events count */
--- 89,18 ---
  }
  
  /* agent algorithm
   */
  static void JNICALL
! agentProc(jvmtiEnv *jvmti, JNIEnv *jni, void *arg) {
  
    /* wait for initial sync */
    if (!agent_wait_for_sync(timeout)) {
      return;
    }
  
!   if (!prepare(jni)) {
      set_agent_fail_status();
      return;
    }
  
    /* clear events count */
< prev index next >