Skip to content

Commit 46c41b6

Browse files
committed
8210429: Clean up JNI_ENV_ARG for vmTestbase/jvmti/Get[G-Z] tests
Remove the JNI_ENV_ARG for the rest of the Get[G-Z] Backport-of: d90f0a5
1 parent 06e9f96 commit 46c41b6

File tree

85 files changed

+153
-1294
lines changed

Some content is hidden

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

85 files changed

+153
-1294
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/getintrf005.cpp

+1-17
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;
@@ -126,6 +112,4 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf005_check(JNIEnv *env, jclass cl
126112
return result;
127113
}
128114

129-
#ifdef __cplusplus
130115
}
131-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/getintrf006.cpp

+1-17
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;
@@ -112,6 +98,4 @@ JNIEXPORT int JNICALL Java_nsk_jvmti_GetImplementedInterfaces_getintrf006_getRes
11298
return result;
11399
}
114100

115-
#ifdef __cplusplus
116101
}
117-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/getintrf007.cpp

+1-17
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
@@ -112,8 +99,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
11299
printdump = JNI_TRUE;
113100
}
114101

115-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
116-
JVMTI_VERSION_1_1);
102+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
117103
if (res != JNI_OK || jvmti == NULL) {
118104
printf("Wrong result of a valid call to GetEnv!\n");
119105
return JNI_ERR;
@@ -182,6 +168,4 @@ JNIEXPORT int JNICALL Java_nsk_jvmti_GetImplementedInterfaces_getintrf007_getRes
182168
return result;
183169
}
184170

185-
#ifdef __cplusplus
186171
}
187-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt001/getjlocfmt001.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
#include "agent_common.h"
2828
#include "jvmti_tools.h"
2929

30-
#ifdef __cplusplus
3130
extern "C" {
32-
#endif
3331

3432
/* ========================================================================== */
3533

@@ -224,6 +222,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
224222

225223
/* ========================================================================== */
226224

227-
#ifdef __cplusplus
228225
}
229-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJLocationFormat/getjlocfmt002/getjlocfmt002.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
#include "agent_common.h"
2727
#include "jvmti_tools.h"
2828

29-
#ifdef __cplusplus
3029
extern "C" {
31-
#endif
3230

3331
/* ========================================================================== */
3432

@@ -97,6 +95,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
9795

9896
/* ========================================================================== */
9997

100-
#ifdef __cplusplus
10198
}
102-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab001/getjniftab001.cpp

+6-25
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,8 @@
3232
#include "JVMTITools.h"
3333
#include "native_thread.h"
3434

35-
#ifdef __cplusplus
3635
extern "C" {
37-
#endif
3836

39-
#ifndef JNI_ENV_ARG
40-
#ifdef __cplusplus
41-
#define JNI_ENV_ARG(x, y) y
42-
#define JNI_ENV_PTR(x) x
43-
#else
44-
#define JNI_ENV_ARG(x, y) x, y
45-
#define JNI_ENV_PTR(x) (*x)
46-
#endif
47-
#endif
4837

4938
#ifndef JNI_ENV_ARG1
5039
#ifdef __cplusplus
@@ -95,16 +84,14 @@ static void doRedirect(JNIEnv *env) {
9584
result = STATUS_FAILED;
9685
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
9786
__FILE__, __LINE__, TranslateError(err));
98-
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
99-
"failed to get original JNI function table"));
87+
env->FatalError("failed to get original JNI function table");
10088
}
10189
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
10290
JVMTI_ERROR_NONE) {
10391
result = STATUS_FAILED;
10492
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
10593
__FILE__, __LINE__, TranslateError(err));
106-
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
107-
"failed to get redirected JNI function table"));
94+
env->FatalError("failed to get redirected JNI function table");
10895
}
10996
if (verbose)
11097
printf("doRedirect: the JNI function table obtained successfully\n");
@@ -118,8 +105,7 @@ static void doRedirect(JNIEnv *env) {
118105
result = STATUS_FAILED;
119106
printf("(%s,%d): TEST FAILED: failed to get new JNI function table: %s\n",
120107
__FILE__, __LINE__, TranslateError(err));
121-
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
122-
"failed to get new JNI function table"));
108+
env->FatalError("failed to get new JNI function table");
123109
}
124110

125111
if (verbose)
@@ -136,8 +122,7 @@ static void doRestore(JNIEnv *env) {
136122
result = STATUS_FAILED;
137123
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
138124
__FILE__, __LINE__, TranslateError(err));
139-
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
140-
"failed to restore original JNI function table"));
125+
env->FatalError("failed to restore original JNI function table");
141126
}
142127
if (verbose)
143128
printf("doRestore: the original JNI function table is restored successfully\n");
@@ -155,8 +140,7 @@ static void checkRedir(JNIEnv *env, int exCalls) {
155140
result = STATUS_FAILED;
156141
printf("(%s,%d): TEST FAILED: failed to get modified JNI function table: %s\n",
157142
__FILE__, __LINE__, TranslateError(err));
158-
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
159-
"failed to get modified JNI function table"));
143+
env->FatalError("failed to get modified JNI function table");
160144
}
161145
if (verbose)
162146
printf("checkRedir: the JNI function table obtained successfully\n\tcalling GetVersion() ...\n");
@@ -222,8 +206,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
222206
if (verbose)
223207
printf("verbose mode on\n");
224208

