Skip to content

Commit 8fcfaef

Browse files
committed
8210593: Clean up JNI_ENV_ARG and factorize the macros for vmTestbase/jvmti[N-R] tests
Remove JNI_ENV/JVMTI_ENV macros from N to R jvmti tests Backport-of: 6a2e431
1 parent 46c41b6 commit 8fcfaef

File tree

50 files changed

+168
-1049
lines changed

Some content is hidden

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

50 files changed

+168
-1049
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe001/popframe001.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 STATUS_FAILED 2
4734
#define PASSED 0
@@ -195,8 +182,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
195182
jint res;
196183
jvmtiError err;
197184

198-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
199-
JVMTI_VERSION_1_1);
185+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
200186
if (res != JNI_OK || jvmti == NULL) {
201187
printf("Wrong result of a valid call to GetEnv!\n");
202188
return JNI_ERR;
@@ -257,6 +243,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
257243
return JNI_OK;
258244
}
259245

260-
#ifdef __cplusplus
261246
}
262-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe002/popframe002.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 STATUS_FAILED 2
4734
#define PASSED 0
@@ -211,8 +198,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
211198
jint res;
212199
jvmtiError err;
213200

214-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
215-
JVMTI_VERSION_1_1);
201+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
216202
if (res != JNI_OK || jvmti == NULL) {
217203
printf("Wrong result of a valid call to GetEnv!\n");
218204
return JNI_ERR;
@@ -268,6 +254,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
268254
return JNI_OK;
269255
}
270256

271-
#ifdef __cplusplus
272257
}
273-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe003/popframe003.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 STATUS_FAILED 2
4734
#define PASSED 0
@@ -196,8 +183,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
196183
jint res;
197184
jvmtiError err;
198185

199-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
200-
JVMTI_VERSION_1_1);
186+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
201187
if (res != JNI_OK || jvmti == NULL) {
202188
printf("Wrong result of a valid call to GetEnv!\n");
203189
return JNI_ERR;
@@ -258,6 +244,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
258244
return JNI_OK;
259245
}
260246

261-
#ifdef __cplusplus
262247
}
263-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe004/popframe004.cpp

Lines changed: 4 additions & 22 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 STATUS_FAILED 2
4734
#define PASSED 0
@@ -220,8 +207,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
220207
jint res;
221208
jvmtiError err;
222209

223-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
224-
JVMTI_VERSION_1_1);
210+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
225211
if (res != JNI_OK || jvmti == NULL) {
226212
printf("Wrong result of a valid call to GetEnv!\n");
227213
return JNI_ERR;
@@ -289,12 +275,10 @@ Java_nsk_jvmti_PopFrame_popframe004_getResult(JNIEnv *env, jclass cls) {
289275

290276
void nativeMeth2(JNIEnv *env, jobject obj, jint vrb,
291277
jobject frameThr) {
292-
jclass cls =
293-
JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, frameThr));
278+
jclass cls = env->GetObjectClass(frameThr);
294279
jmethodID mid = NULL;
295280

296-
if ((mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls),
297-
"activeMethod", "()V")) == NULL) {
281+
if ((mid = env->GetMethodID(cls, "activeMethod", "()V")) == NULL) {
298282
printf("TEST FAILURE: nativeMeth2(): Unable to get method ID\n");
299283
tot_result = STATUS_FAILED;
300284
return;
@@ -303,7 +287,7 @@ void nativeMeth2(JNIEnv *env, jobject obj, jint vrb,
303287
printf("nativeMeth2(): calling the Java activeMethod()\n");
304288
fflush(stdout);
305289
}
306-
JNI_ENV_PTR(env)->CallVoidMethod(JNI_ENV_ARG(env, frameThr), mid);
290+
env->CallVoidMethod(frameThr, mid);
307291
}
308292

309293
JNIEXPORT void JNICALL
@@ -316,6 +300,4 @@ Java_nsk_jvmti_PopFrame_popframe004_nativeMeth(JNIEnv *env, jobject obj, jint vr
316300
nativeMeth2(env, obj, vrb, frameThr);
317301
}
318302

319-
#ifdef __cplusplus
320303
}
321-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe006/popframe006.cpp

Lines changed: 6 additions & 26 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
@@ -364,8 +351,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
364351
printdump = JNI_TRUE;
365352
}
366353

367-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
368-
JVMTI_VERSION_1_1);
354+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
369355
if (res != JNI_OK || jvmti == NULL) {
370356
printf("Wrong result of a valid call to GetEnv!\n");
371357
return JNI_ERR;
@@ -435,39 +421,35 @@ Java_nsk_jvmti_PopFrame_popframe006_getReady(JNIEnv *env,
435421
return;
436422
}
437423

438-
clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr));
424+
clazz = env->GetObjectClass(thr);
439425
if (clazz == NULL) {
440426
printf("Cannot get the class of thread object\n");
441427
result = STATUS_FAILED;
442428
return;
443429
}
444430

