test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/capability/CM01/cm01t005/cm01t005.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 'waitingMonitor' */
   110     /* get tested thread field 'waitingMonitor' */
   116     if (!NSK_JNI_VERIFY(jni, (field =
   111     if (!NSK_JNI_VERIFY(jni, (field =
   117             NSK_CPP_STUB4(GetFieldID, jni, klass,
   112             jni->GetFieldID(klass, "waitingMonitor", "Ljava/lang/Object;")) != NULL))
   118                 "waitingMonitor", "Ljava/lang/Object;")) != NULL))
       
   119         return NSK_FALSE;
   113         return NSK_FALSE;
   120 
   114 
   121     return NSK_TRUE;
   115     return NSK_TRUE;
   122 }
   116 }
   123 
   117 
   127  */
   121  */
   128 static int checkSuspend() {
   122 static int checkSuspend() {
   129     jvmtiError err;
   123     jvmtiError err;
   130 
   124 
   131     NSK_DISPLAY0("Checking negative: SuspendThread\n");
   125     NSK_DISPLAY0("Checking negative: SuspendThread\n");
   132     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   126     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->SuspendThread(thread)))
   133             NSK_CPP_STUB2(SuspendThread, jvmti, thread)))
       
   134         return NSK_FALSE;
   127         return NSK_FALSE;
   135 
   128 
   136     NSK_DISPLAY0("Checking negative: ResumeThread\n");
   129     NSK_DISPLAY0("Checking negative: ResumeThread\n");
   137     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   130     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->ResumeThread(thread)))
   138             NSK_CPP_STUB2(ResumeThread, jvmti, thread)))
       
   139         return NSK_FALSE;
   131         return NSK_FALSE;
   140 
   132 
   141     NSK_DISPLAY0("Checking negative: SuspendThreadList\n");
   133     NSK_DISPLAY0("Checking negative: SuspendThreadList\n");
   142     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   134     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   143             NSK_CPP_STUB4(SuspendThreadList, jvmti, 1, &thread, &err)))
   135             jvmti->SuspendThreadList(1, &thread, &err)))
   144         return NSK_FALSE;
   136         return NSK_FALSE;
   145 
   137 
   146     NSK_DISPLAY0("Checking negative: ResumeThreadList\n");
   138     NSK_DISPLAY0("Checking negative: ResumeThreadList\n");
   147     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   139     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   148             NSK_CPP_STUB4(ResumeThreadList, jvmti, 1, &thread, &err)))
   140             jvmti->ResumeThreadList(1, &thread, &err)))
   149         return NSK_FALSE;
   141         return NSK_FALSE;
   150 
   142 
   151     return NSK_TRUE;
   143     return NSK_TRUE;
   152 }
   144 }
   153 
   145 
   159     const char* THREAD_DEATH_CTOR_SIGNATURE = "()V";
   151     const char* THREAD_DEATH_CTOR_SIGNATURE = "()V";
   160     jclass cls = NULL;
   152     jclass cls = NULL;
   161     jmethodID ctor = NULL;
   153     jmethodID ctor = NULL;
   162     jobject exception = NULL;
   154     jobject exception = NULL;
   163 
   155 
   164     if (!NSK_JNI_VERIFY(jni, (cls =
   156     if (!NSK_JNI_VERIFY(jni, (cls = jni->FindClass(THREAD_DEATH_CLASS_NAME)) != NULL))
   165             NSK_CPP_STUB2(FindClass, jni, THREAD_DEATH_CLASS_NAME)) != NULL))
       
   166         return NSK_FALSE;
   157         return NSK_FALSE;
   167 
   158 
   168     if (!NSK_JNI_VERIFY(jni, (ctor =
   159     if (!NSK_JNI_VERIFY(jni, (ctor =
   169             NSK_CPP_STUB4(GetMethodID, jni, cls,
   160             jni->GetMethodID(cls, THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
   170                 THREAD_DEATH_CTOR_NAME, THREAD_DEATH_CTOR_SIGNATURE)) != NULL))
   161         return NSK_FALSE;
   171         return NSK_FALSE;
   162 
   172 
   163     if (!NSK_JNI_VERIFY(jni, (exception = jni->NewObject(cls, ctor)) != NULL))
   173     if (!NSK_JNI_VERIFY(jni, (exception =
       
   174             NSK_CPP_STUB3(NewObject, jni, cls, ctor)) != NULL))
       
   175         return NSK_FALSE;
   164         return NSK_FALSE;
   176 
   165 
   177     NSK_DISPLAY0("Checking negative: StopThread\n");
   166     NSK_DISPLAY0("Checking negative: StopThread\n");
   178     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   167     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   179             NSK_CPP_STUB3(StopThread, jvmti, thread, exception)))
   168             jvmti->StopThread(thread, exception)))
   180         return NSK_FALSE;
   169         return NSK_FALSE;
   181 
   170 
   182     NSK_DISPLAY0("Checking negative: InterruptThread\n");
   171     NSK_DISPLAY0("Checking negative: InterruptThread\n");
   183     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   172     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->InterruptThread(thread)))
   184             NSK_CPP_STUB2(InterruptThread, jvmti, thread)))
       
   185         return NSK_FALSE;
   173         return NSK_FALSE;
   186 
   174 
   187     return NSK_TRUE;
   175     return NSK_TRUE;
   188 }
   176 }
   189 
   177 
   193     jint count;
   181     jint count;
   194     jobject *monitors = NULL;
   182     jobject *monitors = NULL;
   195 
   183 
   196     NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n");
   184     NSK_DISPLAY0("Checking negative: GetOwnedMonitorInfo\n");
   197     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   185     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   198             NSK_CPP_STUB4(GetOwnedMonitorInfo, jvmti, thread, &count, &monitors)))
   186             jvmti->GetOwnedMonitorInfo(thread, &count, &monitors)))
   199         return NSK_FALSE;
   187         return NSK_FALSE;
   200 
   188 
   201     return NSK_TRUE;
   189     return NSK_TRUE;
   202 }
   190 }
   203 
   191 
   205  */
   193  */
   206 static int checkGetCurrentContendedMonitor() {
   194 static int checkGetCurrentContendedMonitor() {
   207     jobject monitor = NULL;
   195     jobject monitor = NULL;
   208 
   196 
   209     NSK_DISPLAY0("Checking positive: GetCurrentContendedMonitor\n");
   197     NSK_DISPLAY0("Checking positive: GetCurrentContendedMonitor\n");
   210     if (!NSK_JVMTI_VERIFY(
   198     if (!NSK_JVMTI_VERIFY(jvmti->GetCurrentContendedMonitor(thread, &monitor)))
   211             NSK_CPP_STUB3(GetCurrentContendedMonitor, jvmti, thread, &monitor)))
       
   212         return NSK_FALSE;
   199         return NSK_FALSE;
   213 
   200 
   214     return NSK_TRUE;
   201     return NSK_TRUE;
   215 }
   202 }
   216 
   203 
   217 /* Check "can_pop_frame" function
   204 /* Check "can_pop_frame" function
   218  */
   205  */
   219 static int checkPopFrame() {
   206 static int checkPopFrame() {
   220     NSK_DISPLAY0("Checking negative: PopFrame\n");
   207     NSK_DISPLAY0("Checking negative: PopFrame\n");
   221     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   208     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->PopFrame(thread)))
   222             NSK_CPP_STUB2(PopFrame, jvmti, thread)))
       
   223         return NSK_FALSE;
   209         return NSK_FALSE;
   224 
   210 
   225     return NSK_TRUE;
   211     return NSK_TRUE;
   226 }
   212 }
   227 
   213 
   261     jlong *res_tags = NULL;
   247     jlong *res_tags = NULL;
   262     jint dummy_user_data = 0;
   248     jint dummy_user_data = 0;
   263 
   249 
   264     NSK_DISPLAY0("Checking negative: SetTag\n");
   250     NSK_DISPLAY0("Checking negative: SetTag\n");
   265     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   251     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   266             NSK_CPP_STUB3(SetTag, jvmti, thread, TAG_VALUE)))
   252             jvmti->SetTag(thread, TAG_VALUE)))
   267         return NSK_FALSE;
   253         return NSK_FALSE;
   268 
   254 
   269     NSK_DISPLAY0("Checking negative: GetTag\n");
   255     NSK_DISPLAY0("Checking negative: GetTag\n");
   270     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   256     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY, jvmti->GetTag(thread, &tag)))
   271             NSK_CPP_STUB3(GetTag, jvmti, thread, &tag)))
       
   272         return NSK_FALSE;
   257         return NSK_FALSE;
   273 
   258 
   274     NSK_DISPLAY0("Checking negative: GetObjectsWithTags\n");
   259     NSK_DISPLAY0("Checking negative: GetObjectsWithTags\n");
   275     tag = TAG_VALUE;
   260     tag = TAG_VALUE;
   276     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   261     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   277             NSK_CPP_STUB6(GetObjectsWithTags, jvmti, 1, &tag,
   262             jvmti->GetObjectsWithTags(1, &tag, &count, &res_objects, &res_tags)))
   278                 &count, &res_objects, &res_tags)))
       
   279         return NSK_FALSE;
   263         return NSK_FALSE;
   280 
   264 
   281     NSK_DISPLAY0("Checking negative: IterateOverHeap\n");
   265     NSK_DISPLAY0("Checking negative: IterateOverHeap\n");
   282     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   266     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   283             NSK_CPP_STUB4(IterateOverHeap, jvmti, JVMTI_HEAP_OBJECT_TAGGED,
   267             jvmti->IterateOverHeap(JVMTI_HEAP_OBJECT_TAGGED, HeapObject, &dummy_user_data)))
   284                 HeapObject, &dummy_user_data)))
       
   285         return NSK_FALSE;
   268         return NSK_FALSE;
   286 
   269 
   287     NSK_DISPLAY0("Checking negative: IterateOverInstancesOfClass\n");
   270     NSK_DISPLAY0("Checking negative: IterateOverInstancesOfClass\n");
   288     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   271     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   289             NSK_CPP_STUB5(IterateOverInstancesOfClass, jvmti, klass,
   272             jvmti->IterateOverInstancesOfClass(klass,
   290                 JVMTI_HEAP_OBJECT_UNTAGGED, HeapObject, &dummy_user_data)))
   273                                                JVMTI_HEAP_OBJECT_UNTAGGED,
       
   274                                                HeapObject,
       
   275                                                &dummy_user_data)))
   291         return NSK_FALSE;
   276         return NSK_FALSE;
   292 
   277 
   293     NSK_DISPLAY0("Checking negative: IterateOverObjectsReachableFromObject\n");
   278     NSK_DISPLAY0("Checking negative: IterateOverObjectsReachableFromObject\n");
   294     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   279     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   295             NSK_CPP_STUB4(IterateOverObjectsReachableFromObject, jvmti, thread,
   280             jvmti->IterateOverObjectsReachableFromObject(thread,
   296                 ObjectReference, &dummy_user_data)))
   281                                                          ObjectReference,
       
   282                                                          &dummy_user_data)))
   297         return NSK_FALSE;
   283         return NSK_FALSE;
   298 
   284 
   299     NSK_DISPLAY0("Checking negative: IterateOverReachableObjects\n");
   285     NSK_DISPLAY0("Checking negative: IterateOverReachableObjects\n");
   300     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   286     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   301             NSK_CPP_STUB5(IterateOverReachableObjects, jvmti,
   287             jvmti->IterateOverReachableObjects(HeapRoot,
   302                 HeapRoot, StackReference, ObjectReference, &dummy_user_data)))
   288                                                StackReference,
       
   289                                                ObjectReference,
       
   290                                                &dummy_user_data)))
   303         return NSK_FALSE;
   291         return NSK_FALSE;
   304 
   292 
   305     return NSK_TRUE;
   293     return NSK_TRUE;
   306 }
   294 }
   307 
   295 
   316     jfloat float_value;
   304     jfloat float_value;
   317     jdouble double_value;
   305     jdouble double_value;
   318 
   306 
   319     NSK_DISPLAY0("Checking negative: GetLocalVariableTable\n");
   307     NSK_DISPLAY0("Checking negative: GetLocalVariableTable\n");
   320     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   308     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   321             NSK_CPP_STUB4(GetLocalVariableTable, jvmti, method, &count,
   309             jvmti->GetLocalVariableTable(method, &count, &local_variable_table)))
   322                 &local_variable_table)))
       
   323         return NSK_FALSE;
   310         return NSK_FALSE;
   324 
   311 
   325     NSK_DISPLAY0("Checking negative: GetLocalObject\n");
   312     NSK_DISPLAY0("Checking negative: GetLocalObject\n");
   326     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   313     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   327             NSK_CPP_STUB5(GetLocalObject, jvmti, thread, 0, 0, &object_value)))
   314             jvmti->GetLocalObject(thread, 0, 0, &object_value)))
   328         return NSK_FALSE;
   315         return NSK_FALSE;
   329 
   316 
   330     NSK_DISPLAY0("Checking negative: GetLocalInt\n");
   317     NSK_DISPLAY0("Checking negative: GetLocalInt\n");
   331     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   318     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   332             NSK_CPP_STUB5(GetLocalInt, jvmti, thread, 0, 0, &int_value)))
   319             jvmti->GetLocalInt(thread, 0, 0, &int_value)))
   333         return NSK_FALSE;
   320         return NSK_FALSE;
   334 
   321 
   335     NSK_DISPLAY0("Checking negative: GetLocalLong\n");
   322     NSK_DISPLAY0("Checking negative: GetLocalLong\n");
   336     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   323     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   337             NSK_CPP_STUB5(GetLocalLong, jvmti, thread, 0, 0, &long_value)))
   324             jvmti->GetLocalLong(thread, 0, 0, &long_value)))
   338         return NSK_FALSE;
   325         return NSK_FALSE;
   339 
   326 
   340     NSK_DISPLAY0("Checking negative: GetLocalFloat\n");
   327     NSK_DISPLAY0("Checking negative: GetLocalFloat\n");
   341     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   328     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   342             NSK_CPP_STUB5(GetLocalFloat, jvmti, thread, 0, 0, &float_value)))
   329             jvmti->GetLocalFloat(thread, 0, 0, &float_value)))
   343         return NSK_FALSE;
   330         return NSK_FALSE;
   344 
   331 
   345     NSK_DISPLAY0("Checking negative: GetLocalDouble\n");
   332     NSK_DISPLAY0("Checking negative: GetLocalDouble\n");
   346     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   333     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   347             NSK_CPP_STUB5(GetLocalDouble, jvmti, thread, 0, 0, &double_value)))
   334             jvmti->GetLocalDouble(thread, 0, 0, &double_value)))
   348         return NSK_FALSE;
   335         return NSK_FALSE;
   349 
   336 
   350     NSK_DISPLAY0("Checking negative: SetLocalObject\n");
   337     NSK_DISPLAY0("Checking negative: SetLocalObject\n");
   351     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   338     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   352             NSK_CPP_STUB5(SetLocalObject, jvmti, thread, 0, 0, thread)))
   339             jvmti->SetLocalObject(thread, 0, 0, thread)))
   353         return NSK_FALSE;
   340         return NSK_FALSE;
   354 
   341 
   355     NSK_DISPLAY0("Checking negative: SetLocalInt\n");
   342     NSK_DISPLAY0("Checking negative: SetLocalInt\n");
   356     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   343     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   357             NSK_CPP_STUB5(SetLocalInt, jvmti, thread, 0, 0, (jint)0)))
   344             jvmti->SetLocalInt(thread, 0, 0, (jint)0)))
   358         return NSK_FALSE;
   345         return NSK_FALSE;
   359 
   346 
   360     NSK_DISPLAY0("Checking negative: SetLocalLong\n");
   347     NSK_DISPLAY0("Checking negative: SetLocalLong\n");
   361     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   348     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   362             NSK_CPP_STUB5(SetLocalLong, jvmti, thread, 0, 0, (jlong)0)))
   349             jvmti->SetLocalLong(thread, 0, 0, (jlong)0)))
   363         return NSK_FALSE;
   350         return NSK_FALSE;
   364 
   351 
   365     NSK_DISPLAY0("Checking negative: SetLocalFloat\n");
   352     NSK_DISPLAY0("Checking negative: SetLocalFloat\n");
   366     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   353     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   367             NSK_CPP_STUB5(SetLocalFloat, jvmti, thread, 0, 0, (jfloat)0.0)))
   354             jvmti->SetLocalFloat(thread, 0, 0, (jfloat)0.0)))
   368         return NSK_FALSE;
   355         return NSK_FALSE;
   369 
   356 
   370     NSK_DISPLAY0("Checking negative: SetLocalDouble\n");
   357     NSK_DISPLAY0("Checking negative: SetLocalDouble\n");
   371     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   358     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   372             NSK_CPP_STUB5(SetLocalDouble, jvmti, thread, 0, 0, (jdouble)0.0)))
   359             jvmti->SetLocalDouble(thread, 0, 0, (jdouble)0.0)))
   373         return NSK_FALSE;
   360         return NSK_FALSE;
   374 
   361 
   375     return NSK_TRUE;
   362     return NSK_TRUE;
   376 }
   363 }
   377 
   364 
   382     jint count;
   369     jint count;
   383     jvmtiLineNumberEntry *line_number_table = NULL;
   370     jvmtiLineNumberEntry *line_number_table = NULL;
   384 
   371 
   385     NSK_DISPLAY0("Checking negative: GetSourceFileName\n");
   372     NSK_DISPLAY0("Checking negative: GetSourceFileName\n");
   386     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   373     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   387             NSK_CPP_STUB3(GetSourceFileName, jvmti, klass, &name)))
   374             jvmti->GetSourceFileName(klass, &name)))
   388         return NSK_FALSE;
   375         return NSK_FALSE;
   389 
   376 
   390     NSK_DISPLAY0("Checking negative: GetSourceDebugExtension\n");
   377     NSK_DISPLAY0("Checking negative: GetSourceDebugExtension\n");
   391     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   378     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   392             NSK_CPP_STUB3(GetSourceDebugExtension, jvmti, klass, &name)))
   379             jvmti->GetSourceDebugExtension(klass, &name)))
   393         return NSK_FALSE;
   380         return NSK_FALSE;
   394 
   381 
   395     NSK_DISPLAY0("Checking negative: GetLineNumberTable\n");
   382     NSK_DISPLAY0("Checking negative: GetLineNumberTable\n");
   396     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   383     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   397             NSK_CPP_STUB4(GetLineNumberTable, jvmti, method, &count,
   384             jvmti->GetLineNumberTable(method, &count, &line_number_table)))
   398                 &line_number_table)))
       
   399         return NSK_FALSE;
   385         return NSK_FALSE;
   400 
   386 
   401     return NSK_TRUE;
   387     return NSK_TRUE;
   402 }
   388 }
   403 
   389 
   409     NSK_DISPLAY0("Checking negative: RedefineClasses\n");
   395     NSK_DISPLAY0("Checking negative: RedefineClasses\n");
   410     class_def.klass = klass;
   396     class_def.klass = klass;
   411     class_def.class_byte_count = 0;
   397     class_def.class_byte_count = 0;
   412     class_def.class_bytes = NULL;
   398     class_def.class_bytes = NULL;
   413     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   399     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   414             NSK_CPP_STUB3(RedefineClasses, jvmti, 1, &class_def)))
   400             jvmti->RedefineClasses(1, &class_def)))
   415         return NSK_FALSE;
   401         return NSK_FALSE;
   416 
   402 
   417     return NSK_TRUE;
   403     return NSK_TRUE;
   418 }
   404 }
   419 
   405 
   422 static int checkGetObjectMonitorUsage() {
   408 static int checkGetObjectMonitorUsage() {
   423     jvmtiMonitorUsage monitor_info;
   409     jvmtiMonitorUsage monitor_info;
   424 
   410 
   425     NSK_DISPLAY0("Checking negative: GetObjectMonitorUsage\n");
   411     NSK_DISPLAY0("Checking negative: GetObjectMonitorUsage\n");
   426     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   412     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   427             NSK_CPP_STUB3(GetObjectMonitorUsage, jvmti, thread, &monitor_info)))
   413             jvmti->GetObjectMonitorUsage(thread, &monitor_info)))
   428         return NSK_FALSE;
   414         return NSK_FALSE;
   429 
   415 
   430     return NSK_TRUE;
   416     return NSK_TRUE;
   431 }
   417 }
   432 
   418 
   435 static int checkIsSyntheticFunctions() {
   421 static int checkIsSyntheticFunctions() {
   436     jboolean is_synthetic;
   422     jboolean is_synthetic;
   437 
   423 
   438     NSK_DISPLAY0("Checking negative: IsFieldSynthetic\n");
   424     NSK_DISPLAY0("Checking negative: IsFieldSynthetic\n");
   439     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   425     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   440             NSK_CPP_STUB4(IsFieldSynthetic, jvmti, klass, field, &is_synthetic)))
   426             jvmti->IsFieldSynthetic(klass, field, &is_synthetic)))
   441         return NSK_FALSE;
   427         return NSK_FALSE;
   442 
   428 
   443     NSK_DISPLAY0("Checking negative: IsMethodSynthetic\n");
   429     NSK_DISPLAY0("Checking negative: IsMethodSynthetic\n");
   444     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   430     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   445             NSK_CPP_STUB3(IsMethodSynthetic, jvmti, method, &is_synthetic)))
   431             jvmti->IsMethodSynthetic(method, &is_synthetic)))
   446         return NSK_FALSE;
   432         return NSK_FALSE;
   447 
   433 
   448     return NSK_TRUE;
   434     return NSK_TRUE;
   449 }
   435 }
   450 
   436 
   454     jint count;
   440     jint count;
   455     unsigned char *bytecodes;
   441     unsigned char *bytecodes;
   456 
   442 
   457     NSK_DISPLAY0("Checking negative: GetBytecodes\n");
   443     NSK_DISPLAY0("Checking negative: GetBytecodes\n");
   458     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   444     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   459             NSK_CPP_STUB4(GetBytecodes, jvmti, method, &count, &bytecodes)))
   445             jvmti->GetBytecodes(method, &count, &bytecodes)))
   460         return NSK_FALSE;
   446         return NSK_FALSE;
   461 
   447 
   462     return NSK_TRUE;
   448     return NSK_TRUE;
   463 }
   449 }
   464 
   450 
   468     jvmtiTimerInfo info;
   454     jvmtiTimerInfo info;
   469     jlong nanos;
   455     jlong nanos;
   470 
   456 
   471     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTimerInfo\n");
   457     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTimerInfo\n");
   472     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   458     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   473             NSK_CPP_STUB2(GetCurrentThreadCpuTimerInfo, jvmti, &info)))
   459             jvmti->GetCurrentThreadCpuTimerInfo(&info)))
   474         return NSK_FALSE;
   460         return NSK_FALSE;
   475 
   461 
   476     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTime\n");
   462     NSK_DISPLAY0("Checking negative: GetCurrentThreadCpuTime\n");
   477     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   463     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   478             NSK_CPP_STUB2(GetCurrentThreadCpuTime, jvmti, &nanos)))
   464             jvmti->GetCurrentThreadCpuTime(&nanos)))
   479         return NSK_FALSE;
   465         return NSK_FALSE;
   480 
   466 
   481     return NSK_TRUE;
   467     return NSK_TRUE;
   482 }
   468 }
   483 
   469 
   487     jvmtiTimerInfo info;
   473     jvmtiTimerInfo info;
   488     jlong nanos;
   474     jlong nanos;
   489 
   475 
   490     NSK_DISPLAY0("Checking negative: GetThreadCpuTimerInfo\n");
   476     NSK_DISPLAY0("Checking negative: GetThreadCpuTimerInfo\n");
   491     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   477     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   492             NSK_CPP_STUB2(GetThreadCpuTimerInfo, jvmti, &info)))
   478             jvmti->GetThreadCpuTimerInfo(&info)))
   493         return NSK_FALSE;
   479         return NSK_FALSE;
   494 
   480 
   495     NSK_DISPLAY0("Checking negative: GetThreadCpuTime\n");
   481     NSK_DISPLAY0("Checking negative: GetThreadCpuTime\n");
   496     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   482     if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
   497             NSK_CPP_STUB3(GetThreadCpuTime, jvmti, thread, &nanos)))
   483             jvmti->GetThreadCpuTime(thread, &nanos)))
   498         return NSK_FALSE;
   484         return NSK_FALSE;
   499 
   485 
   500     return NSK_TRUE;
   486     return NSK_TRUE;
   501 }
   487 }
   502 
   488 
   588     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
   574     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
   589         return JNI_ERR;
   575         return JNI_ERR;
   590 
   576 
   591     /* testcase #1: check GetPotentialCapabilities */
   577     /* testcase #1: check GetPotentialCapabilities */
   592     NSK_DISPLAY0("Testcase #1: check if GetPotentialCapabilities returns the capability\n");
   578     NSK_DISPLAY0("Testcase #1: check if GetPotentialCapabilities returns the capability\n");
   593     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetPotentialCapabilities, jvmti, &caps)))
   579     if (!NSK_JVMTI_VERIFY(jvmti->GetPotentialCapabilities(&caps)))
   594         return JNI_ERR;
   580         return JNI_ERR;
   595     if (!caps.CAPABILITY) {
   581     if (!caps.CAPABILITY) {
   596         NSK_COMPLAIN1("GetPotentialCapabilities does not return \"%s\" capability\n",
   582         NSK_COMPLAIN1("GetPotentialCapabilities does not return \"%s\" capability\n",
   597             CAPABILITY_STR);
   583             CAPABILITY_STR);
   598         return JNI_ERR;
   584         return JNI_ERR;
   600 
   586 
   601     /* testcase #2: add the capability during Onload phase */
   587     /* testcase #2: add the capability during Onload phase */
   602     NSK_DISPLAY0("Testcase #2: add the capability during Onload phase\n");
   588     NSK_DISPLAY0("Testcase #2: add the capability during Onload phase\n");
   603     memset(&caps, 0, sizeof(caps));
   589     memset(&caps, 0, sizeof(caps));
   604     caps.CAPABILITY = 1;
   590     caps.CAPABILITY = 1;
   605     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
   591     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
   606         return JNI_ERR;
   592         return JNI_ERR;
   607 
   593 
   608     /* testcase #3: check if GetCapabilities returns the capability */
   594     /* testcase #3: check if GetCapabilities returns the capability */
   609     NSK_DISPLAY0("Testcase #3: check if GetCapabilities returns the capability\n");
   595     NSK_DISPLAY0("Testcase #3: check if GetCapabilities returns the capability\n");
   610     memset(&caps, 0, sizeof(caps));
   596     memset(&caps, 0, sizeof(caps));
   611     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti, &caps)))
   597     if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
   612         return JNI_ERR;
   598         return JNI_ERR;
   613     if (!caps.CAPABILITY) {
   599     if (!caps.CAPABILITY) {
   614         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   600         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   615             CAPABILITY_STR);
   601             CAPABILITY_STR);
   616         return JNI_ERR;
   602         return JNI_ERR;
   618 
   604 
   619     /* testcase #4: relinquish the capability during Onload phase */
   605     /* testcase #4: relinquish the capability during Onload phase */
   620     NSK_DISPLAY0("Testcase #4: relinquish the capability during Onload phase\n");
   606     NSK_DISPLAY0("Testcase #4: relinquish the capability during Onload phase\n");
   621     memset(&caps, 0, sizeof(caps));
   607     memset(&caps, 0, sizeof(caps));
   622     caps.CAPABILITY = 1;
   608     caps.CAPABILITY = 1;
   623     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RelinquishCapabilities, jvmti, &caps)))
   609     if (!NSK_JVMTI_VERIFY(jvmti->RelinquishCapabilities(&caps)))
   624         return JNI_ERR;
   610         return JNI_ERR;
   625 
   611 
   626     /* testcase #5: check if GetCapabilities does not return the capability */
   612     /* testcase #5: check if GetCapabilities does not return the capability */
   627     NSK_DISPLAY0("Testcase #5: check if GetCapabilities does not return the capability\n");
   613     NSK_DISPLAY0("Testcase #5: check if GetCapabilities does not return the capability\n");
   628     memset(&caps, 0, sizeof(caps));
   614     memset(&caps, 0, sizeof(caps));
   629     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti, &caps)))
   615     if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
   630         return JNI_ERR;
   616         return JNI_ERR;
   631     if (caps.CAPABILITY) {
   617     if (caps.CAPABILITY) {
   632         NSK_COMPLAIN1("GetCapabilities returns relinquished \"%s\" capability\n",
   618         NSK_COMPLAIN1("GetCapabilities returns relinquished \"%s\" capability\n",
   633             CAPABILITY_STR);
   619             CAPABILITY_STR);
   634         return JNI_ERR;
   620         return JNI_ERR;
   636 
   622 
   637     /* testcase #6: add back the capability and check with GetCapabilities */
   623     /* testcase #6: add back the capability and check with GetCapabilities */
   638     NSK_DISPLAY0("Testcase #6: add back the capability and check with GetCapabilities\n");
   624     NSK_DISPLAY0("Testcase #6: add back the capability and check with GetCapabilities\n");
   639     memset(&caps, 0, sizeof(caps));
   625     memset(&caps, 0, sizeof(caps));
   640     caps.CAPABILITY = 1;
   626     caps.CAPABILITY = 1;
   641     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(AddCapabilities, jvmti, &caps)))
   627     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
   642         return JNI_ERR;
   628         return JNI_ERR;
   643     memset(&caps, 0, sizeof(caps));
   629     memset(&caps, 0, sizeof(caps));
   644     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(GetCapabilities, jvmti, &caps)))
   630     if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
   645         return JNI_ERR;
   631         return JNI_ERR;
   646     if (!caps.CAPABILITY) {
   632     if (!caps.CAPABILITY) {
   647         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   633         NSK_COMPLAIN1("GetCapabilities does not return \"%s\" capability\n",
   648             CAPABILITY_STR);
   634             CAPABILITY_STR);
   649         return JNI_ERR;
   635         return JNI_ERR;