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