225-
res = JNI_ENV_PTR(jvm)->
226-
GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
209+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
227210
if (res != JNI_OK || jvmti == NULL) {
228211
printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__);
229212
return JNI_ERR;
@@ -232,6 +215,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
232215
return JNI_OK;
233216
}
234217

235-
#ifdef __cplusplus
236218
}
237-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetJNIFunctionTable/getjniftab002/getjniftab002.cpp

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

30-
#ifdef __cplusplus
3130
extern "C" {
32-
#endif
3331

34-
#ifndef JNI_ENV_ARG
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
42-
#endif
4332

4433
#ifndef JNI_ENV_ARG1
4534
#ifdef __cplusplus
@@ -100,9 +89,7 @@ Java_nsk_jvmti_GetJNIFunctionTable_getjniftab002_check(JNIEnv *env, jobject obj)
10089
only since JDK 1.2 */
10190
if (verbose)
10291
printf("\nb) Checking the function with the detached thread ...\n\ndetaching the main thread ...\n");
103-
if ((err =
104-
JNI_ENV_PTR(vm)->DetachCurrentThread(
105-
JNI_ENV_ARG1(vm))) != 0)
92+
if ((err = vm->DetachCurrentThread(JNI_ENV_ARG1(vm))) != 0)
10693
printf("(%s,%d): Warning: DetachCurrentThread() returns: %d\n\
10794
\tcheck with the detached main thread skipped\n",
10895
__FILE__, __LINE__, err);
@@ -111,9 +98,7 @@ Java_nsk_jvmti_GetJNIFunctionTable_getjniftab002_check(JNIEnv *env, jobject obj)
11198

11299
if (verbose)
113100
printf("\nattaching the main thread back ...\n");
114-
if ((err =
115-
JNI_ENV_PTR(vm)->AttachCurrentThread(
116-
JNI_ENV_ARG(vm, (void **) &nextEnv), (void *) 0)) != 0) {
101+
if ((err = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0)) != 0) {
117102
printf("(%s,%d): TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
118103
__FILE__, __LINE__, err);
119104
return STATUS_FAILED;
@@ -143,8 +128,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
143128
if (verbose)
144129
printf("verbose mode on\n");
145130

146-
res = JNI_ENV_PTR(jvm)->
147-
GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
131+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
148132
if (res != JNI_OK || jvmti == NULL) {
149133
printf("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__);
150134
return JNI_ERR;
@@ -155,6 +139,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
155139
return JNI_OK;
156140
}
157141

158-
#ifdef __cplusplus
159142
}
160-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab001/linetab001.cpp

+3-21
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
@@ -76,11 +63,9 @@ void checkMeth(JNIEnv *env, jclass cl, const char *name, const char *sig,
7663
jvmtiLineNumberEntry *exp_table = meth_tab[meth_ind].table;
7764

7865
if (stat) {
79-
mid = JNI_ENV_PTR(env)->
80-
GetStaticMethodID(JNI_ENV_ARG(env, cl), name, sig);
66+
mid = env->GetStaticMethodID(cl, name, sig);
8167
} else {
82-
mid = JNI_ENV_PTR(env)->
83-
GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
68+
mid = env->GetMethodID(cl, name, sig);
8469
}
8570
if (mid == NULL) {
8671
printf("Name = %s, sig = %s: mid = NULL\n", name, sig);
@@ -146,8 +131,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
146131
jvmtiError err;
147132
jint res;
148133

149-
res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
150-
JVMTI_VERSION_1_1);
134+
res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
151135
if (res != JNI_OK || jvmti == NULL) {
152136
printf("Wrong result of a valid call to GetEnv !\n");
153137
return JNI_ERR;
@@ -188,6 +172,4 @@ Java_nsk_jvmti_GetLineNumberTable_linetab001_check(JNIEnv *env, jclass cls) {
188172
return result;
189173
}
190174

191-
#ifdef __cplusplus
192175
}
193-
#endif

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetLineNumberTable/linetab002/linetab002.cpp

+2-18
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;
@@ -121,7 +107,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) {
121107
return result;
122108
}
123109

124-
mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
110+
mid = env->GetMethodID(cls, "<init>", "()V");
125111
if (mid == NULL) {
126112
printf("Cannot get method ID!\n");
127113
return STATUS_FAILED;
@@ -164,6 +150,4 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) {
164150
return result;
165151
}
166152

167-
#ifdef __cplusplus
168153
}
169-
#endif

0 commit comments

Comments
 (0)