Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
GoeLin committed Nov 24, 2021
1 parent 06e9f96 commit 46c41b6
Show file tree
Hide file tree
Showing 85 changed files with 153 additions and 1,294 deletions.
Expand Up @@ -27,21 +27,8 @@
#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
Expand All @@ -68,8 +55,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
printdump = JNI_TRUE;
}

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;
Expand Down Expand Up @@ -126,6 +112,4 @@ Java_nsk_jvmti_GetImplementedInterfaces_getintrf005_check(JNIEnv *env, jclass cl
return result;
}

#ifdef __cplusplus
}
#endif
Expand Up @@ -27,21 +27,8 @@
#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
Expand All @@ -68,8 +55,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
printdump = JNI_TRUE;
}

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;
Expand Down Expand Up @@ -112,6 +98,4 @@ JNIEXPORT int JNICALL Java_nsk_jvmti_GetImplementedInterfaces_getintrf006_getRes
return result;
}

#ifdef __cplusplus
}
#endif
Expand Up @@ -27,21 +27,8 @@
#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
Expand Down Expand Up @@ -112,8 +99,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
printdump = JNI_TRUE;
}

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;
Expand Down Expand Up @@ -182,6 +168,4 @@ JNIEXPORT int JNICALL Java_nsk_jvmti_GetImplementedInterfaces_getintrf007_getRes
return result;
}

#ifdef __cplusplus
}
#endif
Expand Up @@ -27,9 +27,7 @@
#include "agent_common.h"
#include "jvmti_tools.h"

#ifdef __cplusplus
extern "C" {
#endif

/* ========================================================================== */

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

/* ========================================================================== */

#ifdef __cplusplus
}
#endif
Expand Up @@ -26,9 +26,7 @@
#include "agent_common.h"
#include "jvmti_tools.h"

#ifdef __cplusplus
extern "C" {
#endif

/* ========================================================================== */

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

/* ========================================================================== */

#ifdef __cplusplus
}
#endif
Expand Up @@ -32,19 +32,8 @@
#include "JVMTITools.h"
#include "native_thread.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

#ifndef JNI_ENV_ARG1
#ifdef __cplusplus
Expand Down Expand Up @@ -95,16 +84,14 @@ static void doRedirect(JNIEnv *env) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
"failed to get original JNI function table"));
env->FatalError("failed to get original JNI function table");
}
if ((err = jvmti->GetJNIFunctionTable(&redir_jni_functions)) !=
JVMTI_ERROR_NONE) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get redirected JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
"failed to get redirected JNI function table"));
env->FatalError("failed to get redirected JNI function table");
}
if (verbose)
printf("doRedirect: the JNI function table obtained successfully\n");
Expand All @@ -118,8 +105,7 @@ static void doRedirect(JNIEnv *env) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get new JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
"failed to get new JNI function table"));
env->FatalError("failed to get new JNI function table");
}

if (verbose)
Expand All @@ -136,8 +122,7 @@ static void doRestore(JNIEnv *env) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to restore original JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
"failed to restore original JNI function table"));
env->FatalError("failed to restore original JNI function table");
}
if (verbose)
printf("doRestore: the original JNI function table is restored successfully\n");
Expand All @@ -155,8 +140,7 @@ static void checkRedir(JNIEnv *env, int exCalls) {
result = STATUS_FAILED;
printf("(%s,%d): TEST FAILED: failed to get modified JNI function table: %s\n",
__FILE__, __LINE__, TranslateError(err));
JNI_ENV_PTR(env)->FatalError(JNI_ENV_ARG(env,
"failed to get modified JNI function table"));
env->FatalError("failed to get modified JNI function table");
}
if (verbose)
printf("checkRedir: the JNI function table obtained successfully\n\tcalling GetVersion() ...\n");
Expand Down Expand Up @@ -222,8 +206,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
if (verbose)
printf("verbose mode on\n");

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("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__);
return JNI_ERR;
Expand All @@ -232,6 +215,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_OK;
}

