< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/functions/nosuspendMonitorInfo/JvmtiTest/JvmtiTest.cpp
Print this page
rev 51722 : 8210700: Clean up JNI_ENV_ARG and factorize the macros for vmTestbase/jvmti/unit tests
Summary:
Reviewed-by:
@@ -24,31 +24,12 @@
#include <stdio.h>
#include <string.h>
#include "jvmti.h"
#include "agent_common.h"
-#ifdef __cplusplus
extern "C" {
-#endif
-
-#ifndef JNI_ENV_ARG
-#ifdef __cplusplus
-#define JNI_ENV_ARG(x, y) y
-#define JNI_ENV_ARG1(x)
-#define JNI_ENV_PTR(x) x
-#else
-#define JNI_ENV_ARG(x,y) x, y
-#define JNI_ENV_ARG1(x) x
-#define JNI_ENV_PTR(x) (*x)
-#endif
-
-#endif
-
-#define JVMTI_ENV_ARG JNI_ENV_ARG
-#define JVMTI_ENV_ARG1 JNI_ENV_ARG1
-#define JVMTI_ENV_PTR JNI_ENV_PTR
#define JVMTI_ERROR_CHECK(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); return res;}
#define JVMTI_ERROR_CHECK_EXPECTED_ERROR(str,res,err) if ( res != err) { printf(str); printf("unexpected error %d\n",res); return res;}
#define JVMTI_ERROR_CHECK_VOID(str,res) if ( res != JVMTI_ERROR_NONE) { printf(str); printf("%d\n",res); iGlobalStatus = 2; }
@@ -132,34 +113,33 @@
if (strstr(options, "printdump")) {
printdump = 1;
}
}
- 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 < 0) {
debug_printf("Wrong result of a valid call to GetEnv!\n");
return JNI_ERR;
}
/* Add capabilities */
- res = JVMTI_ENV_PTR(jvmti)->GetPotentialCapabilities(JVMTI_ENV_ARG(jvmti, &jvmti_caps));
+ res = jvmti->GetPotentialCapabilities(&jvmti_caps);
JVMTI_ERROR_CHECK("GetPotentialCapabilities returned error", res);
- res = JVMTI_ENV_PTR(jvmti)->AddCapabilities(JVMTI_ENV_ARG(jvmti, &jvmti_caps));
+ res = jvmti->AddCapabilities(&jvmti_caps);
JVMTI_ERROR_CHECK("GetPotentialCapabilities returned error", res);
/* Enable events */
init_callbacks();
- res = JVMTI_ENV_PTR(jvmti)->SetEventCallbacks(JVMTI_ENV_ARG(jvmti, &callbacks), sizeof(callbacks));
+ res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res);
- res = JVMTI_ENV_PTR(jvmti)->SetEventNotificationMode(JVMTI_ENV_ARG(jvmti,JVMTI_ENABLE),JVMTI_EVENT_VM_INIT,NULL);
+ res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL);
JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res);
- res = JVMTI_ENV_PTR(jvmti)->SetEventNotificationMode(JVMTI_ENV_ARG(jvmti,JVMTI_ENABLE),JVMTI_EVENT_VM_DEATH,NULL);
+ res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL);
JVMTI_ERROR_CHECK("SetEventNotificationMode for vm death event returned error", res);
return JNI_OK;
}
@@ -177,30 +157,28 @@
jobject *owned_monitor;
debug_printf(" jvmti GetMonitorInfo \n");
- ret = JVMTI_ENV_PTR(jvmti)->GetOwnedMonitorInfo(JVMTI_ENV_ARG(jvmti, thr), &count , &owned_monitor);
+ ret = jvmti->GetOwnedMonitorInfo(thr, &count, &owned_monitor);
if (ret != JVMTI_ERROR_NONE) {
printf("Error: GetMonitorInfo %d \n", ret);
iGlobalStatus = 2;
}
if (expected_count != 0 && expected_count != count) {
printf("Error: GetMonitorInfo expected count %d but got %d \n", expected_count, count);
iGlobalStatus = 2;
}
- if (expected_count !=0 ) {
+ if (expected_count !=0) {
- ret = JVMTI_ENV_PTR(jvmti)->GetCurrentContendedMonitor(JVMTI_ENV_ARG(jvmti, thr), owned_monitor);
+ ret = jvmti->GetCurrentContendedMonitor(thr, owned_monitor);
if (ret != JVMTI_ERROR_NONE) {
printf("Error: GetContendedMonitorInfo %d \n", ret);
iGlobalStatus = 2;
}
}
}
-#ifdef __cplusplus
}
-#endif
< prev index next >