< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/agentthr/agentthr.cpp

Print this page
rev 51722 : 8210700: Clean up JNI_ENV_ARG and factorize the macros for vmTestbase/jvmti/unit tests
Summary:
Reviewed-by:

*** 25,49 **** #include <string.h> #include "jvmti.h" #include "agent_common.h" #include "JVMTITools.h" - #ifdef __cplusplus extern "C" { - #endif - - #ifndef JNI_ENV_ARG - - #ifdef __cplusplus - #define JNI_ENV_ARG(x, y) y - #define JNI_ENV_PTR(x) x - #else - #define JNI_ENV_ARG(x,y) x, y - #define JNI_ENV_PTR(x) (*x) - #endif - #endif #define PASSED 0 #define STATUS_FAILED 2 static JavaVM *jvm_ins; --- 25,36 ----
*** 58,70 **** jthread jthr(JNIEnv *env) { jclass thrClass; jmethodID cid; jthread res; ! thrClass = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, "java/lang/Thread")); ! cid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, thrClass), "<init>", "()V"); ! res = JNI_ENV_PTR(env)->NewObject(JNI_ENV_ARG(env, thrClass), cid); return res; } void JNICALL agent_start(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void *p) { JNIEnv *env; --- 45,57 ---- jthread jthr(JNIEnv *env) { jclass thrClass; jmethodID cid; jthread res; ! thrClass = env->FindClass("java/lang/Thread"); ! cid = env->GetMethodID(thrClass, "<init>", "()V"); ! res = env->NewObject(thrClass, cid); return res; } void JNICALL agent_start(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void *p) { JNIEnv *env;
*** 72,83 **** if (jvmti_env != jvmti) { printf("(agent_start) JVMTI envs don't match\n"); result = STATUS_FAILED; } ! JNI_ENV_PTR(jvm_ins)->GetEnv(JNI_ENV_ARG(jvm_ins, (void **) &env), ! JNI_VERSION_1_2); if (jni_env != env) { printf("(agent_start) JNI envs don't match\n"); result = STATUS_FAILED; } --- 59,69 ---- if (jvmti_env != jvmti) { printf("(agent_start) JVMTI envs don't match\n"); result = STATUS_FAILED; } ! jvm_ins->GetEnv((void **) &env, JNI_VERSION_1_2); if (jni_env != env) { printf("(agent_start) JNI envs don't match\n"); result = STATUS_FAILED; }
*** 138,149 **** if (options != NULL && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } jvm_ins = jvm; ! res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), ! JVMTI_VERSION_1_1); if (res != JNI_OK || jvmti == NULL) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } --- 124,134 ---- if (options != NULL && strcmp(options, "printdump") == 0) { printdump = JNI_TRUE; } jvm_ins = jvm; ! res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); if (res != JNI_OK || jvmti == NULL) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; }
*** 177,184 **** result = STATUS_FAILED; } return result; } - #ifdef __cplusplus } - #endif --- 162,167 ----
< prev index next >