404 405 //release resources allocated in tag_objects 406 void release_object_info(jvmtiEnv *jvmti, JNIEnv *jni) { 407 int object; 408 int field; 409 for (object = 0; object < TEST_OBJECTS_COUNT; object++) { 410 for (field = 0; field < objects_info[object].fields_count; field++) { 411 jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].name); 412 jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].signature); 413 } 414 jvmti->Deallocate((unsigned char*)objects_info[object].name); 415 free(objects_info[object].fields); 416 } 417 } 418 419 // Check that every field was found expected amount of times 420 void verify_objects(int reachable) { 421 int object; 422 int field; 423 for (object = 0; object < (reachable?TEST_OBJECTS_COUNT:TAGGED_OBJECTS); object++) { 424 for (field = 0; field < objects_info[object].fields_count; field++) { 425 // If primitive field of object that was not collected or 426 // non primitive field that was not collected was not found 427 // expected amount of times, than test failed. 428 if ((objects_info[object].fields[field].primitive && 429 !objects_info[object].collected) 430 || 431 (!objects_info[object].fields[field].primitive && 432 !objects_info[object].fields[field].collected)) { 433 if (objects_info[object].fields[field].expected != 434 objects_info[object].fields[field].found) { 435 NSK_COMPLAIN4("Field %s::%s expected to be found %d times, " 436 "but it was found %d times.\n", 437 objects_info[object].name, 438 objects_info[object].fields[field].name, 439 objects_info[object].fields[field].expected, 440 objects_info[object].fields[field].found); 441 nsk_jvmti_setFailStatus(); 442 } 443 } 444 objects_info[object].fields[field].found = 0; 445 } 446 } 447 } 448 449 static void JNICALL 450 agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { 451 jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; 452 jvmtiHeapCallbacks primitive_callbacks; 453 jvmtiEventCallbacks event_callbacks; 454 | 404 405 //release resources allocated in tag_objects 406 void release_object_info(jvmtiEnv *jvmti, JNIEnv *jni) { 407 int object; 408 int field; 409 for (object = 0; object < TEST_OBJECTS_COUNT; object++) { 410 for (field = 0; field < objects_info[object].fields_count; field++) { 411 jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].name); 412 jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].signature); 413 } 414 jvmti->Deallocate((unsigned char*)objects_info[object].name); 415 free(objects_info[object].fields); 416 } 417 } 418 419 // Check that every field was found expected amount of times 420 void verify_objects(int reachable) { 421 int object; 422 int field; 423 for (object = 0; object < (reachable?TEST_OBJECTS_COUNT:TAGGED_OBJECTS); object++) { 424 int tagged = object == 0; 425 for (field = 0; field < objects_info[object].fields_count; field++) { 426 // If primitive field of object that was not collected or 427 // non primitive field that was not collected was not found 428 // expected amount of times, than test failed. 429 if ((objects_info[object].fields[field].primitive && 430 !objects_info[object].collected) 431 || 432 (!objects_info[object].fields[field].primitive && 433 !objects_info[object].fields[field].collected)) { 434 int expected = objects_info[object].fields[field].expected; 435 int found = objects_info[object].fields[field].found; 436 if (tagged ? expected != found : expected > found) { 437 NSK_COMPLAIN4("Field %s::%s expected to be found %d times, " 438 "but it was found %d times.\n", 439 objects_info[object].name, 440 objects_info[object].fields[field].name, 441 objects_info[object].fields[field].expected, 442 objects_info[object].fields[field].found); 443 nsk_jvmti_setFailStatus(); 444 } 445 } 446 objects_info[object].fields[field].found = 0; 447 } 448 } 449 } 450 451 static void JNICALL 452 agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) { 453 jvmtiEvent event = JVMTI_EVENT_OBJECT_FREE; 454 jvmtiHeapCallbacks primitive_callbacks; 455 jvmtiEventCallbacks event_callbacks; 456 |