Skip to content

Commit d256eb9

Browse files
author
Jean Christophe Beyler
committed
8210198: Clean up JNI_ENV_ARG for vmTestbase/jvmti/Get[A-F] tests
Remove JNI_ENV macros from the Get[A-F] tests Reviewed-by: sspitsyn, amenkov, cjplummer
1 parent bac1c9b commit d256eb9

56 files changed

Lines changed: 77 additions & 839 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr001/allthr001.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,8 @@
2828
#include "agent_common.h"
2929
#include "JVMTITools.h"
3030

31-
#ifdef __cplusplus
3231
extern "C" {
33-
#endif
34-
35-
#ifndef JNI_ENV_ARG
36-
37-
#ifdef __cplusplus
38-
#define JNI_ENV_ARG(x, y) y
39-
#define JNI_ENV_PTR(x) x
40-
#else
41-
#define JNI_ENV_ARG(x,y) x, y
42-
#define JNI_ENV_PTR(x) (*x)
43-
#endif
4432

45-
#endif
4633

4734
#define PASSED 0
4835
#define STATUS_FAILED 2
@@ -70,11 +57,9 @@ jthread jthr(JNIEnv *env) {
7057
jclass thrClass;
7158
jmethodID cid;
7259
jthread res;
73-
thrClass = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env,
74-
"java/lang/Thread"));
75-
cid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, thrClass),
76-
"<init>", "()V");
77-
res = JNI_ENV_PTR(env)->NewObject(JNI_ENV_ARG(env, thrClass), cid);
60+
thrClass = env->FindClass("java/lang/Thread");
61+
cid = env->GetMethodID(thrClass, "<init>", "()V");
62+
res = env->NewObject(thrClass, cid);
7863
return res;
7964
}
8065

@@ -143,8 +128,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
143128
printdump = JNI_TRUE;
144129
}
145130

146-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
147-
JVMTI_VERSION_1_1);
131+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
148132
if (res != JNI_OK || jvmti == NULL) {
149133
printf("Wrong result of a valid call to GetEnv !\n");
150134
return JNI_ERR;
@@ -313,6 +297,4 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetAllThreads_allthr001_getRes(JNIEnv *env
313297
return result;
314298
}
315299

316-
#ifdef __cplusplus
317300
}
318-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAllThreads/allthr002/allthr002.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,8 @@
2727
#include "agent_common.h"
2828
#include "JVMTITools.h"
2929

30-
#ifdef __cplusplus
3130
extern "C" {
32-
#endif
33-
34-
#ifndef JNI_ENV_ARG
35-
36-
#ifdef __cplusplus
37-
#define JNI_ENV_ARG(x, y) y
38-
#define JNI_ENV_PTR(x) x
39-
#else
40-
#define JNI_ENV_ARG(x,y) x, y
41-
#define JNI_ENV_PTR(x) (*x)
42-
#endif
4331

44-
#endif
4532

4633
#define PASSED 0
4734
#define STATUS_FAILED 2
@@ -68,8 +55,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
6855
printdump = JNI_TRUE;
6956
}
7057

71-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
72-
JVMTI_VERSION_1_1);
58+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
7359
if (res != JNI_OK || jvmti == NULL) {
7460
printf("Wrong result of a valid call to GetEnv!\n");
7561
return JNI_ERR;
@@ -116,6 +102,4 @@ Java_nsk_jvmti_GetAllThreads_allthr002_check(JNIEnv *env, jclass cls) {
116102
return result;
117103
}
118104

119-
#ifdef __cplusplus
120105
}
121-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize001/argsize001.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,8 @@
2626
#include "agent_common.h"
2727
#include "JVMTITools.h"
2828

