test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadState/thrstat001/thrstat001.cpp
changeset 51672 b613bf6a10b1
parent 51551 e409244ce72e
child 59264 981a55672786
equal deleted inserted replaced
51671:9f6903174bad 51672:b613bf6a10b1
    25 #include <string.h>
    25 #include <string.h>
    26 #include "jvmti.h"
    26 #include "jvmti.h"
    27 #include "agent_common.h"
    27 #include "agent_common.h"
    28 #include "JVMTITools.h"
    28 #include "JVMTITools.h"
    29 
    29 
    30 #ifdef __cplusplus
       
    31 extern "C" {
    30 extern "C" {
    32 #endif
    31 
    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
       
    43 
       
    44 #endif
       
    45 
    32 
    46 #define PASSED  0
    33 #define PASSED  0
    47 #define STATUS_FAILED  2
    34 #define STATUS_FAILED  2
    48 #define WAIT_START 100
    35 #define WAIT_START 100
    49 #define WAIT_TIME (2*60*1000)
    36 #define WAIT_TIME (2*60*1000)
   115         printf("(GetThreadInfo#TS) unexpected error: %s (%d)\n",
   102         printf("(GetThreadInfo#TS) unexpected error: %s (%d)\n",
   116                TranslateError(err), err);
   103                TranslateError(err), err);
   117         result = STATUS_FAILED;
   104         result = STATUS_FAILED;
   118     }
   105     }
   119     if (thrInfo.name != NULL && strcmp(thrInfo.name, "thr1") == 0) {
   106     if (thrInfo.name != NULL && strcmp(thrInfo.name, "thr1") == 0) {
   120         thr_ptr = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env, thread));
   107         thr_ptr = env->NewGlobalRef(thread);
   121         if (printdump == JNI_TRUE) {
   108         if (printdump == JNI_TRUE) {
   122             printf(">>> ThreadStart: \"%s\", 0x%p\n", thrInfo.name, thr_ptr);
   109             printf(">>> ThreadStart: \"%s\", 0x%p\n", thrInfo.name, thr_ptr);
   123         }
   110         }
   124     }
   111     }
   125 
   112 
   242 
   229 
   243     if (options != NULL && strcmp(options, "printdump") == 0) {
   230     if (options != NULL && strcmp(options, "printdump") == 0) {
   244         printdump = JNI_TRUE;
   231         printdump = JNI_TRUE;
   245     }
   232     }
   246 
   233 
   247     res = JNI_ENV_PTR(jvm)->
   234     res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
   248         GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), JVMTI_VERSION_1_1);
       
   249     if (res != JNI_OK || jvmti == NULL) {
   235     if (res != JNI_OK || jvmti == NULL) {
   250         printf("Wrong result of a valid call to GetEnv!\n");
   236         printf("Wrong result of a valid call to GetEnv!\n");
   251         return JNI_ERR;
   237         return JNI_ERR;
   252     }
   238     }
   253 
   239 
   435     }
   421     }
   436 
   422 
   437     return result;
   423     return result;
   438 }
   424 }
   439 
   425 
   440 #ifdef __cplusplus
   426 }
   441 }
       
   442 #endif