< 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,25 +25,12 @@
#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;
@@ -58,13 +45,13 @@
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);
+ 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,12 +59,11 @@
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);
+ 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,12 +124,11 @@
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);
+ 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,8 +162,6 @@
result = STATUS_FAILED;
}
return result;
}
-#ifdef __cplusplus
}
-#endif
< prev index next >