test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t007/cm01t007.cpp
changeset 52081 ca7ddf0a1d47
parent 51774 79dc492c00ab
equal deleted inserted replaced
52080:a2c72b476c9f 52081:ca7ddf0a1d47
    70     int i;
    70     int i;
    71 
    71 
    72     NSK_DISPLAY0("Prepare: find tested thread\n");
    72     NSK_DISPLAY0("Prepare: find tested thread\n");
    73 
    73 
    74     /* get all live threads */
    74     /* get all live threads */
    75     if (!NSK_JVMTI_VERIFY(
    75     if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))
    76            NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
       
    77         return NSK_FALSE;
    76         return NSK_FALSE;
    78 
    77 
    79     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
    78     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
    80         return NSK_FALSE;
    79         return NSK_FALSE;
    81 
    80 
    83     for (i = 0; i < threads_count; i++) {
    82     for (i = 0; i < threads_count; i++) {
    84         if (!NSK_VERIFY(threads[i] != NULL))
    83         if (!NSK_VERIFY(threads[i] != NULL))
    85             return NSK_FALSE;
    84             return NSK_FALSE;
    86 
    85 
    87         /* get thread information */
    86         /* get thread information */
    88         if (!NSK_JVMTI_VERIFY(
    87         if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))
    89                 NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
       
    90             return NSK_FALSE;
    88             return NSK_FALSE;
    91 
    89 
    92         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
    90         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
    93 
    91 
    94         /* find by name */
    92         /* find by name */
    96             thread = threads[i];
    94             thread = threads[i];
    97         }
    95         }
    98     }
    96     }
    99 
    97 
   100     /* deallocate threads list */
    98     /* deallocate threads list */
   101     if (!NSK_JVMTI_VERIFY(
    99     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))
   102             NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
       
   103         return NSK_FALSE;
   100         return NSK_FALSE;
   104 
   101 
   105     /* get tested thread class */
   102     /* get tested thread class */
   106     if (!NSK_JNI_VERIFY(jni, (klass =
   103     if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(thread)) != NULL))
   107             NSK_CPP_STUB2(GetObjectClass, jni, thread)) != NULL))
       
   108         return NSK_FALSE;
   104         return NSK_FALSE;
   109 
   105 
   110     /* get tested thread method 'run' */
   106     /* get tested thread method 'run' */
   111     if (!NSK_JNI_VERIFY(jni, (method =
   107     if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "run", "()V")) != NULL))
   112             NSK_CPP_STUB4(GetMethodID, jni, klass, "run", "()V")) != NULL))
       
   113         return NSK_FALSE;
   108         return NSK_FALSE;
   114 
   109 
   115     /* get tested thread field 'waitingFlag' */
   110     /* get tested thread field 'waitingFlag' */
   116     if (!NSK_JNI_VERIFY(jni, (field =
   111     if (!NSK_JNI_VERIFY(jni, (field = jni->GetFieldID(klass, "waitingFlag", "Z")) != NULL))
   117             NSK_CPP_STUB4(GetFieldID, jni, klass, "waitingFlag", "Z")) != NULL))
       
   118         return NSK_FALSE;
   112         return NSK_FALSE;
   119 
   113 
   120     return NSK_TRUE;
   114     return NSK_TRUE;
   121 }
   115 }
   122 
   116 
   126  */
   120  */
   127 static int checkSuspend() {
   121 static int checkSuspend() {
   128     jvmtiError err;
   122     jvmtiError err;
   129 
   123 
   130     NSK_DISPLAY0("Checking negative: SuspendThread\n");
   124     NSK_DISPLAY0("Checking negative: SuspendThread\n");
   131     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   125     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->SuspendThread(thread)))
   132             NSK_CPP_STUB2(SuspendThread, jvmti, thread)))
       
   133         return NSK_FALSE;
   126         return NSK_FALSE;
   134 
   127 
   135     NSK_DISPLAY0("Checking negative: ResumeThread\n");
   128     NSK_DISPLAY0("Checking negative: ResumeThread\n");
   136     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   129     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->ResumeThread(thread)))
   137             NSK_CPP_STUB2(ResumeThread, jvmti, thread)))
       
   138         return NSK_FALSE;
   130         return NSK_FALSE;
   139 
   131 
   140     NSK_DISPLAY0("Checking negative: SuspendThreadList\n");
   132     NSK_DISPLAY0("Checking negative: SuspendThreadList\n");
   141     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   133     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   142             NSK_CPP_STUB4(SuspendThreadList, jvmti, 1, &thread, &err)))
   134             jvmti->SuspendThreadList(1, &thread, &err)))
   143         return NSK_FALSE;
   135         return NSK_FALSE;
   144 
   136 
   145     NSK_DISPLAY0("Checking negative: ResumeThreadList\n");
   137     NSK_DISPLAY0("Checking negative: ResumeThreadList\n");
   146     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   138     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   147             NSK_CPP_STUB4(ResumeThreadList, jvmti, 1, &thread, &err)))
   139             jvmti->ResumeThreadList(1, &thread, &err)))
   148         return NSK_FALSE;
   140         return NSK_FALSE;
   149 
   141 
   150     return NSK_TRUE;
   142     return NSK_TRUE;
   151 }
   143 }
   152 
   144 
   158     const char* THREAD_DEATH_CTOR_SIGNATURE = "()V";
   150     const char* THREAD_DEATH_CTOR_SIGNATURE = "()V";
   159     jclass cls = NULL;
   151     jclass cls = NULL;
   160     jmethodID ctor = NULL;
   152     jmethodID ctor = NULL;
   161     jobject exception = NULL;
   153     jobject exception = NULL;
   162 
   154 
   163     if (!NSK_JNI_VERIFY(jni, (cls =
   155     if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL))
   164             NSK_CPP_STUB2(FindClass, jni, THREAD_DEATH_CLASS_NAME)) != NULL))
       
   165         return NSK_FALSE;
   156         return NSK_FALSE;
   166 
   157 
   167     if (!NSK_JNI_VERIFY(jni, (ctor =
   158     if (!NSK_JNI_VERIFY(jni, (ctor =
   168             NSK_CPP_STUB4(GetMethodID, jni, cls,
   159             jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
   169                 THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
   160         return NSK_FALSE;
   170         return NSK_FALSE;
   161 
   171 
   162     if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL))
   172     if (!NSK_JNI_VERIFY(jni, (exception =
       
   173             NSK_CPP_STUB3(NewObject, jni, cls, ctor)) != NULL))
       
   174         return NSK_FALSE;
   163         return NSK_FALSE;
   175 
   164 
   176     NSK_DISPLAY0("Checking negative: StopThread\n");
   165     NSK_DISPLAY0("Checking negative: StopThread\n");
   177     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   166     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   178             NSK_CPP_STUB3(StopThread, jvmti, thread, exception)))
   167             jvmti->StopThread(thread, exception)))
   179         return NSK_FALSE;
   168         return NSK_FALSE;
   180 
   169 
   181     NSK_DISPLAY0("Checking negative: InterruptThread\n");
   170     NSK_DISPLAY0("Checking negative: InterruptThread\n");
   182     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   171     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->InterruptThread(thread)))
   183             NSK_CPP_STUB2(InterruptThread, jvmti, thread)))
       
   184         return NSK_FALSE;
   172         return NSK_FALSE;
   185 
   173 
   186     return NSK_TRUE;
   174     return NSK_TRUE;
   187 }
   175 }
   188 
   176 
   192     jint count;
   180     jint count;
   193     jobject *monitors = NULL;
   181     jobject *monitors = NULL;
   194 
   182 
   195     NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n");
   183     NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n");
   196     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   184     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   197             NSK_CPP_STUB4(GetOwnedMonitorInfo, jvmti, thread, &count, &monitors)))
   185             jvmti->GetOwnedMonitorInfo(thread, &count, &monitors)))
   198         return NSK_FALSE;
   186         return NSK_FALSE;
   199 
   187 
   200     return NSK_TRUE;
   188     return NSK_TRUE;
   201 }
   189 }
   202 
   190 
   205 static int checkGetCurrentContendedMonitor() {
   193 static int checkGetCurrentContendedMonitor() {
   206     jobject monitor = NULL;
   194     jobject monitor = NULL;
   207 
   195 
   208     NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n");
   196     NSK_DISPLAY0("Checking negative: GetCurrentContendedMonitor\n");
   209     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   197     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   210             NSK_CPP_STUB3(GetCurrentContendedMonitor, jvmti, thread, &monitor)))
   198             jvmti->GetCurrentContendedMonitor(thread, &monitor)))
   211         return NSK_FALSE;
   199         return NSK_FALSE;
   212 
   200 
   213     return NSK_TRUE;
   201     return NSK_TRUE;
   214 }
   202 }
   215 
   203 
   221 
   209 
   222     NSK_DISPLAY0("Checking positive: PopFrame\n");
   210     NSK_DISPLAY0("Checking positive: PopFrame\n");
   223 
   211 
   224     memset(&caps, 0, sizeof(caps));
   212     memset(&caps, 0, sizeof(caps));
   225     caps.can_suspend = 1;
   213     caps.can_suspend = 1;
   226     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
   214     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
   227         return JNI_ERR;
   215         return JNI_ERR;
   228     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(SuspendThread, jvmti, thread)))
   216     if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(thread)))
   229         return NSK_FALSE;
   217         return NSK_FALSE;
   230 
   218 
   231     // PopFrame is allowed to fail with JVMTI_ERROR_OPAQUE_FRAME.
   219     // PopFrame is allowed to fail with JVMTI_ERROR_OPAQUE_FRAME.
   232     // That will happen if we are in a native function, for example while waiting for a Condition.
   220     // That will happen if we are in a native function, for example while waiting for a Condition.
   233     // See JCK-5020108.
   221     // See JCK-5020108.
   234     err = NSK_CPP_STUB2(PopFrame, jvmti, thread);
   222     err = jvmti->PopFrame(thread);
   235     if (err != JVMTI_ERROR_NONE && err != JVMTI_ERROR_OPAQUE_FRAME) {
   223     if (err != JVMTI_ERROR_NONE && err != JVMTI_ERROR_OPAQUE_FRAME) {
   236       NSK_DISPLAY1("jvmti error from PopFrame: %d\n", err);
   224       NSK_DISPLAY1("jvmti error from PopFrame: %d\n", err);
   237       return NSK_FALSE;
   225       return NSK_FALSE;
   238     }
   226     }
   239 
   227 
   240     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(ResumeThread, jvmti, thread)))
   228     if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(thread)))
   241         return NSK_FALSE;
   229         return NSK_FALSE;
   242     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RelinquishCapabilities, jvmti, &caps)))
   230     if (!NSK_JVMTI_VERIFY(jvmti->RelinquishCapabilities(&caps)))
   243         return JNI_ERR;
   231         return JNI_ERR;
   244 
   232 
   245     return NSK_TRUE;
   233     return NSK_TRUE;
   246 }
   234 }
   247 
   235 
   281     jlong *res_tags = NULL;
   269     jlong *res_tags = NULL;
   282     jint dummy_user_data = 0;
   270     jint dummy_user_data = 0;
   283 
   271 
   284     NSK_DISPLAY0("Checking negative: SetTag\n");
   272     NSK_DISPLAY0("Checking negative: SetTag\n");
   285     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   273     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   286             NSK_CPP_STUB3(SetTag, jvmti, thread, TAG_VALUE)))
   274             jvmti->SetTag(thread, TAG_VALUE)))
   287         return NSK_FALSE;
   275         return NSK_FALSE;
   288 
   276 
   289     NSK_DISPLAY0("Checking negative: GetTag\n");
   277     NSK_DISPLAY0("Checking negative: GetTag\n");
   290     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   278     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->GetTag(thread, &tag)))
   291             NSK_CPP_STUB3(GetTag, jvmti, thread, &tag)))
       
   292         return NSK_FALSE;
   279         return NSK_FALSE;
   293 
   280 
   294     NSK_DISPLAY0("Checking negative: GetObjectsWithTags\n");
   281     NSK_DISPLAY0("Checking negative: GetObjectsWithTags\n");
   295     tag = TAG_VALUE;
   282     tag = TAG_VALUE;
   296     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   283     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   297             NSK_CPP_STUB6(GetObjectsWithTags, jvmti, 1, &tag,
   284             jvmti->GetObjectsWithTags(1, &tag, &count, &res_objects, &res_tags)))
   298                 &count, &res_objects, &res_tags)))
       
   299         return NSK_FALSE;
   285         return NSK_FALSE;
   300 
   286 
   301     NSK_DISPLAY0("Checking negative: IterateOverHeap\n");
   287     NSK_DISPLAY0("Checking negative: IterateOverHeap\n");
   302     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   288     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   303             NSK_CPP_STUB4(IterateOverHeap, jvmti, JVMTI_HEAP_OBJECT_TAGGED,
   289             jvmti->IterateOverHeap(JVMTI_HEAP_OBJECT_TAGGED,
   304                 HeapObject, &dummy_user_data)))
   290                                    HeapObject,
       
   291                                    &dummy_user_data)))
   305         return NSK_FALSE;
   292         return NSK_FALSE;
   306 
   293 
   307     NSK_DISPLAY0("Checking negative: IterateOverInstancesOfClass\n");
   294     NSK_DISPLAY0("Checking negative: IterateOverInstancesOfClass\n");
   308     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   295     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   309             NSK_CPP_STUB5(IterateOverInstancesOfClass, jvmti, klass,
   296             jvmti->IterateOverInstancesOfClass(klass,
   310                 JVMTI_HEAP_OBJECT_UNTAGGED, HeapObject, &dummy_user_data)))
   297                                                JVMTI_HEAP_OBJECT_UNTAGGED,
       
   298                                                HeapObject,
       
   299                                                &dummy_user_data)))
   311         return NSK_FALSE;
   300         return NSK_FALSE;
   312 
   301 
   313     NSK_DISPLAY0("Checking negative: IterateOverObjectsReachableFromObject\n");
   302     NSK_DISPLAY0("Checking negative: IterateOverObjectsReachableFromObject\n");
   314     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   303     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   315             NSK_CPP_STUB4(IterateOverObjectsReachableFromObject, jvmti, thread,
   304             jvmti->IterateOverObjectsReachableFromObject(thread,
   316                 ObjectReference, &dummy_user_data)))
   305                                                          ObjectReference,
       
   306                                                          &dummy_user_data)))
   317         return NSK_FALSE;
   307         return NSK_FALSE;
   318 
   308 
   319     NSK_DISPLAY0("Checking negative: IterateOverReachableObjects\n");
   309     NSK_DISPLAY0("Checking negative: IterateOverReachableObjects\n");
   320     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   310     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   321             NSK_CPP_STUB5(IterateOverReachableObjects, jvmti,
   311             jvmti->IterateOverReachableObjects(HeapRoot,
   322                 HeapRoot, StackReference, ObjectReference, &dummy_user_data)))
   312                                                StackReference,
       
   313                                                ObjectReference,
       
   314                                                &dummy_user_data)))
   323         return NSK_FALSE;
   315         return NSK_FALSE;
   324 
   316 
   325     return NSK_TRUE;
   317     return NSK_TRUE;
   326 }
   318 }
   327 
   319 
   336     jfloat float_value;
   328     jfloat float_value;
   337     jdouble double_value;
   329     jdouble double_value;
   338 
   330 
   339     NSK_DISPLAY0("Checking negative: GetLocalVariableTable\n");
   331     NSK_DISPLAY0("Checking negative: GetLocalVariableTable\n");
   340     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   332     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   341             NSK_CPP_STUB4(GetLocalVariableTable, jvmti, method, &count,
   333             jvmti->GetLocalVariableTable(method, &count, &local_variable_table)))
   342                 &local_variable_table)))
       
   343         return NSK_FALSE;
   334         return NSK_FALSE;
   344 
   335 
   345     NSK_DISPLAY0("Checking negative: GetLocalObject\n");
   336     NSK_DISPLAY0("Checking negative: GetLocalObject\n");
   346     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   337     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   347             NSK_CPP_STUB5(GetLocalObject, jvmti, thread, 0, 0, &object_value)))
   338             jvmti->GetLocalObject(thread, 0, 0, &object_value)))
   348         return NSK_FALSE;
   339         return NSK_FALSE;
   349 
   340 
   350     NSK_DISPLAY0("Checking negative: GetLocalInt\n");
   341     NSK_DISPLAY0("Checking negative: GetLocalInt\n");
   351     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   342     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   352             NSK_CPP_STUB5(GetLocalInt, jvmti, thread, 0, 0, &int_value)))
   343             jvmti->GetLocalInt(thread, 0, 0, &int_value)))
   353         return NSK_FALSE;
   344         return NSK_FALSE;
   354 
   345 
   355     NSK_DISPLAY0("Checking negative: GetLocalLong\n");
   346     NSK_DISPLAY0("Checking negative: GetLocalLong\n");
   356     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   347     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   357             NSK_CPP_STUB5(GetLocalLong, jvmti, thread, 0, 0, &long_value)))
   348             jvmti->GetLocalLong(thread, 0, 0, &long_value)))
   358         return NSK_FALSE;
   349         return NSK_FALSE;
   359 
   350 
   360     NSK_DISPLAY0("Checking negative: GetLocalFloat\n");
   351     NSK_DISPLAY0("Checking negative: GetLocalFloat\n");
   361     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   352     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   362             NSK_CPP_STUB5(GetLocalFloat, jvmti, thread, 0, 0, &float_value)))
   353             jvmti->GetLocalFloat(thread, 0, 0, &float_value)))
   363         return NSK_FALSE;
   354         return NSK_FALSE;
   364 
   355 
   365     NSK_DISPLAY0("Checking negative: GetLocalDouble\n");
   356     NSK_DISPLAY0("Checking negative: GetLocalDouble\n");
   366     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   357     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   367             NSK_CPP_STUB5(GetLocalDouble, jvmti, thread, 0, 0, &double_value)))
   358             jvmti->GetLocalDouble(thread, 0, 0, &double_value)))
   368         return NSK_FALSE;
   359         return NSK_FALSE;
   369 
   360 
   370     NSK_DISPLAY0("Checking negative: SetLocalObject\n");
   361     NSK_DISPLAY0("Checking negative: SetLocalObject\n");
   371     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   362     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   372             NSK_CPP_STUB5(SetLocalObject, jvmti, thread, 0, 0, thread)))
   363             jvmti->SetLocalObject(thread, 0, 0, thread)))
   373         return NSK_FALSE;
   364         return NSK_FALSE;
   374 
   365 
   375     NSK_DISPLAY0("Checking negative: SetLocalInt\n");
   366     NSK_DISPLAY0("Checking negative: SetLocalInt\n");
   376     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   367     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   377             NSK_CPP_STUB5(SetLocalInt, jvmti, thread, 0, 0, (jint)0)))
   368             jvmti->SetLocalInt(thread, 0, 0, (jint)0)))
   378         return NSK_FALSE;
   369         return NSK_FALSE;
   379 
   370 
   380     NSK_DISPLAY0("Checking negative: SetLocalLong\n");
   371     NSK_DISPLAY0("Checking negative: SetLocalLong\n");
   381     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   372     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   382             NSK_CPP_STUB5(SetLocalLong, jvmti, thread, 0, 0, (jlong)0)))
   373             jvmti->SetLocalLong(thread, 0, 0, (jlong)0)))
   383         return NSK_FALSE;
   374         return NSK_FALSE;
   384 
   375 
   385     NSK_DISPLAY0("Checking negative: SetLocalFloat\n");
   376     NSK_DISPLAY0("Checking negative: SetLocalFloat\n");
   386     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   377     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   387             NSK_CPP_STUB5(SetLocalFloat, jvmti, thread, 0, 0, (jfloat)0.0)))
   378             jvmti->SetLocalFloat(thread, 0, 0, (jfloat)0.0)))
   388         return NSK_FALSE;
   379         return NSK_FALSE;
   389 
   380 
   390     NSK_DISPLAY0("Checking negative: SetLocalDouble\n");
   381     NSK_DISPLAY0("Checking negative: SetLocalDouble\n");
   391     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   382     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   392             NSK_CPP_STUB5(SetLocalDouble, jvmti, thread, 0, 0, (jdouble)0.0)))
   383             jvmti->SetLocalDouble(thread, 0, 0, (jdouble)0.0)))
   393         return NSK_FALSE;
   384         return NSK_FALSE;
   394 
   385 
   395     return NSK_TRUE;
   386     return NSK_TRUE;
   396 }
   387 }
   397 
   388 
   402     jint count;
   393     jint count;
   403     jvmtiLineNumberEntry *line_number_table = NULL;
   394     jvmtiLineNumberEntry *line_number_table = NULL;
   404 
   395 
   405     NSK_DISPLAY0("Checking negative: GetSourceFileName\n");
   396     NSK_DISPLAY0("Checking negative: GetSourceFileName\n");
   406     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   397     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   407             NSK_CPP_STUB3(GetSourceFileName, jvmti, klass, &name)))
   398             jvmti->GetSourceFileName(klass, &name)))
   408         return NSK_FALSE;
   399         return NSK_FALSE;
   409 
   400 
   410     NSK_DISPLAY0("Checking negative: GetSourceDebugExtension\n");
   401     NSK_DISPLAY0("Checking negative: GetSourceDebugExtension\n");
   411     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   402     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   412             NSK_CPP_STUB3(GetSourceDebugExtension, jvmti, klass, &name)))
   403             jvmti->GetSourceDebugExtension(klass, &name)))
   413         return NSK_FALSE;
   404         return NSK_FALSE;
   414 
   405 
   415     NSK_DISPLAY0("Checking negative: GetLineNumberTable\n");
   406     NSK_DISPLAY0("Checking negative: GetLineNumberTable\n");
   416     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   407     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   417             NSK_CPP_STUB4(GetLineNumberTable, jvmti, method, &count,
   408             jvmti->GetLineNumberTable(method, &count, &line_number_table)))
   418                 &line_number_table)))
       
   419         return NSK_FALSE;
   409         return NSK_FALSE;
   420 
   410 
   421     return NSK_TRUE;
   411     return NSK_TRUE;
   422 }
   412 }
   423 
   413 
   429     NSK_DISPLAY0("Checking negative: RedefineClasses\n");
   419     NSK_DISPLAY0("Checking negative: RedefineClasses\n");
   430     class_def.klass = klass;
   420     class_def.klass = klass;
   431     class_def.class_byte_count = 0;
   421     class_def.class_byte_count = 0;
   432     class_def.class_bytes = NULL;
   422     class_def.class_bytes = NULL;
   433     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   423     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   434             NSK_CPP_STUB3(RedefineClasses, jvmti, 1, &class_def)))
   424             jvmti->RedefineClasses(1, &class_def)))
   435         return NSK_FALSE;
   425         return NSK_FALSE;
   436 
   426 
   437     return NSK_TRUE;
   427     return NSK_TRUE;
   438 }
   428 }
   439 
   429 
   442 static int checkGetObjectMonitorUsage() {
   432 static int checkGetObjectMonitorUsage() {
   443     jvmtiMonitorUsage monitor_info;
   433     jvmtiMonitorUsage monitor_info;
   444 
   434 
   445     NSK_DISPLAY0("Checking negative: GetObjectMonitorUsage\n");
   435     NSK_DISPLAY0("Checking negative: GetObjectMonitorUsage\n");
   446     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   436     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   447             NSK_CPP_STUB3(GetObjectMonitorUsage, jvmti, thread, &monitor_info)))
   437             jvmti->GetObjectMonitorUsage(thread, &monitor_info)))
   448         return NSK_FALSE;
   438         return NSK_FALSE;
   449 
   439 
   450     return NSK_TRUE;
   440     return NSK_TRUE;
   451 }
   441 }
   452 
   442 
   455 static int checkIsSyntheticFunctions() {
   445 static int checkIsSyntheticFunctions() {
   456     jboolean is_synthetic;
   446     jboolean is_synthetic;
   457 
   447 
   458     NSK_DISPLAY0("Checking negative: IsFieldSynthetic\n");
   448     NSK_DISPLAY0("Checking negative: IsFieldSynthetic\n");
   459     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   449     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   460             NSK_CPP_STUB4(IsFieldSynthetic, jvmti, klass, field, &is_synthetic)))
   450             jvmti->IsFieldSynthetic(klass, field, &is_synthetic)))
   461         return NSK_FALSE;
   451         return NSK_FALSE;
   462 
   452 
   463     NSK_DISPLAY0("Checking negative: IsMethodSynthetic\n");
   453     NSK_DISPLAY0("Checking negative: IsMethodSynthetic\n");
   464     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   454     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   465             NSK_CPP_STUB3(IsMethodSynthetic, jvmti, method, &is_synthetic)))
   455             jvmti->IsMethodSynthetic(method, &is_synthetic)))
   466         return NSK_FALSE;
   456         return NSK_FALSE;
   467 
   457 
   468     return NSK_TRUE;
   458     return NSK_TRUE;
   469 }
   459 }
   470 
   460 
   474     jint count;
   464     jint count;
   475     unsigned char *bytecodes;
   465     unsigned char *bytecodes;
   476 
   466 
   477     NSK_DISPLAY0("Checking negative: GetBytecodes\n");
   467     NSK_DISPLAY0("Checking negative: GetBytecodes\n");
   478     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   468     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   479             NSK_CPP_STUB4(GetBytecodes, jvmti, method, &count, &bytecodes)))
   469             jvmti->GetBytecodes(method, &count, &bytecodes)))
   480         return NSK_FALSE;
   470         return NSK_FALSE;
   481 
   471 
   482     return NSK_TRUE;
   472     return NSK_TRUE;
   483 }
   473 }
   484 
   474 
   488     jvmtiTimerInfo info;
   478     jvmtiTimerInfo info;
   489     jlong nanos;
   479     jlong nanos;
   490 
   480 
   491     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTimerInfo\n");
   481     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTimerInfo\n");
   492     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   482     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   493             NSK_CPP_STUB2(GetCurrentThreadCpuTimerInfo, jvmti, &info)))
   483             jvmti->GetCurrentThreadCpuTimerInfo(&info)))
   494         return NSK_FALSE;
   484         return NSK_FALSE;
   495 
   485 
   496     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTime\n");
   486     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTime\n");
   497     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   487     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   498             NSK_CPP_STUB2(GetCurrentThreadCpuTime, jvmti, &nanos)))
   488             jvmti->GetCurrentThreadCpuTime(&nanos)))
   499         return NSK_FALSE;
   489         return NSK_FALSE;
   500 
   490 
   501     return NSK_TRUE;
   491     return NSK_TRUE;
   502 }
   492 }
   503 
   493 
   507     jvmtiTimerInfo info;
   497     jvmtiTimerInfo info;
   508     jlong nanos;
   498     jlong nanos;
   509 
   499 
   510     NSK_DISPLAY0("Checking negative: GetThreadCpuTimerInfo\n");
   500     NSK_DISPLAY0("Checking negative: GetThreadCpuTimerInfo\n");
   511     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   501     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   512             NSK_CPP_STUB2(GetThreadCpuTimerInfo, jvmti, &info)))
   502             jvmti->GetThreadCpuTimerInfo(&info)))
   513         return NSK_FALSE;
   503         return NSK_FALSE;
   514 
   504 
   515     NSK_DISPLAY0("Checking negative: GetThreadCpuTime\n");
   505     NSK_DISPLAY0("Checking negative: GetThreadCpuTime\n");
   516     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   506     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   517             NSK_CPP_STUB3(GetThreadCpuTime, jvmti, thread, &nanos)))
   507             jvmti->GetThreadCpuTime(thread, &nanos)))
   518         return NSK_FALSE;
   508         return NSK_FALSE;
   519 
   509 
   520     return NSK_TRUE;
   510     return NSK_TRUE;
   521 }
   511 }
   522 
   512 
   608     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
   598     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
   609         return JNI_ERR;
   599         return JNI_ERR;
   610 
   600 
   611     /* testcase #1: check GetPotentialCapabilities */
   601     /* testcase #1: check GetPotentialCapabilities */
   612     NSK_DISPLAY0("Testcase #1: check if GetPotentialCapabilities returns the capability\n");
   602     NSK_DISPLAY0("Testcase #1: check if GetPotentialCapabilities returns the capability\n");
   613     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPotentialCapabilities, jvmti, &caps)))
   603     if (!NSK_JVMTI_VERIFY(jvmti->GetPotentialCapabilities(&caps)))
   614         return JNI_ERR;
   604         return JNI_ERR;
   615     if (!caps.CAPABILITY) {
   605     if (!caps.CAPABILITY) {
   616         NSK_COMPLAIN1("GetPotentialCapabilities does not return \"%s\" capability\n",
   606         NSK_COMPLAIN1("GetPotentialCapabilities does not return \"%s\" capability\n",
   617             CAPABILITY_STR);
   607             CAPABILITY_STR);
   618         return JNI_ERR;
   608         return JNI_ERR;
   620 
   610 
   621     /* testcase #2: add the capability during Onload phase */
   611     /* testcase #2: add the capability during Onload phase */
   622     NSK_DISPLAY0("Testcase #2: add the capability during Onload phase\n");
   612     NSK_DISPLAY0("Testcase #2: add the capability during Onload phase\n");
   623     memset(&caps, 0, sizeof(caps));
   613     memset(&caps, 0, sizeof(caps));
   624     caps.CAPABILITY = 1;
   614     caps.CAPABILITY = 1;
   625     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
   615     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
   626         return JNI_ERR;
   616         return JNI_ERR;
   627 
   617 
   628     /* testcase #3: check if GetCapabilities returns the capability */
   618     /* testcase #3: check if GetCapabilities returns the capability */
   629     NSK_DISPLAY0("Testcase #3: check if GetCapabilities returns the capability\n");
   619     NSK_DISPLAY0("Testcase #3: check if GetCapabilities returns the capability\n");
   630     memset(&caps, 0, sizeof(caps));
   620     memset(&caps, 0, sizeof(caps));
   631     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti, &caps)))
   621     if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
   632         return JNI_ERR;
   622         return JNI_ERR;
   633     if (!caps.CAPABILITY) {
   623     if (!caps.CAPABILITY) {
   634         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   624         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   635             CAPABILITY_STR);
   625             CAPABILITY_STR);
   636         return JNI_ERR;
   626         return JNI_ERR;
   638 
   628 
   639     /* testcase #4: relinquish the capability during Onload phase */
   629     /* testcase #4: relinquish the capability during Onload phase */
   640     NSK_DISPLAY0("Testcase #4: relinquish the capability during Onload phase\n");
   630     NSK_DISPLAY0("Testcase #4: relinquish the capability during Onload phase\n");
   641     memset(&caps, 0, sizeof(caps));
   631     memset(&caps, 0, sizeof(caps));
   642     caps.CAPABILITY = 1;
   632     caps.CAPABILITY = 1;
   643     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RelinquishCapabilities, jvmti, &caps)))
   633     if (!NSK_JVMTI_VERIFY(jvmti->RelinquishCapabilities(&caps)))
   644         return JNI_ERR;
   634         return JNI_ERR;
   645 
   635 
   646     /* testcase #5: check if GetCapabilities does not return the capability */
   636     /* testcase #5: check if GetCapabilities does not return the capability */
   647     NSK_DISPLAY0("Testcase #5: check if GetCapabilities does not return the capability\n");
   637     NSK_DISPLAY0("Testcase #5: check if GetCapabilities does not return the capability\n");
   648     memset(&caps, 0, sizeof(caps));
   638     memset(&caps, 0, sizeof(caps));
   649     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti, &caps)))
   639     if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
   650         return JNI_ERR;
   640         return JNI_ERR;
   651     if (caps.CAPABILITY) {
   641     if (caps.CAPABILITY) {
   652         NSK_COMPLAIN1("GetCapabilities returns relinquished \"%s\" capability\n",
   642         NSK_COMPLAIN1("GetCapabilities returns relinquished \"%s\" capability\n",
   653             CAPABILITY_STR);
   643             CAPABILITY_STR);
   654         return JNI_ERR;
   644         return JNI_ERR;
   656 
   646 
   657     /* testcase #6: add back the capability and check with GetCapabilities */
   647     /* testcase #6: add back the capability and check with GetCapabilities */
   658     NSK_DISPLAY0("Testcase #6: add back the capability and check with GetCapabilities\n");
   648     NSK_DISPLAY0("Testcase #6: add back the capability and check with GetCapabilities\n");
   659     memset(&caps, 0, sizeof(caps));
   649     memset(&caps, 0, sizeof(caps));
   660     caps.CAPABILITY = 1;
   650     caps.CAPABILITY = 1;
   661     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
   651     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
   662         return JNI_ERR;
   652         return JNI_ERR;
   663     memset(&caps, 0, sizeof(caps));
   653     memset(&caps, 0, sizeof(caps));
   664     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti, &caps)))
   654     if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
   665         return JNI_ERR;
   655         return JNI_ERR;
   666     if (!caps.CAPABILITY) {
   656     if (!caps.CAPABILITY) {
   667         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   657         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   668             CAPABILITY_STR);
   658             CAPABILITY_STR);
   669         return JNI_ERR;
   659         return JNI_ERR;