#ifdef __cplusplus
}
#endif
Expand Up @@ -27,19 +27,8 @@
#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

#ifndef JNI_ENV_ARG1
#ifdef __cplusplus
Expand Down Expand Up @@ -100,9 +89,7 @@ Java_nsk_jvmti_GetJNIFunctionTable_getjniftab002_check(JNIEnv *env, jobject obj)
only since JDK 1.2 */
if (verbose)
printf("\nb) Checking the function with the detached thread ...\n\ndetaching the main thread ...\n");
if ((err =
JNI_ENV_PTR(vm)->DetachCurrentThread(
JNI_ENV_ARG1(vm))) != 0)
if ((err = vm->DetachCurrentThread(JNI_ENV_ARG1(vm))) != 0)
printf("(%s,%d): Warning: DetachCurrentThread() returns: %d\n\
\tcheck with the detached main thread skipped\n",
__FILE__, __LINE__, err);
Expand All @@ -111,9 +98,7 @@ Java_nsk_jvmti_GetJNIFunctionTable_getjniftab002_check(JNIEnv *env, jobject obj)

if (verbose)
printf("\nattaching the main thread back ...\n");
if ((err =
JNI_ENV_PTR(vm)->AttachCurrentThread(
JNI_ENV_ARG(vm, (void **) &nextEnv), (void *) 0)) != 0) {
if ((err = vm->AttachCurrentThread((void **) &nextEnv, (void *) 0)) != 0) {
printf("(%s,%d): TEST FAILURE: waitingThread: AttachCurrentThread() returns: %d\n",
__FILE__, __LINE__, err);
return STATUS_FAILED;
Expand Down Expand Up @@ -143,8 +128,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
if (verbose)
printf("verbose mode on\n");

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("(%s,%d): Failed to call GetEnv\n", __FILE__, __LINE__);
return JNI_ERR;
Expand All @@ -155,6 +139,4 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
return JNI_OK;
}

#ifdef __cplusplus
}
#endif
Expand Up @@ -27,21 +27,8 @@
#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
Expand Down Expand Up @@ -76,11 +63,9 @@ void checkMeth(JNIEnv *env, jclass cl, const char *name, const char *sig,
jvmtiLineNumberEntry *exp_table = meth_tab[meth_ind].table;

if (stat) {
mid = JNI_ENV_PTR(env)->
GetStaticMethodID(JNI_ENV_ARG(env, cl), name, sig);
mid = env->GetStaticMethodID(cl, name, sig);
} else {
mid = JNI_ENV_PTR(env)->
GetMethodID(JNI_ENV_ARG(env, cl), name, sig);
mid = env->GetMethodID(cl, name, sig);
}
if (mid == NULL) {
printf("Name = %s, sig = %s: mid = NULL\n", name, sig);
Expand Down Expand Up @@ -146,8 +131,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
jvmtiError err;
jint res;

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;
Expand Down Expand Up @@ -188,6 +172,4 @@ Java_nsk_jvmti_GetLineNumberTable_linetab001_check(JNIEnv *env, jclass cls) {
return result;
}

#ifdef __cplusplus
}
#endif
Expand Up @@ -27,21 +27,8 @@
#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
Expand Down Expand Up @@ -70,8 +57,7 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
printdump = JNI_TRUE;
}

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;
Expand Down Expand Up @@ -121,7 +107,7 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) {
return result;
}

mid = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, cls), "<init>", "()V");
mid = env->GetMethodID(cls, "<init>", "()V");
if (mid == NULL) {
printf("Cannot get method ID!\n");
return STATUS_FAILED;
Expand Down Expand Up @@ -164,6 +150,4 @@ Java_nsk_jvmti_GetLineNumberTable_linetab002_check(JNIEnv *env, jclass cls) {
return result;
}

#ifdef __cplusplus
}
#endif

1 comment on commit 46c41b6

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.