< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/setNullVMInit/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:

*** 34,64 **** #include <inttypes.h> #include "jvmti.h" #include "jni_tools.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; } --- 34,44 ----
*** 84,117 **** intptr_t get_env_local() { jvmtiError res; void *val; ! res = JVMTI_ENV_PTR(jvmti)->GetEnvironmentLocalStorage(JVMTI_ENV_ARG(jvmti, &val)); JVMTI_ERROR_CHECK("GetEnvironmentLocalStorage returned error", res); return (intptr_t)val; } void set_env_local(intptr_t x) { jvmtiError res; void *val = (void*)x; ! res = JVMTI_ENV_PTR(jvmti)->SetEnvironmentLocalStorage(JVMTI_ENV_ARG(jvmti, val)); JVMTI_ERROR_CHECK_VOID("SetEnvironmentLocalStorage returned error", res); } intptr_t get_thread_local(jthread thread) { jvmtiError res; void *val; ! res = JVMTI_ENV_PTR(jvmti)->GetThreadLocalStorage(JVMTI_ENV_ARG(jvmti, thread), &val); JVMTI_ERROR_CHECK("GetThreadLocalStorage returned error", res); return (intptr_t)val; } void set_thread_local(jthread thread, intptr_t x) { jvmtiError res; void *val = (void*)x; ! res = JVMTI_ENV_PTR(jvmti)->SetThreadLocalStorage(JVMTI_ENV_ARG(jvmti, thread), val); JVMTI_ERROR_CHECK_VOID("SetThreadLocalStorage returned error", res); } void check_val(intptr_t x, intptr_t y, const char* msg) { if (x != y) { --- 64,97 ---- intptr_t get_env_local() { jvmtiError res; void *val; ! res = jvmti->GetEnvironmentLocalStorage(&val); JVMTI_ERROR_CHECK("GetEnvironmentLocalStorage returned error", res); return (intptr_t)val; } void set_env_local(intptr_t x) { jvmtiError res; void *val = (void*)x; ! res = jvmti->SetEnvironmentLocalStorage(val); JVMTI_ERROR_CHECK_VOID("SetEnvironmentLocalStorage returned error", res); } intptr_t get_thread_local(jthread thread) { jvmtiError res; void *val; ! res = jvmti->GetThreadLocalStorage(thread, &val); JVMTI_ERROR_CHECK("GetThreadLocalStorage returned error", res); return (intptr_t)val; } void set_thread_local(jthread thread, intptr_t x) { jvmtiError res; void *val = (void*)x; ! res = jvmti->SetThreadLocalStorage(thread, val); JVMTI_ERROR_CHECK_VOID("SetThreadLocalStorage returned error", res); } void check_val(intptr_t x, intptr_t y, const char* msg) { if (x != y) {
*** 162,173 **** if (strstr(options, "printdump")) { printdump = 1; } } ! res = JNI_ENV_PTR(jvm)-> ! GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1); if (res < 0) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; } --- 142,152 ---- if (strstr(options, "printdump")) { printdump = 1; } } ! res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); if (res < 0) { printf("Wrong result of a valid call to GetEnv!\n"); return JNI_ERR; }
*** 177,190 **** set_env_local(14); check_val(get_env_local(), 14, "env set non-zero"); /* Enable events */ init_callbacks(); ! res = JVMTI_ENV_PTR(jvmti)->SetEventCallbacks(JVMTI_ENV_ARG(jvmti, &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); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); return JNI_OK; } --- 156,169 ---- set_env_local(14); check_val(get_env_local(), 14, "env set non-zero"); /* Enable events */ init_callbacks(); ! res = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)); JVMTI_ERROR_CHECK("SetEventCallbacks returned error", res); ! res = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT,NULL); JVMTI_ERROR_CHECK("SetEventNotificationMode for VM_INIT returned error", res); return JNI_OK; }
*** 199,206 **** check_val(get_thread_local(NULL), 0, "thread check"); return iGlobalStatus; } - #ifdef __cplusplus } - #endif --- 178,183 ----
< prev index next >