445-
mid_run = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
446-
"run", "()V");
431+
mid_run = env->GetMethodID(clazz, "run", "()V");
447432
if (mid_run == NULL) {
448433
printf("Cannot find Method ID for method \"run\"\n");
449434
result = STATUS_FAILED;
450435
return;
451436
}
452437

453-
mid_A = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
454-
"A", "()V");
438+
mid_A = env->GetStaticMethodID(clazz, "A", "()V");
455439
if (mid_A == NULL) {
456440
printf("Cannot find Method ID for method \"A\"\n");
457441
result = STATUS_FAILED;
458442
return;
459443
}
460444

461-
mid_B = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
462-
"B", "()V");
445+
mid_B = env->GetStaticMethodID(clazz, "B", "()V");
463446
if (mid_B == NULL) {
464447
printf("Cannot find Method ID for method \"B\"\n");
465448
result = STATUS_FAILED;
466449
return;
467450
}
468451

469-
mid_C = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
470-
"C", "()V");
452+
mid_C = env->GetStaticMethodID(clazz, "C", "()V");
471453
if (mid_C == NULL) {
472454
printf("Cannot find Method ID for method \"C\"\n");
473455
result = STATUS_FAILED;
@@ -529,6 +511,4 @@ Java_nsk_jvmti_PopFrame_popframe006_getRes(JNIEnv *env, jclass cls) {
529511
return result;
530512
}
531513

532-
#ifdef __cplusplus
533514
}
534-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe007/popframe007.cpp

Lines changed: 4 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
@@ -103,8 +90,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
10390
printdump = JNI_TRUE;
10491
}
10592

106-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
107-
JVMTI_VERSION_1_1);
93+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
10894
if (res != JNI_OK || jvmti == NULL) {
10995
printf("Wrong result of a valid call to GetEnv!\n");
11096
return JNI_ERR;
@@ -166,15 +152,14 @@ Java_nsk_jvmti_PopFrame_popframe007_getReady(JNIEnv *env,
166152
return;
167153
}
168154

169-
clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr));
155+
clazz = env->GetObjectClass(thr);
170156
if (clazz == NULL) {
171157
printf("Cannot get class of the thread object\n");
172158
result = STATUS_FAILED;
173159
return;
174160
}
175161

176-
mid = JNI_ENV_PTR(env)->GetStaticMethodID(JNI_ENV_ARG(env, clazz),
177-
"C", "()V");
162+
mid = env->GetStaticMethodID(clazz, "C", "()V");
178163
if (mid == NULL) {
179164
printf("Cannot find Method ID for method \"C\"\n");
180165
result = STATUS_FAILED;
@@ -206,10 +191,8 @@ Java_nsk_jvmti_PopFrame_popframe007_getRes(JNIEnv *env, jclass cls) {
206191
JNIEXPORT void JNICALL
207192
Java_nsk_jvmti_PopFrame_popframe007_B(JNIEnv *env, jclass cls) {
208193
if (mid != NULL) {
209-
JNI_ENV_PTR(env)->CallStaticVoidMethod(JNI_ENV_ARG(env, cls), mid);
194+
env->CallStaticVoidMethod(cls, mid);
210195
}
211196
}
212197

213-
#ifdef __cplusplus
214198
}
215-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/PopFrame/popframe008/popframe008.cpp

Lines changed: 4 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
@@ -212,8 +199,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
212199
printdump = JNI_TRUE;
213200
}
214201

215-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
216-
JVMTI_VERSION_1_1);
202+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
217203
if (res != JNI_OK || jvmti == NULL) {
218204
printf("Wrong result of a valid call to GetEnv!\n");
219205
return JNI_ERR;
@@ -279,22 +265,21 @@ Java_nsk_jvmti_PopFrame_popframe008_getReady(JNIEnv *env,
279265
return;
280266
}
281267

282-
clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr));
268+
clazz = env->GetObjectClass(thr);
283269
if (clazz == NULL) {
284270
printf("Cannot get class of the thread object\n");
285271
result = STATUS_FAILED;
286272
return;
287273
}
288274

289-
midD = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz), "D", "()V");
275+
midD = env->GetMethodID(clazz, "D", "()V");
290276
if (midD == NULL) {
291277
printf("Cannot get Method ID for method \"D\"\n");
292278
result = STATUS_FAILED;
293279
return;
294280
}
295281

296-
midRun = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz),
297-
"run", "()V");
282+
midRun = env->GetMethodID(clazz, "run", "()V");
298283
if (midRun == NULL) {
299284
printf("Cannot get Method ID for method \"run\"\n");
300285
result = STATUS_FAILED;
@@ -328,6 +313,4 @@ Java_nsk_jvmti_PopFrame_popframe008_getRes(JNIEnv *env, jclass cls) {
328313
return result;
329314
}
330315

331-
#ifdef __cplusplus
332316
}
333-
#endif

0 commit comments

Comments
 (0)