< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/FollowReferences/followref005/followref005.cpp

Print this page
rev 52185 : [mq]: refactor


  28 #include "jvmti_FollowRefObjects.h"
  29 
  30 extern "C" {
  31 
  32 static jlong g_timeout = 0;
  33 
  34 /* ============================================================================= */
  35 
  36 /** Agent algorithm. */
  37 static void JNICALL
  38 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  39     jvmtiError retCode;
  40     jlong tag;
  41     jint cnt;
  42     jobject * pObjs;
  43     jlong * pObjTags;
  44 
  45     printf(">>> Check that FollowReferences(), IterateThroughHeap(), GetTag(), SetTag() and GetObjectsWithTags() \n"
  46            "    return an error if env. doesn't possess can_tag_objects capability\n");
  47 
  48     retCode = NSK_CPP_STUB6(FollowReferences,
  49                               jvmti,
  50                               (jint) 0,                 /* heap filter */
  51                               NULL,                     /* class */
  52                               NULL,                     /* inital object */
  53                               &g_wrongHeapCallbacks,
  54                               (const void *) &g_fakeUserData);
  55 
  56     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  57         NSK_COMPLAIN1("FollowReferences() returned %i", retCode);
  58         nsk_jvmti_setFailStatus();
  59     }
  60 
  61     retCode = NSK_CPP_STUB5(IterateThroughHeap,
  62                               jvmti,
  63                               (jint) 0,                 /* heap filter */
  64                               NULL,                     /* class */
  65                               &g_wrongHeapCallbacks,
  66                               (const void *) &g_fakeUserData);
  67 
  68     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  69         NSK_COMPLAIN1("IterateThroughHeap() returned %i", retCode);
  70         nsk_jvmti_setFailStatus();
  71     }
  72 
  73     retCode = NSK_CPP_STUB3(GetTag,
  74                               jvmti,
  75                               (jobject) &g_wrongHeapCallbacks,
  76                               &tag);
  77 
  78     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  79         NSK_COMPLAIN1("GetTag() returned %i", retCode);
  80         nsk_jvmti_setFailStatus();
  81     }
  82 
  83     retCode = NSK_CPP_STUB3(SetTag,
  84                               jvmti,
  85                               (jobject) &g_wrongHeapCallbacks,
  86                               tag);
  87 
  88     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  89         NSK_COMPLAIN1("SetTag() returned %i", retCode);
  90         nsk_jvmti_setFailStatus();
  91     }
  92 
  93     retCode = NSK_CPP_STUB6(GetObjectsWithTags,
  94                               jvmti,
  95                               1,
  96                               &tag,
  97                               &cnt,
  98                               &pObjs,
  99                               &pObjTags);
 100 
 101     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
 102         NSK_COMPLAIN1("GetObjectsWithTags() returned %i", retCode);
 103         nsk_jvmti_setFailStatus();
 104     }
 105 
 106     printf(">>> Let debugee to finish\n");
 107     fflush(0);
 108 
 109     if (!NSK_VERIFY(nsk_jvmti_waitForSync(g_timeout))) {
 110         return;
 111     }
 112 
 113     if (!NSK_VERIFY(nsk_jvmti_resumeSync())) {
 114         return;
 115     }
 116 } /* agentProc */
 117 
 118 
 119 /* ============================================================================= */


 131 }
 132 #endif
 133 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 134     jvmtiEnv* jvmti = NULL;
 135 
 136     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) {
 137         return JNI_ERR;
 138     }
 139 
 140     g_timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 141 
 142     if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) {
 143         return JNI_ERR;
 144     }
 145 
 146     {
 147         jvmtiCapabilities caps;
 148 
 149         memset(&caps, 0, sizeof(caps));
 150         /* Don't add can_tag_objects capability */
 151         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
 152             return JNI_ERR;
 153         }
 154     }
 155 
 156     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) {
 157         return JNI_ERR;
 158     }
 159 
 160     return JNI_OK;
 161 } /* Agent_OnLoad */
 162 
 163 
 164 /* ============================================================================= */
 165 
 166 }


  28 #include "jvmti_FollowRefObjects.h"
  29 
  30 extern "C" {
  31 
  32 static jlong g_timeout = 0;
  33 
  34 /* ============================================================================= */
  35 
  36 /** Agent algorithm. */
  37 static void JNICALL
  38 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  39     jvmtiError retCode;
  40     jlong tag;
  41     jint cnt;
  42     jobject * pObjs;
  43     jlong * pObjTags;
  44 
  45     printf(">>> Check that FollowReferences(), IterateThroughHeap(), GetTag(), SetTag() and GetObjectsWithTags() \n"
  46            "    return an error if env. doesn't possess can_tag_objects capability\n");
  47 
  48     retCode = jvmti->FollowReferences((jint) 0,                 /* heap filter */


  49                                       NULL,                     /* class */
  50                                       NULL,                     /* inital object */
  51                                       &g_wrongHeapCallbacks,
  52                                       (const void *) &g_fakeUserData);
  53 
  54     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  55         NSK_COMPLAIN1("FollowReferences() returned %i", retCode);
  56         nsk_jvmti_setFailStatus();
  57     }
  58 
  59     retCode = jvmti->IterateThroughHeap((jint) 0,                 /* heap filter */


  60                                         NULL,                     /* class */
  61                                         &g_wrongHeapCallbacks,
  62                                         (const void *) &g_fakeUserData);
  63 
  64     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  65         NSK_COMPLAIN1("IterateThroughHeap() returned %i", retCode);
  66         nsk_jvmti_setFailStatus();
  67     }
  68 
  69     retCode = jvmti->GetTag((jobject) &g_wrongHeapCallbacks, &tag);



  70 
  71     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  72         NSK_COMPLAIN1("GetTag() returned %i", retCode);
  73         nsk_jvmti_setFailStatus();
  74     }
  75 
  76     retCode = jvmti->SetTag((jobject) &g_wrongHeapCallbacks, tag);



  77 
  78     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  79         NSK_COMPLAIN1("SetTag() returned %i", retCode);
  80         nsk_jvmti_setFailStatus();
  81     }
  82 
  83     retCode = jvmti->GetObjectsWithTags(1, &tag, &cnt, &pObjs, &pObjTags);






  84 
  85     if ( ! NSK_VERIFY(retCode == JVMTI_ERROR_MUST_POSSESS_CAPABILITY ) ) {
  86         NSK_COMPLAIN1("GetObjectsWithTags() returned %i", retCode);
  87         nsk_jvmti_setFailStatus();
  88     }
  89 
  90     printf(">>> Let debugee to finish\n");
  91     fflush(0);
  92 
  93     if (!NSK_VERIFY(nsk_jvmti_waitForSync(g_timeout))) {
  94         return;
  95     }
  96 
  97     if (!NSK_VERIFY(nsk_jvmti_resumeSync())) {
  98         return;
  99     }
 100 } /* agentProc */
 101 
 102 
 103 /* ============================================================================= */


 115 }
 116 #endif
 117 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 118     jvmtiEnv* jvmti = NULL;
 119 
 120     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options))) {
 121         return JNI_ERR;
 122     }
 123 
 124     g_timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 125 
 126     if (!NSK_VERIFY((jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) {
 127         return JNI_ERR;
 128     }
 129 
 130     {
 131         jvmtiCapabilities caps;
 132 
 133         memset(&caps, 0, sizeof(caps));
 134         /* Don't add can_tag_objects capability */
 135         if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
 136             return JNI_ERR;
 137         }
 138     }
 139 
 140     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) {
 141         return JNI_ERR;
 142     }
 143 
 144     return JNI_OK;
 145 } /* Agent_OnLoad */
 146 
 147 
 148 /* ============================================================================= */
 149 
 150 }
< prev index next >