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