test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClearFieldAccessWatch/clrfldw001/clrfldw001.cpp
changeset 51699 543a3fb81c4c
parent 51551 e409244ce72e
child 52776 c05ba185a1d3
equal deleted inserted replaced
51698:74dde8b66b7f 51699:543a3fb81c4c
    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 
    35 
    49 typedef struct {
    36 typedef struct {
    72     jvmtiError err;
    59     jvmtiError err;
    73     jclass cls;
    60     jclass cls;
    74     field fld = fields[ind];
    61     field fld = fields[ind];
    75     const char *msg;
    62     const char *msg;
    76 
    63 
    77     cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, fld.klass));
    64     cls = env->FindClass(fld.klass);
    78     if (fld.fid == NULL) {
    65     if (fld.fid == NULL) {
    79         if (fld.stat) {
    66         if (fld.stat) {
    80             fields[ind].fid = JNI_ENV_PTR(env)->
    67             fields[ind].fid = env->GetStaticFieldID(cls, fld.name, fld.sig);
    81                     GetStaticFieldID(JNI_ENV_ARG(env, cls), fld.name, fld.sig);
       
    82         } else {
    68         } else {
    83             fields[ind].fid = JNI_ENV_PTR(env)->
    69             fields[ind].fid = env->GetFieldID(cls, fld.name, fld.sig);
    84                     GetFieldID(JNI_ENV_ARG(env, cls), fld.name, fld.sig);
       
    85         }
    70         }
    86     }
    71     }
    87 
    72 
    88     if (on == JNI_TRUE) {
    73     if (on == JNI_TRUE) {
    89         msg = "Set";
    74         msg = "Set";
   121 #endif
   106 #endif
   122 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
   107 jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
   123     jint res;
   108     jint res;
   124     jvmtiError err;
   109     jvmtiError err;
   125 
   110 
   126     res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti),
   111     res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
   127         JVMTI_VERSION_1_1);
       
   128     if (res != JNI_OK || jvmti == NULL) {
   112     if (res != JNI_OK || jvmti == NULL) {
   129         printf("Wrong result of a valid call to GetEnv !\n");
   113         printf("Wrong result of a valid call to GetEnv !\n");
   130         return JNI_ERR;
   114         return JNI_ERR;
   131     }
   115     }
   132 
   116 
   189 JNIEXPORT void JNICALL
   173 JNIEXPORT void JNICALL
   190 Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_touchfld0(JNIEnv *env,
   174 Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_touchfld0(JNIEnv *env,
   191         jobject obj) {
   175         jobject obj) {
   192     jint val;
   176     jint val;
   193 
   177 
   194     val = JNI_ENV_PTR(env)->GetIntField(JNI_ENV_ARG(env, obj), fields[0].fid);
   178     val = env->GetIntField(obj, fields[0].fid);
   195 }
   179 }
   196 
   180 
   197 JNIEXPORT void JNICALL
   181 JNIEXPORT void JNICALL
   198 Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_check(JNIEnv *env,
   182 Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_check(JNIEnv *env,
   199         jclass cls, jint fld_ind, jboolean flag) {
   183         jclass cls, jint fld_ind, jboolean flag) {
   214 JNIEXPORT jint JNICALL
   198 JNIEXPORT jint JNICALL
   215 Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_getRes(JNIEnv *env, jclass cls) {
   199 Java_nsk_jvmti_ClearFieldAccessWatch_clrfldw001_getRes(JNIEnv *env, jclass cls) {
   216     return result;
   200     return result;
   217 }
   201 }
   218 
   202 
   219 #ifdef __cplusplus
   203 }
   220 }
       
   221 #endif