29-
#ifdef __cplusplus
3029
extern "C" {
31-
#endif
32-
33-
#ifndef JNI_ENV_ARG
34-
35-
#ifdef __cplusplus
36-
#define JNI_ENV_ARG(x, y) y
37-
#define JNI_ENV_PTR(x) x
38-
#else
39-
#define JNI_ENV_ARG(x,y) x, y
40-
#define JNI_ENV_PTR(x) (*x)
41-
#endif
4230

43-
#endif
4431

4532
#define PASSED 0
4633
#define STATUS_FAILED 2
@@ -54,10 +41,9 @@ void chk(JNIEnv *env, jclass cl, const char *name, const char *sig, int stat, in
5441
jint ret_size;
5542

5643
if (stat) {
57-
mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
58-
name, sig);
44+
mid = env->GetStaticMethodID(cl, name, sig);
5945
} else {
60-
mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
46+
mid = env->GetMethodID(cl, name, sig);
6147
}
6248
if (mid == NULL) {
6349
printf("Name = %s, sig = %s: mid = 0\n", name, sig);
@@ -89,8 +75,7 @@ JNIEXPORT jint JNI_OnLoad_argsize001(JavaVM *jvm, char *options, void *reserved)
8975
jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
9076
jint res;
9177

92-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
93-
JVMTI_VERSION_1_1);
78+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
9479
if (res != JNI_OK || jvmti == NULL) {
9580
printf("Wrong result of a valid call to GetEnv !\n");
9681
return JNI_ERR;
@@ -114,6 +99,4 @@ Java_nsk_jvmti_GetArgumentsSize_argsize001_check(JNIEnv *env, jclass cls,
11499
return result;
115100
}
116101

117-
#ifdef __cplusplus
118102
}
119-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetArgumentsSize/argsize002/argsize002.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,8 @@
2727
#include "agent_common.h"
2828
#include "JVMTITools.h"
2929

30-
#ifdef __cplusplus
3130
extern "C" {
32-
#endif
33-
34-
#ifndef JNI_ENV_ARG
35-
36-
#ifdef __cplusplus
37-
#define JNI_ENV_ARG(x, y) y
38-
#define JNI_ENV_PTR(x) x
39-
#else
40-
#define JNI_ENV_ARG(x,y) x, y
41-
#define JNI_ENV_PTR(x) (*x)
42-
#endif
4331

44-
#endif
4532

4633
#define PASSED 0
4734
#define STATUS_FAILED 2
@@ -68,8 +55,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
6855
printdump = JNI_TRUE;
6956
}
7057

71-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
72-
JVMTI_VERSION_1_1);
58+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
7359
if (res != JNI_OK || jvmti == NULL) {
7460
printf("Wrong result of a valid call to GetEnv!\n");
7561
return JNI_ERR;
@@ -89,7 +75,7 @@ Java_nsk_jvmti_GetArgumentsSize_argsize002_check(JNIEnv *env, jclass cls) {
8975
return STATUS_FAILED;
9076
}
9177

92-
mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
78+
mid = env->GetMethodID(cls, "<init>", "()V");
9379
if (mid == NULL) {
9480
printf("Cannot get method ID for \"<init>\"!\n");
9581
return STATUS_FAILED;
@@ -115,8 +101,7 @@ Java_nsk_jvmti_GetArgumentsSize_argsize002_check(JNIEnv *env, jclass cls) {
115101
result = STATUS_FAILED;
116102
}
117103

118-
mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
119-
"check", "()I");
104+
mid = env->GetStaticMethodID(cls, "check", "()I");
120105
if (mid == NULL) {
121106
printf("Cannot get method ID for \"check\"!\n");
122107
return STATUS_FAILED;
@@ -139,6 +124,4 @@ Java_nsk_jvmti_GetArgumentsSize_argsize002_check(JNIEnv *env, jclass cls) {
139124
return result;
140125
}
141126

142-
#ifdef __cplusplus
143127
}
144-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetAvailableProcessors/getavailproc001/getavailproc001.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
#include "jni_tools.h"
2929
#include "jvmti_tools.h"
3030

31-
#ifdef __cplusplus
3231
extern "C" {
33-
#endif
3432

3533
/* ============================================================================= */
3634

@@ -185,6 +183,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
185183

186184
/* ============================================================================= */
187185

188-
#ifdef __cplusplus
189186
}
190-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes001/bytecodes001.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,8 @@
2727
#include "agent_common.h"
2828
#include "JVMTITools.h"
2929

30-
#ifdef __cplusplus
3130
extern "C" {
32-
#endif
33-
34-
#ifndef JNI_ENV_ARG
35-
36-
#ifdef __cplusplus
37-
#define JNI_ENV_ARG(x, y) y
38-
#define JNI_ENV_PTR(x) x
39-
#else
40-
#define JNI_ENV_ARG(x,y) x, y
41-
#define JNI_ENV_PTR(x) (*x)
42-
#endif
4331

44-
#endif
4532

4633
#define PASSED 0
4734
#define STATUS_FAILED 2
@@ -87,8 +74,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
8774
printdump = JNI_TRUE;
8875
}
8976

90-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
91-
JVMTI_VERSION_1_1);
77+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
9278
if (res != JNI_OK || jvmti == NULL) {
9379
printf("Wrong result of a valid call to GetEnv!\n");
9480
return JNI_ERR;
@@ -142,10 +128,10 @@ void checkMeth(JNIEnv *env, jclass cl, int meth_ind) {
142128
}
143129

144130
if (meth_tab[meth_ind].stat == JNI_TRUE) {
145-
mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cl),
131+
mid = env->GetStaticMethodID(cl,
146132
meth_tab[meth_ind].name, meth_tab[meth_ind].sig);
147133
} else {
148-
mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cl),
134+
mid = env->GetMethodID(cl,
149135
meth_tab[meth_ind].name, meth_tab[meth_ind].sig);
150136
}
151137
if (mid == NULL) {
@@ -194,6 +180,4 @@ JNIEXPORT jint JNICALL Java_nsk_jvmti_GetBytecodes_bytecodes001_check(JNIEnv *en
194180
return result;
195181
}
196182

197-
#ifdef __cplusplus
198183
}
199-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes002/bytecodes002.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,8 @@
2727
#include "agent_common.h"
2828
#include "JVMTITools.h"
2929

