changeset 54744:be7839b9493f

8223044: Add back exception checking in tests Summary: Add exception checking to previously modified tests Reviewed-by: sspitsyn, cjplummer
author jcbeyler
date Tue, 07 May 2019 07:43:41 -0700
parents ba74d2de9a01
children 87d01c0d7b45
files test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002/attach002Agent00.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach022/attach022Agent00.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t003/ap04t003.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/bi01t001.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/bi01t002.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/libbi01t002.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/bi04t002.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/libbi04t002.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/em01t001.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/libem01t001.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/em01t002.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/libem01t002.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/libem02t001.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/libem02t010.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/em02t011.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/libem02t011.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/em02t012.cpp test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/libem02t012.cpp test/hotspot/jtreg/vmTestbase/nsk/share/ExceptionCheckingJniEnv/exceptionjni001/exceptionjni001.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.cpp test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp
diffstat 37 files changed, 293 insertions(+), 308 deletions(-) [+]
line wrap: on
line diff
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002/attach002Agent00.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach002/attach002Agent00.cpp	Tue May 07 07:43:41 2019 -0700
@@ -69,14 +69,14 @@
 #define ATTACH002_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach002/attach002Target"
 
 void registerNativeMethods(JNIEnv* jni_env) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass appClass;
     JNINativeMethod nativeMethods[] = {
             { (char*) "agentGotCapabilities", (char*) "()Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach002_attach002Target_agentGotCapabilities } };
     jint nativeMethodsNumber = 1;
 
-    appClass = jni->FindClass(ATTACH002_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
-    jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
+    appClass = ec_jni->FindClass(ATTACH002_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
+    ec_jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
 }
 
 void JNICALL  classLoadHandler(
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach021/attach021Agent00.cpp	Tue May 07 07:43:41 2019 -0700
@@ -89,15 +89,15 @@
 }
 
 void registerNativeMethods(JNIEnv* jni_env) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass appClass;
     JNINativeMethod nativeMethods[] = {
             { (char*) "setTagFor", (char*) "(Ljava/lang/Object;)Z", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_setTagFor },
             { (char*) "shutdownAgent", (char*) "()V", (void*) Java_nsk_jvmti_AttachOnDemand_attach021_attach021Target_shutdownAgent } };
     jint nativeMethodsNumber = 2;
 
-    appClass = jni->FindClass(ATTACH021_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
-    jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
+    appClass = ec_jni->FindClass(ATTACH021_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
+    ec_jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
 }
 
 #ifdef STATIC_BUILD
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach022/attach022Agent00.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach022/attach022Agent00.cpp	Tue May 07 07:43:41 2019 -0700
@@ -98,15 +98,15 @@
 #define ATTACH022_TARGET_APP_CLASS_NAME "nsk/jvmti/AttachOnDemand/attach022/attach022Target"
 
 void registerNativeMethods(JNIEnv* jni_env) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass appClass;
     JNINativeMethod nativeMethods[] = {
             { (char*)"shutdownAgent", (char*)"(I)Z",
               (void*) Java_nsk_jvmti_AttachOnDemand_attach022_attach022Target_shutdownAgent } };
     jint nativeMethodsNumber = 1;
 
-    appClass = jni->FindClass(ATTACH022_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
-    jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
+    appClass = ec_jni->FindClass(ATTACH022_TARGET_APP_CLASS_NAME, TRACE_JNI_CALL);
+    ec_jni->RegisterNatives(appClass, nativeMethods, nativeMethodsNumber, TRACE_JNI_CALL);
 }
 
 void JNICALL vmObjectAllocHandler(jvmtiEnv * jvmti,
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t003/ap04t003.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/allocation/AP04/ap04t003/ap04t003.cpp	Tue May 07 07:43:41 2019 -0700
@@ -335,13 +335,13 @@
 
 /** Create thread object for new agent thread. */
 static jthread newThreadObj(JNIEnv* jni_env) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass thrClass;
     jmethodID cid;
 
-    thrClass = jni->FindClass("java/lang/Thread", TRACE_JNI_CALL);
-    cid = jni->GetMethodID(thrClass, "<init>", "()V", TRACE_JNI_CALL);
-    return jni->NewObject(thrClass, cid, TRACE_JNI_CALL);
+    thrClass = ec_jni->FindClass("java/lang/Thread", TRACE_JNI_CALL);
+    cid = ec_jni->GetMethodID(thrClass, "<init>", "()V", TRACE_JNI_CALL);
+    return ec_jni->NewObject(thrClass, cid, TRACE_JNI_CALL);
 }
 
 /***********************************************************************/
@@ -491,12 +491,12 @@
 JNIEXPORT void JNICALL
 Java_nsk_jvmti_scenarios_allocation_AP04_ap04t003_runIterateOverObjectsReachableFromObject(JNIEnv* jni_env,
                                                                                            jclass  klass) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jobject root = NULL;
     int modified = 0;
     int found = 0;
 
-    root = jni->GetStaticObjectField(debugeeClass, rootFieldID, TRACE_JNI_CALL);
+    root = ec_jni->GetStaticObjectField(debugeeClass, rootFieldID, TRACE_JNI_CALL);
 
     if (!prepareToIteration(jni_env))
         return;
@@ -524,7 +524,7 @@
 
 static void JNICALL
 agentProc(jvmtiEnv* jvmti, JNIEnv* jni_env, void* arg) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     NSK_DISPLAY0("Wait for debugee start\n\n");
     if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
         return;
@@ -536,10 +536,10 @@
         return;
     }
 
-    debugeeClass = (jclass) jni->NewGlobalRef(debugeeClass, TRACE_JNI_CALL);
+    debugeeClass = (jclass) ec_jni->NewGlobalRef(debugeeClass, TRACE_JNI_CALL);
 
     NSK_DISPLAY1("Find ID of 'root' field: %s\n", ROOT_SIGNATURE);
-    rootFieldID = jni->GetStaticFieldID(debugeeClass, "root",
+    rootFieldID = ec_jni->GetStaticFieldID(debugeeClass, "root",
                                         ROOT_SIGNATURE, TRACE_JNI_CALL);
 
     NSK_DISPLAY0("Let debugee to run test cases\n");
@@ -550,7 +550,7 @@
     if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
         return;
 
-    jni->DeleteGlobalRef(debugeeClass, TRACE_JNI_CALL);
+    ec_jni->DeleteGlobalRef(debugeeClass, TRACE_JNI_CALL);
     NSK_TRACE(jvmti->DestroyRawMonitor(counterMonitor_ptr));
     NSK_TRACE(jvmti->DestroyRawMonitor(startLock));
     NSK_TRACE(jvmti->DestroyRawMonitor(runLock));
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/bi01t001.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t001/bi01t001.cpp	Tue May 07 07:43:41 2019 -0700
@@ -50,18 +50,18 @@
 Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t001_setNewByteCode(JNIEnv *jni_env,
                                                               jobject o,
                                                               jbyteArray byteCode) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jbyte* elements;
     jboolean isCopy;
 
-    newClassSize = jni->GetArrayLength(byteCode, TRACE_JNI_CALL);
+    newClassSize = ec_jni->GetArrayLength(byteCode, TRACE_JNI_CALL);
     if (newClassSize <= 0) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
     NSK_DISPLAY1("\t... got array size: %d\n", newClassSize);
 
-    elements = jni->GetByteArrayElements(byteCode, &isCopy, TRACE_JNI_CALL);
+    elements = ec_jni->GetByteArrayElements(byteCode, &isCopy, TRACE_JNI_CALL);
     NSK_DISPLAY1("\t... got elements list: 0x%p\n", (void*)elements);
 
     if (!NSK_JVMTI_VERIFY(jvmti->Allocate(newClassSize, &newClassBytes))) {
@@ -78,7 +78,7 @@
     NSK_DISPLAY1("\t... copied bytecode: %d bytes\n", (int)newClassSize);
 
     NSK_DISPLAY1("\t... release elements list: 0x%p\n", (void*)elements);
-    jni->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT, TRACE_JNI_CALL);
+    ec_jni->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT, TRACE_JNI_CALL);
     NSK_DISPLAY0("\t... released\n");
     return NSK_TRUE;
 }
@@ -92,8 +92,8 @@
 JNIEXPORT void JNICALL
 Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t001_setClass(JNIEnv *jni_env,
                         jobject o, jclass cls) {
-    ExceptionCheckingJniEnvPtr jni(jni_env);
-    oldClassDef.klass = (jclass) jni->NewGlobalRef(cls, TRACE_JNI_CALL);
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
+    oldClassDef.klass = (jclass) ec_jni->NewGlobalRef(cls, TRACE_JNI_CALL);
 }
 
 /* ============================================================================= */
@@ -149,7 +149,7 @@
 /** Agent algorithm. */
 static void JNICALL
 agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
-    ExceptionCheckingJniEnvPtr jni(agentJNI);
+    ExceptionCheckingJniEnvPtr ec_jni(agentJNI);
 
     /*Wait for debuggee to read new byte codes nsk_jvmti_waitForSync#1*/
     NSK_DISPLAY0("Wait for debuggee to read new byte codes nsk_jvmti_waitForSync#1\n");
@@ -210,7 +210,7 @@
     if (!nsk_jvmti_waitForSync(timeout))
         return;
 
-    jni->DeleteGlobalRef(oldClassDef.klass, TRACE_JNI_CALL);
+    ec_jni->DeleteGlobalRef(oldClassDef.klass, TRACE_JNI_CALL);
 
     NSK_DISPLAY0("Let debuggee to finish\n");
     if (!nsk_jvmti_resumeSync())
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/bi01t002.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/bi01t002.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
@@ -51,21 +52,18 @@
 Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t002_setNewByteCode(JNIEnv *jni_env,
                         jobject o, jint ind, jbyteArray byteCode) {
 
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jbyte* elements;
     jboolean isCopy;
 
-    newClassSize[ind] = jni_env->GetArrayLength(byteCode);
-    if (!NSK_JNI_VERIFY(jni_env, newClassSize[ind] > 0)) {
+    newClassSize[ind] = ec_jni->GetArrayLength(byteCode, TRACE_JNI_CALL);
+    if (!NSK_VERIFY(newClassSize[ind] > 0)) {
         nsk_jvmti_setFailStatus();
         return NSK_FALSE;
     }
     NSK_DISPLAY1("\t... got array size: %d\n", newClassSize[ind]);
 
-    elements = jni_env->GetByteArrayElements(byteCode, &isCopy);
-    if (!NSK_JNI_VERIFY(jni_env, elements != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return NSK_FALSE;
-    }
+    elements = ec_jni->GetByteArrayElements(byteCode, &isCopy, TRACE_JNI_CALL);
     NSK_DISPLAY1("\t... got elements list: 0x%p\n", (void*)elements);
 
     if (!NSK_JVMTI_VERIFY(jvmti->Allocate(newClassSize[ind], &newClassBytes[ind]))) {
@@ -82,7 +80,7 @@
     NSK_DISPLAY1("\t... copied bytecode: %d bytes\n", (int)newClassSize[ind]);
 
     NSK_DISPLAY1("\t... release elements list: 0x%p\n", (void*)elements);
-    NSK_TRACE(jni_env->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT));
+    NSK_TRACE(ec_jni->ReleaseByteArrayElements(byteCode, elements, JNI_ABORT, TRACE_JNI_CALL));
     NSK_DISPLAY0("\t... released\n");
     return NSK_TRUE;
 }
@@ -97,10 +95,8 @@
 Java_nsk_jvmti_scenarios_bcinstr_BI01_bi01t002_setClass(JNIEnv *jni_env,
                         jobject o, jint ind, jclass cls) {
 
-    oldClassDef[ind].klass = (jclass) jni_env->NewGlobalRef(cls);
-    if (!NSK_JNI_VERIFY(jni_env, oldClassDef[ind].klass != NULL)) {
-        nsk_jvmti_setFailStatus();
-    }
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
+    oldClassDef[ind].klass = (jclass) ec_jni->NewGlobalRef(cls, TRACE_JNI_CALL);
 }
 
 /* ============================================================================= */
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/libbi01t002.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI01/bi01t002/libbi01t002.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/bi04t002.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/bi04t002.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 
@@ -91,23 +92,15 @@
 static void JNICALL
 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
 
+    ExceptionCheckingJniEnvPtr ec_jni(jni);
     /*Wait for debuggee to set classes to be redefined nsk_jvmti_waitForSync#4*/
     NSK_DISPLAY0("Wait for debuggee to set classes to be redefined nsk_jvmti_waitForSync#4\n");
     if (!nsk_jvmti_waitForSync(timeout))
         return;
 
     NSK_DISPLAY1("Find class: %s\n", TESTED_CLASS_NAME);
-    classDef.klass = jni->FindClass(TESTED_CLASS_NAME);
-    if (!NSK_JNI_VERIFY(jni, classDef.klass != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return;
-    }
-
-    classDef.klass = (jclass) jni->NewGlobalRef(classDef.klass);
-    if (!NSK_JNI_VERIFY(jni, classDef.klass != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return;
-    }
+    classDef.klass = ec_jni->FindClass(TESTED_CLASS_NAME, TRACE_JNI_CALL);
+    classDef.klass = (jclass) ec_jni->NewGlobalRef(classDef.klass, TRACE_JNI_CALL);
 
     NSK_DISPLAY0("Redfine class with new byte code\n");
     NSK_DISPLAY3("class definition:\n\t0x%p, 0x%p:%d\n",
@@ -123,7 +116,7 @@
         return;
     }
 
-    jni->DeleteGlobalRef(classDef.klass);
+    ec_jni->DeleteGlobalRef(classDef.klass, TRACE_JNI_CALL);
 
     if (!nsk_jvmti_resumeSync())
         return;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/libbi04t002.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/bcinstr/BI04/bi04t002/libbi04t002.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/em01t001.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/em01t001.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 #include "JVMTITools.h"
@@ -135,17 +136,13 @@
 void
 threadEventHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env,
                             jthread thread) {
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass classObject;
     char *className;
     char *generic;
     jvmtiPhase phase;
 
-
-    classObject = jni_env->GetObjectClass(thread);
-    if (!NSK_JNI_VERIFY(jni_env, classObject != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return;
-    }
+    classObject = ec_jni->GetObjectClass(thread, TRACE_JNI_CALL);
 
     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(classObject, &className, &generic))) {
         nsk_jvmti_setFailStatus();
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/libem01t001.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t001/libem01t001.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/em01t002.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/em01t002.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 #include "JVMTITools.h"
@@ -61,28 +62,16 @@
 JNIEXPORT jclass JNICALL
 Java_nsk_jvmti_scenarios_events_EM01_em01t002_loadClass(JNIEnv *jni_env,
                         jobject o, jobject loader, jstring className) {
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass klass;
     jmethodID methodID;
     jclass loadedClass;
 
-    klass = jni_env->GetObjectClass(loader);
-    if (!NSK_JNI_VERIFY(jni_env, klass != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return NULL;
-    }
-
-    methodID = jni_env->GetMethodID(
-            klass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
-    if (!NSK_JNI_VERIFY(jni_env, methodID != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return NULL;
-    }
-
-    loadedClass = (jclass) jni_env->CallObjectMethod(loader, methodID, className);
-    if (!NSK_JNI_VERIFY(jni_env, loadedClass != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return NULL;
-    }
+    klass = ec_jni->GetObjectClass(loader, TRACE_JNI_CALL);
+    methodID = ec_jni->GetMethodID(
+            klass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;", TRACE_JNI_CALL);
+    loadedClass = (jclass) ec_jni->CallObjectMethod(loader, methodID,
+                                                    TRACE_JNI_CALL_VARARGS(className));
 
     return loadedClass;
 }
@@ -93,16 +82,12 @@
  * Signature: (Ljava/lang/Class;)Z
  */
 JNIEXPORT jboolean JNICALL
-Java_nsk_jvmti_scenarios_events_EM01_em01t002_prepareClass(JNIEnv *jni_env,
+Java_nsk_jvmti_scenarios_events_EM01_em01t002_prepareClass(JNIEnv *jni,
                         jobject o, jclass klass) {
+    ExceptionCheckingJniEnvPtr ec_jni(jni);
     jfieldID fieldID;
 
-    fieldID = jni_env->GetStaticFieldID(klass, "toProvokePreparation", "I");
-    if (!NSK_JNI_VERIFY(jni_env, fieldID != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return NSK_FALSE;
-    }
-
+    fieldID = ec_jni->GetStaticFieldID(klass, "toProvokePreparation", "I", TRACE_JNI_CALL);
     return NSK_TRUE;
 }
 
@@ -114,26 +99,13 @@
 JNIEXPORT jboolean JNICALL
 Java_nsk_jvmti_scenarios_events_EM01_em01t002_startThread(JNIEnv *jni_env,
                         jobject o, jobject thread) {
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass klass;
     jmethodID methodID;
 
-    klass = jni_env->GetObjectClass(thread);
-    if (!NSK_JNI_VERIFY(jni_env, klass != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return NSK_FALSE;
-    }
-
-    methodID = jni_env->GetMethodID(klass, "start", "()V");
-    if (!NSK_JNI_VERIFY(jni_env, methodID != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return NSK_FALSE;
-    }
-
-    if (!NSK_JNI_VERIFY_VOID(jni_env,jni_env->CallVoidMethod(thread, methodID))) {
-        nsk_jvmti_setFailStatus();
-        return NSK_FALSE;
-    }
-
+    klass = ec_jni->GetObjectClass(thread, TRACE_JNI_CALL);
+    methodID = ec_jni->GetMethodID(klass, "start", "()V", TRACE_JNI_CALL);
+    ec_jni->CallVoidMethod(thread, methodID, TRACE_JNI_CALL);
     return NSK_TRUE;
 }
 
@@ -224,17 +196,14 @@
 void
 threadEventHandler(jvmtiEvent event, jvmtiEnv* jvmti_env, JNIEnv* jni_env,
                             jthread thread) {
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
     jclass classObject;
     char *className;
     char *generic;
     jvmtiPhase phase;
 
 
-    classObject = jni_env->GetObjectClass(thread);
-    if (!NSK_JNI_VERIFY(jni_env, classObject != NULL)) {
-        nsk_jvmti_setFailStatus();
-        return;
-    }
+    classObject = ec_jni->GetObjectClass(thread, TRACE_JNI_CALL);
 
     if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(classObject, &className, &generic))) {
         nsk_jvmti_setFailStatus();
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/libem01t002.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM01/em01t002/libem01t002.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/em02t001.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 #include "JVMTITools.h"
@@ -102,24 +103,20 @@
 getStaticObjField(const char* className, const char* objFieldName,
                     const char* signature) {
 
+    ExceptionCheckingJniEnvPtr ec_jni(jni);
     jfieldID fieldID;
     jclass klass = NULL;
 
-    klass = jni->FindClass(className);
-    if (!NSK_JNI_VERIFY(jni, klass != NULL))
-        return NULL;
-
-    fieldID = jni->GetStaticFieldID(klass, objFieldName, signature);
-    if (!NSK_JNI_VERIFY(jni, fieldID != NULL))
-        return NULL;
-
-    return jni->GetStaticObjectField(klass, fieldID);
+    klass = ec_jni->FindClass(className, TRACE_JNI_CALL);
+    fieldID = ec_jni->GetStaticFieldID(klass, objFieldName, signature, TRACE_JNI_CALL);
+    return ec_jni->GetStaticObjectField(klass, fieldID, TRACE_JNI_CALL);
 }
 
 /* ============================================================================= */
 
 static int prepare() {
 
+    ExceptionCheckingJniEnvPtr ec_jni(jni);
     mainThread = findThread(MAIN_THREAD_NAME);
     if (!NSK_VERIFY(mainThread != NULL)) {
         NSK_COMPLAIN1("<%s> thread not found\n", MAIN_THREAD_NAME);
@@ -127,29 +124,20 @@
     }
 
     /* make thread accessable for a long time */
-    mainThread = jni->NewGlobalRef(mainThread);
-    if (!NSK_JNI_VERIFY(jni, mainThread != NULL))
-        return NSK_FALSE;
-
+    mainThread = ec_jni->NewGlobalRef(mainThread, TRACE_JNI_CALL);
     startObject = getStaticObjField(DEBUGEE_CLASS_NAME, START_FIELD_NAME, OBJECT_FIELD_SIG);
     if (!NSK_VERIFY(startObject != NULL))
         return NSK_FALSE;
 
     /*make object accessable for a long time*/
-    startObject = jni->NewGlobalRef(startObject);
-    if (!NSK_JNI_VERIFY(jni, startObject != NULL))
-        return NSK_FALSE;
-
+    startObject = ec_jni->NewGlobalRef(startObject, TRACE_JNI_CALL);
 
     endObject = getStaticObjField(DEBUGEE_CLASS_NAME, END_FIELD_NAME, OBJECT_FIELD_SIG);
     if (!NSK_VERIFY(endObject != NULL))
         return NSK_FALSE;
 
     /*make object accessable for a long time*/
-    endObject = jni->NewGlobalRef(endObject);
-    if (!NSK_JNI_VERIFY(jni, endObject != NULL))
-        return NSK_FALSE;
-
+    endObject = ec_jni->NewGlobalRef(endObject, TRACE_JNI_CALL);
 
     debuggeeThread = (jthread) getStaticObjField(DEBUGEE_CLASS_NAME,
                                                  THREAD_FIELD_NAME,
@@ -158,10 +146,7 @@
         return NSK_FALSE;
 
     /* make thread accessable for a long time */
-    debuggeeThread = jni->NewGlobalRef(debuggeeThread);
-    if (!NSK_JNI_VERIFY(jni, debuggeeThread != NULL))
-        return NSK_FALSE;
-
+    debuggeeThread = ec_jni->NewGlobalRef(debuggeeThread, TRACE_JNI_CALL);
     return NSK_TRUE;
 }
 
@@ -170,6 +155,7 @@
 static int
 clean() {
 
+    ExceptionCheckingJniEnvPtr ec_jni(jni);
     /* disable MonitorContendedEnter event */
     if (!NSK_JVMTI_VERIFY(
             jvmti->SetEventNotificationMode(
@@ -177,10 +163,10 @@
         nsk_jvmti_setFailStatus();
 
     /* dispose global references */
-    jni->DeleteGlobalRef(startObject);
-    jni->DeleteGlobalRef(endObject);
-    jni->DeleteGlobalRef(debuggeeThread);
-    jni->DeleteGlobalRef(mainThread);
+    ec_jni->DeleteGlobalRef(startObject, TRACE_JNI_CALL);
+    ec_jni->DeleteGlobalRef(endObject, TRACE_JNI_CALL);
+    ec_jni->DeleteGlobalRef(debuggeeThread, TRACE_JNI_CALL);
+    ec_jni->DeleteGlobalRef(mainThread, TRACE_JNI_CALL);
 
     startObject = NULL;
     endObject = NULL;
@@ -409,18 +395,19 @@
 handlerMC1(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env,
                             jthread thread, jobject object,
                             jthread expectedThread, jobject expectedObject) {
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
     if (expectedThread == NULL || expectedObject == NULL)
         return;
 
     /* check if event is for tested thread and for tested object */
-    if (jni_env->IsSameObject(expectedThread, thread) &&
-            jni_env->IsSameObject(expectedObject, object)) {
+    if (ec_jni->IsSameObject(expectedThread, thread, TRACE_JNI_CALL) &&
+            ec_jni->IsSameObject(expectedObject, object, TRACE_JNI_CALL)) {
 
         NSK_DISPLAY1("--->%-40s is received\n", TranslateEvent(event));
 
         showThreadInfo(thread);
-        if (jni_env->IsSameObject(expectedObject, endObject))
+        if (ec_jni->IsSameObject(expectedObject, endObject, TRACE_JNI_CALL))
             NSK_DISPLAY0("\tobject: 'endingMonitor'\n");
         else
             NSK_DISPLAY0("\tobject: 'startingMonitor'\n");
@@ -495,18 +482,19 @@
 handlerMC2(jvmtiEvent event, jvmtiEnv* jvmti, JNIEnv* jni_env,
                             jthread thread, jobject object,
                             jthread expectedThread, jobject expectedObject) {
+    ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
     if (expectedThread == NULL || expectedObject == NULL)
         return;
 
     /* check if event is for tested thread and for tested object */
-    if (jni_env->IsSameObject(expectedThread, thread) &&
-            jni_env->IsSameObject(expectedObject, object)) {
+    if (ec_jni->IsSameObject(expectedThread, thread, TRACE_JNI_CALL) &&
+            ec_jni->IsSameObject(expectedObject, object, TRACE_JNI_CALL)) {
 
         NSK_DISPLAY1("--->%-40s is received (new callbacks)\n", TranslateEvent(event));
 
         showThreadInfo(thread);
-        if (jni_env->IsSameObject(expectedObject, endObject))
+        if (ec_jni->IsSameObject(expectedObject, endObject, TRACE_JNI_CALL))
             NSK_DISPLAY0("\tobject: 'endingMonitor'\n");
         else
             NSK_DISPLAY0("\tobject: 'startingMonitor'\n");
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/libem02t001.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t001/libem02t001.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/em02t010.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 #include "JVMTITools.h"
@@ -451,6 +452,7 @@
 static void JNICALL
 agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
 
+    ExceptionCheckingJniEnvPtr ec_jni(agentJNI);
     int i;
     jfieldID field_accID, field_modID;
     jclass cls;
@@ -459,17 +461,9 @@
     if (!nsk_jvmti_waitForSync(timeout))
         return;
 
-    cls = agentJNI->FindClass(CLASS_NAME);
-    if (!NSK_JNI_VERIFY(agentJNI, cls != NULL))
-        return;
-
-    field_accID = agentJNI->GetStaticFieldID(cls, FIELD_ACC_NAME, "I");
-    if (!NSK_JNI_VERIFY(agentJNI, field_accID != NULL))
-        return;
-
-    field_modID = agentJNI->GetStaticFieldID(cls, FIELD_MOD_NAME, "I");
-    if (!NSK_JNI_VERIFY(agentJNI, field_modID != NULL))
-        return;
+    cls = ec_jni->FindClass(CLASS_NAME, TRACE_JNI_CALL);
+    field_accID = ec_jni->GetStaticFieldID(cls, FIELD_ACC_NAME, "I", TRACE_JNI_CALL);
+    field_modID = ec_jni->GetStaticFieldID(cls, FIELD_MOD_NAME, "I", TRACE_JNI_CALL);
 
     if (!NSK_JVMTI_VERIFY(jvmti->SetFieldModificationWatch(cls, field_modID)))
         return;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/libem02t010.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t010/libem02t010.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/em02t011.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/em02t011.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 #include "JVMTITools.h"
@@ -436,6 +437,7 @@
 static void JNICALL
 agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
 
+    ExceptionCheckingJniEnvPtr ec_jni(agentJNI);
     int i;
     jmethodID methodID;
     jclass cls;
@@ -444,13 +446,8 @@
     if (!nsk_jvmti_waitForSync(timeout))
         return;
 
-    cls = agentJNI->FindClass(CLASS_NAME);
-    if (!NSK_JNI_VERIFY(agentJNI, cls != NULL))
-        return;
-
-    methodID = agentJNI->GetStaticMethodID(cls, METHOD_NAME, "()I");
-    if (!NSK_JNI_VERIFY(agentJNI, methodID != NULL))
-        return;
+    cls = ec_jni->FindClass(CLASS_NAME, TRACE_JNI_CALL);
+    methodID = ec_jni->GetStaticMethodID(cls, METHOD_NAME, "()I", TRACE_JNI_CALL);
 
     if (!NSK_JVMTI_VERIFY(jvmti->SetBreakpoint(methodID, 0)))
         return;
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/libem02t011.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t011/libem02t011.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/em02t012.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/em02t012.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
 #include <string.h>
 #include "jvmti.h"
 #include "agent_common.h"
+#include "ExceptionCheckingJniEnv.hpp"
 #include "jni_tools.h"
 #include "jvmti_tools.h"
 #include "JVMTITools.h"
@@ -48,12 +49,11 @@
 
 /* ============================================================================= */
 JNIEXPORT void JNICALL
-Java_nsk_jvmti_scenarios_events_EM02_em02t012_setThread(JNIEnv *jni_env,
+Java_nsk_jvmti_scenarios_events_EM02_em02t012_setThread(JNIEnv *jni,
                         jobject o, jthread thrd) {
-
+    ExceptionCheckingJniEnvPtr ec_jni(jni);
     /* make thread accessable for a long time */
-    testedThread = jni_env->NewGlobalRef(thrd);
-    NSK_JNI_VERIFY(jni_env, testedThread != NULL);
+    testedThread = ec_jni->NewGlobalRef(thrd, TRACE_JNI_CALL);
 }
 
 static void
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/libem02t012.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/events/EM02/em02t012/libem02t012.cpp	Tue May 07 07:43:41 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * questions.
  */
 
+#include "ExceptionCheckingJniEnv.cpp"
 #include "native_thread.cpp"
 #include "nsk_tools.cpp"
 #include "jni_tools.cpp"
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/ExceptionCheckingJniEnv/exceptionjni001/exceptionjni001.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/ExceptionCheckingJniEnv/exceptionjni001/exceptionjni001.cpp	Tue May 07 07:43:41 2019 -0700
@@ -79,69 +79,69 @@
 }
 
 static bool checkSuccess(JNIEnv* env, jclass cls) {
-  ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
+  ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
   is_error_called = false;
 
-  jni->GetFieldID(cls, "anInteger", "I", TRACE_JNI_CALL);
+  ec_jni->GetFieldID(cls, "anInteger", "I", TRACE_JNI_CALL);
   return !is_error_called;
 }
 
 static bool checkFailureMessageReturnNull(JNIEnv* env, jclass cls) {
-  ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
+  ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
 
   expected_message_start = null_return_expected_message_start;
   expected_line_number = __LINE__ + 1;
-  jni->GetFieldID(cls, "whatever", "does not matter", TRACE_JNI_CALL);
+  ec_jni->GetFieldID(cls, "whatever", "does not matter", TRACE_JNI_CALL);
 
   return is_error_called && error_message_ok;
 }
 
 static bool checkFailureMessageEmptyFile(JNIEnv* env, jclass cls) {
-  ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
+  ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
 
   expected_message_start = null_file_expected_message_start;
   expected_line_number = __LINE__ + 1;
-  jni->GetFieldID(cls, "whatever", "does not matter", __LINE__, NULL);
+  ec_jni->GetFieldID(cls, "whatever", "does not matter", __LINE__, NULL);
 
   return is_error_called && error_message_ok;
 }
 
 static bool checkFailureMessageNilLine(JNIEnv* env, jclass cls) {
-  ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
+  ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
 
   expected_message_start = null_return_expected_message_start;
   expected_line_number = 0;
-  jni->GetFieldID(cls, "whatever", "does not matter", 0, __FILE__);
+  ec_jni->GetFieldID(cls, "whatever", "does not matter", 0, __FILE__);
 
   return is_error_called && error_message_ok;
 }
 
 static bool checkFailureMessageNegativeLine(JNIEnv* env, jclass cls) {
-  ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
+  ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
 
   expected_message_start = null_return_expected_message_start;
   expected_line_number = -1;
-  jni->GetFieldID(cls, "whatever", "does not matter", -1, __FILE__);
+  ec_jni->GetFieldID(cls, "whatever", "does not matter", -1, __FILE__);
 
   return is_error_called && error_message_ok;
 }
 
 static bool checkFailureMessageMinLine(JNIEnv* env, jclass cls) {
-  ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
+  ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
 
   expected_message_start = null_return_expected_message_start;
   expected_line_number = INT32_MIN;
-  jni->GetFieldID(cls, "whatever", "does not matter", INT32_MIN, __FILE__);
+  ec_jni->GetFieldID(cls, "whatever", "does not matter", INT32_MIN, __FILE__);
 
   return is_error_called && error_message_ok;
 }
 
 static bool checkFailureMessageMaxLine(JNIEnv* env, jclass cls) {
-  ExceptionCheckingJniEnvPtr jni(env, ErrorCheckerMessage);
+  ExceptionCheckingJniEnvPtr ec_jni(env, ErrorCheckerMessage);
 
   expected_message_start = null_return_expected_message_start;
   expected_line_number = INT32_MAX;
-  jni->GetFieldID(cls, "whatever", "does not matter", INT32_MAX, __FILE__);
+  ec_jni->GetFieldID(cls, "whatever", "does not matter", INT32_MAX, __FILE__);
 
   return is_error_called && error_message_ok;
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/BooleanArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jboolean JNICALL Java_nsk_share_gc_lock_jni_BooleanArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jbooleanArray arr;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jbooleanArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jbooleanArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = (jboolean*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jboolean*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash ^= pa[i];
@@ -65,11 +65,11 @@
                         hash = JNI_FALSE;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ByteArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -36,7 +36,7 @@
  */
 JNIEXPORT jbyte JNICALL Java_nsk_share_gc_lock_jni_ByteArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jbyteArray arr;
@@ -45,18 +45,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jbyteArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jbyteArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = (jbyte*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jbyte*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash ^= pa[i];
@@ -64,11 +64,11 @@
                         hash = 0;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/CharArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_CharArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jcharArray arr;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jcharArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jcharArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         current_time = 0;
         enterTime /= 1000;
         while (current_time - start_time < enterTime) {
-                pa = (jchar*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jchar*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash ^= pa[i];
@@ -65,11 +65,11 @@
                         hash = 0;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/DoubleArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jdouble JNICALL Java_nsk_share_gc_lock_jni_DoubleArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jdoubleArray arr;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jdoubleArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jdoubleArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = (jdouble*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jdouble*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash += pa[i];
@@ -65,11 +65,11 @@
                         hash = 0;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/FloatArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jfloat JNICALL Java_nsk_share_gc_lock_jni_FloatArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jfloatArray arr;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jfloatArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jfloatArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = (jfloat*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jfloat*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash += pa[i];
@@ -65,11 +65,11 @@
                         hash = 0;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/IntArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jint JNICALL Java_nsk_share_gc_lock_jni_IntArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jintArray arr;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jintArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jintArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = (jint*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jint*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash ^= pa[i];
@@ -65,11 +65,11 @@
                         hash = 0;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/LongArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jlong JNICALL Java_nsk_share_gc_lock_jni_LongArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jlongArray arr;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jlongArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jlongArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = (jlong*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jlong*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash ^= pa[i];
@@ -65,11 +65,11 @@
                         hash = 0;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/ShortArrayCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jshort JNICALL Java_nsk_share_gc_lock_jni_ShortArrayCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jshortArray arr;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        arr = (jshortArray) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        arr = (jshortArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetArrayLength(arr, TRACE_JNI_CALL);
+        size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = (jshort*) jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
+                pa = (jshort*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash ^= pa[i];
@@ -65,11 +65,11 @@
                         hash = 0;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
+                ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jni/StringCriticalLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,7 +37,7 @@
  */
 JNIEXPORT jchar JNICALL Java_nsk_share_gc_lock_jni_StringCriticalLocker_criticalNative
 (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jsize size, i;
         jstring str;
@@ -46,18 +46,18 @@
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        str = (jstring) jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        str = (jstring) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
-        size = jni->GetStringLength(str, TRACE_JNI_CALL);
+        size = ec_jni->GetStringLength(str, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                pa = jni->GetStringCritical(str, NULL, TRACE_JNI_CALL);
+                pa = ec_jni->GetStringCritical(str, NULL, TRACE_JNI_CALL);
                 if (pa != NULL) {
                         for (i = 0; i < size; ++i)
                                 hash ^= pa[i];
@@ -65,11 +65,11 @@
                         hash = JNI_FALSE;
                 }
                 mssleep((long) sleepTime);
-                jni->ReleaseStringCritical(str, pa, TRACE_JNI_CALL);
+                ec_jni->ReleaseStringCritical(str, pa, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, str, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, str, TRACE_JNI_CALL);
         return hash;
 }
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIGlobalRefLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -38,29 +38,29 @@
  */
 JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIGlobalRefLocker_criticalNative
   (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jobject obj;
         jobject gref;
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                gref = jni->NewGlobalRef(obj, TRACE_JNI_CALL);
+                gref = ec_jni->NewGlobalRef(obj, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
-                jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
+                ec_jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
 }
 
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNILocalRefLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,29 +37,29 @@
  */
 JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNILocalRefLocker_criticalNative
   (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jobject obj;
         jobject gref;
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                gref = jni->NewLocalRef(obj, TRACE_JNI_CALL);
+                gref = ec_jni->NewLocalRef(obj, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
-                jni->DeleteLocalRef(gref, TRACE_JNI_CALL);
+                ec_jni->DeleteLocalRef(gref, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
 }
 
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIRefLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,35 +37,35 @@
  */
 JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIRefLocker_criticalNative
   (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jobject obj;
         jobject gref, lref, gwref;
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
 
-        obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                gref = jni->NewGlobalRef(obj, TRACE_JNI_CALL);
-                lref = jni->NewLocalRef(obj, TRACE_JNI_CALL);
-                gwref = jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
+                gref = ec_jni->NewGlobalRef(obj, TRACE_JNI_CALL);
+                lref = ec_jni->NewLocalRef(obj, TRACE_JNI_CALL);
+                gwref = ec_jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
-                jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
-                jni->DeleteLocalRef(lref, TRACE_JNI_CALL);
-                jni->DeleteWeakGlobalRef(gwref, TRACE_JNI_CALL);
+                ec_jni->DeleteGlobalRef(gref, TRACE_JNI_CALL);
+                ec_jni->DeleteLocalRef(lref, TRACE_JNI_CALL);
+                ec_jni->DeleteWeakGlobalRef(gwref, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
 }
 
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jniref/JNIWeakGlobalRefLocker.cpp	Tue May 07 07:43:41 2019 -0700
@@ -37,30 +37,30 @@
  */
 JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jniref_JNIWeakGlobalRefLocker_criticalNative
   (JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
-        ExceptionCheckingJniEnvPtr jni(jni_env);
+        ExceptionCheckingJniEnvPtr ec_jni(jni_env);
 
         jobject obj;
         jobject gref;
         time_t start_time, current_time;
 
         if (objFieldId == NULL) {
-                jclass klass = jni->GetObjectClass(o, TRACE_JNI_CALL);
-                objFieldId = jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
+                jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
+                objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
         }
-        obj = jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
-        jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
+        obj = ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
 
         start_time = time(NULL);
         enterTime /= 1000;
         current_time = 0;
         while (current_time - start_time < enterTime) {
-                gref = jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
+                gref = ec_jni->NewWeakGlobalRef(obj, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
-                jni->DeleteWeakGlobalRef(gref, TRACE_JNI_CALL);
+                ec_jni->DeleteWeakGlobalRef(gref, TRACE_JNI_CALL);
                 mssleep((long) sleepTime);
                 current_time = time(NULL);
         }
-        jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
+        ec_jni->SetObjectField(o, objFieldId, obj, TRACE_JNI_CALL);
 }
 
 }
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.cpp	Tue May 07 07:43:41 2019 -0700
@@ -426,6 +426,17 @@
   return marker.ResultNotNull(_jni_env->GetMethodID(klass, name, sig));
 }
 
+jmethodID ExceptionCheckingJniEnv::GetStaticMethodID(jclass klass, const char* name, const char* sig,
+                                                     int line, const char* file_name) {
+  JNIVerifier<jmethodID> marker(this, "GetStaticMethodID", klass, name, sig, line, file_name);
+  return marker.ResultNotNull(_jni_env->GetStaticMethodID(klass, name, sig));
+}
+
+jboolean ExceptionCheckingJniEnv::IsSameObject(jobject ref1, jobject ref2, int line, const char* file_name) {
+  JNIVerifier<> marker(this, "IsSameObject", ref1, ref2, line, file_name);
+  return _jni_env->IsSameObject(ref1, ref2);
+}
+
 jobject ExceptionCheckingJniEnv::NewObject(jclass klass, jmethodID methodID,
                                            int line, const char* file_name, ...) {
   // In the case of NewObject, we miss the extra arguments passed to NewObject sadly.
@@ -437,3 +448,24 @@
   va_end(args);
   return result;
 }
+
+jobject ExceptionCheckingJniEnv::CallObjectMethod(jobject obj, jmethodID methodID, int line,
+                         const char* file_name, ...) {
+  JNIVerifier<> marker(this, "CallObjectMethod", obj, methodID, line, file_name);
+
+  va_list args;
+  va_start(args, file_name);
+  jobject result = _jni_env->CallObjectMethodV(obj, methodID, args);
+  va_end(args);
+  return result;
+}
+
+void ExceptionCheckingJniEnv::CallVoidMethod(jobject obj, jmethodID methodID, int line,
+                    const char* file_name, ...) {
+  JNIVerifier<> marker(this, "CallVoidMethod", obj, methodID, line, file_name);
+
+  va_list args;
+  va_start(args, file_name);
+  _jni_env->CallVoidMethodV(obj, methodID, args);
+  va_end(args);
+}
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp	Tue May 07 15:39:33 2019 +0100
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jni/ExceptionCheckingJniEnv.hpp	Tue May 07 07:43:41 2019 -0700
@@ -59,6 +59,7 @@
  */
 
 #define TRACE_JNI_CALL __LINE__, __FILE__
+#define TRACE_JNI_CALL_VARARGS(...) __LINE__, __FILE__, __VA_ARGS__
 
 class ExceptionCheckingJniEnv {
  public:
@@ -69,6 +70,8 @@
                             int line, const char* file_name);
   jfieldID GetFieldID(jclass klass, const char* name, const char* type,
                       int line, const char* file_name);
+  jmethodID GetStaticMethodID(jclass klass, const char* name, const char* sig,
+                              int line, const char* file_name);
   jmethodID GetMethodID(jclass klass, const char* name, const char* sig,
                         int line, const char* file_name);
 
@@ -106,6 +109,14 @@
   jweak NewWeakGlobalRef(jobject obj, int line, const char* file_name);
   void DeleteWeakGlobalRef(jweak obj, int line, const char* file_name);
 
+  jboolean IsSameObject(jobject ref1, jobject ref2, int line,
+                        const char* file_name);
+
+  jobject CallObjectMethod(jobject obj, jmethodID methodID, int line,
+                           const char* file_name, ...);
+  void CallVoidMethod(jobject obj, jmethodID methodID, int line,
+                      const char* file_name, ...);
+
   // ExceptionCheckingJniEnv methods.
   JNIEnv* GetJNIEnv() {
     return _jni_env;