30-
#ifdef __cplusplus
3130
extern "C" {
32-
#endif
33-
34-
#ifndef JNI_ENV_ARG
35-
36-
#ifdef __cplusplus
37-
#define JNI_ENV_ARG(x, y) y
38-
#define JNI_ENV_PTR(x) x
39-
#else
40-
#define JNI_ENV_ARG(x,y) x, y
41-
#define JNI_ENV_PTR(x) (*x)
42-
#endif
4331

44-
#endif
4532

4633
#define PASSED 0
4734
#define STATUS_FAILED 2
@@ -70,8 +57,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
7057
printdump = JNI_TRUE;
7158
}
7259

73-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
74-
JVMTI_VERSION_1_1);
60+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
7561
if (res != JNI_OK || jvmti == NULL) {
7662
printf("Wrong result of a valid call to GetEnv!\n");
7763
return JNI_ERR;
@@ -123,8 +109,7 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) {
123109
return STATUS_FAILED;
124110
}
125111

126-
mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
127-
"<init>", "()V");
112+
mid = env->GetMethodID(cls, "<init>", "()V");
128113
if (mid == NULL) {
129114
printf("Cannot get method ID for \"<init>\"!\n");
130115
return STATUS_FAILED;
@@ -166,8 +151,7 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) {
166151
result = STATUS_FAILED;
167152
}
168153

169-
mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, cls),
170-
"check", "()I");
154+
mid = env->GetStaticMethodID(cls, "check", "()I");
171155
if (mid == NULL) {
172156
printf("Cannot get method ID for \"check\"!\n");
173157
return STATUS_FAILED;
@@ -190,6 +174,4 @@ Java_nsk_jvmti_GetBytecodes_bytecodes002_check(JNIEnv *env, jclass cls) {
190174
return result;
191175
}
192176

193-
#ifdef __cplusplus
194177
}
195-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetBytecodes/bytecodes003/bytecodes003.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,8 @@
2727
#include "agent_common.h"
2828
#include "JVMTITools.h"
2929

30-
#ifdef __cplusplus
3130
extern "C" {
32-
#endif
33-
34-
#ifndef JNI_ENV_ARG
35-
36-
#ifdef __cplusplus
37-
#define JNI_ENV_ARG(x, y) y
38-
#define JNI_ENV_PTR(x) x
39-
#else
40-
#define JNI_ENV_ARG(x,y) x, y
41-
#define JNI_ENV_PTR(x) (*x)
42-
#endif
4331

44-
#endif
4532

4633
#define PASSED 0
4734
#define STATUS_FAILED 2
@@ -366,8 +353,7 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti_env, JNIEnv *env,
366353
name = NULL;
367354
msig = NULL;
368355
bytecodes = NULL;
369-
err = jvmti_env->GetMethodName(methods[i],
370-
&name, &msig, NULL);
356+
err = jvmti_env->GetMethodName(methods[i], &name, &msig, NULL);
371357
if (err != JVMTI_ERROR_NONE) {
372358
printf("(GetMethodName) unexpected error: %s (%d)\n",
373359
TranslateError(err), err);
@@ -446,8 +432,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
446432
printdump = JNI_TRUE;
447433
}
448434

449-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
450-
JVMTI_VERSION_1_1);
435+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
451436
if (res != JNI_OK || jvmti == NULL) {
452437
printf("Wrong result of a valid call to GetEnv!\n");
453438
return JNI_ERR;
@@ -535,6 +520,4 @@ Java_nsk_jvmti_GetBytecodes_bytecodes003_check(JNIEnv *env, jclass cls) {
535520
return result;
536521
}
537522

538-
#ifdef __cplusplus
539523
}
540-
#endif

0 commit comments

Comments
 (0)