8212939: Add space after if/while/for/switch and parenthesis
Add spaces where needed Reviewed-by: cjplummer, sspitsyn
This commit is contained in:
parent
e3d65f1c12
commit
1d340e454c
@ -38,7 +38,7 @@ Java_nsk_jdi_ThreadReference_forceEarlyReturn_forceEarlyReturn004_forceEarlyRetu
|
||||
env->SetBooleanField(object, field, 1);
|
||||
|
||||
// execute infinite loop to be sure that thread in native method
|
||||
while(always_true)
|
||||
while (always_true)
|
||||
{
|
||||
// Need some dummy code so the optimizer does not remove this loop.
|
||||
dummy_counter = dummy_counter < 1000 ? 0 : dummy_counter + 1;
|
||||
|
@ -32,7 +32,7 @@ Java_nsk_jdi_ThreadReference_forceEarlyReturn_forceEarlyReturn005_forceEarlyRetu
|
||||
{
|
||||
jint success = env->MonitorEnter(object);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
|
@ -38,7 +38,7 @@ Java_nsk_jdwp_ThreadReference_ForceEarlyReturn_forceEarlyReturn002_forceEarlyRet
|
||||
env->SetBooleanField(object, field, 1);
|
||||
|
||||
// execute infinite loop to be sure that thread in native method
|
||||
while(always_true)
|
||||
while (always_true)
|
||||
{
|
||||
// Need some dummy code so the optimizer does not remove this loop.
|
||||
dummy_counter = dummy_counter < 1000 ? 0 : dummy_counter + 1;
|
||||
|
@ -73,7 +73,7 @@ void JNICALL monitorContentedEnteredHandler(
|
||||
jobject object) {
|
||||
char threadName[MAX_STRING_LENGTH];
|
||||
|
||||
if(!nsk_jvmti_aod_getThreadName(jvmti, thread, threadName)) {
|
||||
if (!nsk_jvmti_aod_getThreadName(jvmti, thread, threadName)) {
|
||||
nsk_jvmti_aod_disableEventsAndFinish(agentName, testEvents, testEventsNumber, 0, jvmti, jni);
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ int tryFindThread(jvmtiEnv *jvmti, jthreadGroup group, const char* threadNameToF
|
||||
int i;
|
||||
char threadGroupName[MAX_STRING_LENGTH];
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetThreadGroupInfo(group, &groupInfo))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetThreadGroupInfo(group, &groupInfo))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ int tryFindThread(jvmtiEnv *jvmti, jthreadGroup group, const char* threadNameToF
|
||||
|
||||
NSK_DISPLAY3("%s: trying to find thread '%s' in group '%s'\n", agentName, threadNameToFind, threadGroupName);
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetThreadGroupChildren(group, &threadsCount, &threads, &groupsCount, &groups))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetThreadGroupChildren(group, &threadsCount, &threads, &groupsCount, &groups))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ void JNICALL threadStartHandler(jvmtiEnv *jvmti,
|
||||
jthreadGroup *topGroups;
|
||||
int i;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetTopThreadGroups(&groupsCount, &topGroups))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetTopThreadGroups(&groupsCount, &topGroups))) {
|
||||
NSK_COMPLAIN1("%s: failed to get top thread groups\n", agentName);
|
||||
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_THREAD_START, 0, jvmti, jni);
|
||||
return;
|
||||
|
@ -48,7 +48,7 @@ void JNICALL threadStartHandler(jvmtiEnv *jvmti,
|
||||
jthread thread) {
|
||||
char startedThreadName[MAX_STRING_LENGTH];
|
||||
|
||||
if(!nsk_jvmti_aod_getThreadName(jvmti, thread, startedThreadName)) {
|
||||
if (!nsk_jvmti_aod_getThreadName(jvmti, thread, startedThreadName)) {
|
||||
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_THREAD_START, 0, jvmti, jni);
|
||||
return;
|
||||
}
|
||||
@ -62,7 +62,7 @@ void JNICALL threadStartHandler(jvmtiEnv *jvmti,
|
||||
int i;
|
||||
int startedThreadWasFound = 0;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threadsCount, &threads))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threadsCount, &threads))) {
|
||||
NSK_COMPLAIN1("%s: failed to get all threads\n", agentName);
|
||||
nsk_jvmti_aod_disableEventAndFinish(agentName, JVMTI_EVENT_THREAD_START, 0, jvmti, jni);
|
||||
return;
|
||||
|
@ -58,7 +58,7 @@ static jrawMonitorID agent_lock;
|
||||
static void initCounters() {
|
||||
int i;
|
||||
|
||||
for(i=0; i<METH_NUM; i++)
|
||||
for (i=0; i<METH_NUM; i++)
|
||||
bpEvents[i] = 0;
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,10 @@ static jrawMonitorID countLock;
|
||||
static void initCounters() {
|
||||
size_t i;
|
||||
|
||||
for(i=0; i<EXP_SIG_NUM; i++)
|
||||
for (i=0; i<EXP_SIG_NUM; i++)
|
||||
clsEvents[i] = 0;
|
||||
|
||||
for(i=0; i<UNEXP_SIG_NUM; i++)
|
||||
for (i=0; i<UNEXP_SIG_NUM; i++)
|
||||
primClsEvents[i] = 0;
|
||||
}
|
||||
|
||||
|
@ -81,10 +81,10 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
int invocations = 0;
|
||||
|
||||
NSK_DISPLAY0("Waiting debugee.\n");
|
||||
if(!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
return;
|
||||
}
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,18 +95,18 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
primitive_callbacks.heap_iteration_callback = &heap_callback;
|
||||
|
||||
NSK_DISPLAY0("Iterating over reachable objects.\n");
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, &invocations))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, &invocations))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
if(invocations != 1) {
|
||||
if (invocations != 1) {
|
||||
NSK_COMPLAIN1("Primitive callbacks were invoked more than once: "
|
||||
"%d invocations registered.\n",invocations);
|
||||
nsk_jvmti_setFailStatus();
|
||||
}
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -139,12 +139,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&event_callbacks, 0, sizeof(jvmtiEventCallbacks));
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
|
@ -111,25 +111,25 @@ static object_info_t objects_info[TEST_OBJECTS_COUNT];
|
||||
|
||||
// Check if the signature is signature of primitive type.
|
||||
jboolean is_primitive_type(const char *signature) {
|
||||
if(!strcmp(signature,"C")
|
||||
|| !strcmp(signature, "B")
|
||||
|| !strcmp(signature, "S")
|
||||
|| !strcmp(signature, "I")
|
||||
|| !strcmp(signature, "J")
|
||||
|| !strcmp(signature, "F")
|
||||
|| !strcmp(signature, "D")
|
||||
|| !strcmp(signature, "Z"))
|
||||
if (!strcmp(signature,"C")
|
||||
|| !strcmp(signature, "B")
|
||||
|| !strcmp(signature, "S")
|
||||
|| !strcmp(signature, "I")
|
||||
|| !strcmp(signature, "J")
|
||||
|| !strcmp(signature, "F")
|
||||
|| !strcmp(signature, "D")
|
||||
|| !strcmp(signature, "Z"))
|
||||
return JNI_TRUE;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
// For given signature find expected tag type
|
||||
int get_tag_type(const char *signature) {
|
||||
if(is_primitive_type(signature)) {
|
||||
if (is_primitive_type(signature)) {
|
||||
return TAG_TYPE_PRIMITIVE;
|
||||
} else if(signature[0]=='[' && is_primitive_type(signature+1)) {
|
||||
} else if (signature[0]=='[' && is_primitive_type(signature+1)) {
|
||||
return TAG_TYPE_ARRAY;
|
||||
} else if(!strcmp(signature, "Ljava/lang/String;")) {
|
||||
} else if (!strcmp(signature, "Ljava/lang/String;")) {
|
||||
return TAG_TYPE_STRING;
|
||||
} else {
|
||||
return TAG_TYPE_OBJECT;
|
||||
@ -141,7 +141,7 @@ int get_tag_type(const char *signature) {
|
||||
* Returns 0 if value matched with expected.
|
||||
*/
|
||||
jboolean verify_value(jvalue value, jvmtiPrimitiveType type) {
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case JVMTI_PRIMITIVE_TYPE_BOOLEAN:
|
||||
return value.z==BOOLEAN;
|
||||
case JVMTI_PRIMITIVE_TYPE_BYTE:
|
||||
@ -167,7 +167,7 @@ jboolean verify_value(jvalue value, jvmtiPrimitiveType type) {
|
||||
// Check that array values are correct depending on type of elements
|
||||
jboolean verify_array(const void *array, jvmtiPrimitiveType type, jint length) {
|
||||
void *expected_array;
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case JVMTI_PRIMITIVE_TYPE_BOOLEAN:
|
||||
expected_array = (void*)BOOLEAN_ARRAY;
|
||||
break;
|
||||
@ -210,11 +210,11 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
tag = *object_tag_ptr;
|
||||
|
||||
// skip all non-tagged fields as well as fields of tagged objects
|
||||
if(tag == 0 ||
|
||||
DECODE_TYPE(tag) == TAG_TYPE_OBJECT ||
|
||||
DECODE_TYPE(tag) == TAG_TYPE_STRING) {
|
||||
if (tag == 0 ||
|
||||
DECODE_TYPE(tag) == TAG_TYPE_OBJECT ||
|
||||
DECODE_TYPE(tag) == TAG_TYPE_STRING) {
|
||||
return 0;
|
||||
} else if(DECODE_TYPE(tag) != TAG_TYPE_PRIMITIVE) {
|
||||
} else if (DECODE_TYPE(tag) != TAG_TYPE_PRIMITIVE) {
|
||||
NSK_COMPLAIN3("jvmtiPrimitiveFieldCallback was invoked for an object with "
|
||||
"non-primitive field tag (0x%lX) corresponging to %s::%s.\n",
|
||||
DECODE_TYPE(tag),
|
||||
@ -226,7 +226,7 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
|
||||
objects_info[DECODE_OBJECT(tag)].fields[info->field.index].found++;
|
||||
|
||||
if(!verify_value(value, value_type)) {
|
||||
if (!verify_value(value, value_type)) {
|
||||
NSK_COMPLAIN2("Field %s::%s has unexpected value.\n",
|
||||
objects_info[DECODE_OBJECT(tag)].name,
|
||||
objects_info[DECODE_OBJECT(tag)].fields[info->field.index].name);
|
||||
@ -245,9 +245,9 @@ jint JNICALL string_callback(jlong class_tag,
|
||||
int i;
|
||||
|
||||
//skip all untegged strings
|
||||
if(*tag_ptr==0) {
|
||||
if (*tag_ptr==0) {
|
||||
return 0;
|
||||
} else if(DECODE_TYPE(*tag_ptr) != TAG_TYPE_STRING) {
|
||||
} else if (DECODE_TYPE(*tag_ptr) != TAG_TYPE_STRING) {
|
||||
NSK_COMPLAIN2("jvmtiStringPrimitiveValueCallback was invoked for an object "
|
||||
"with non-string tag corresponding to %s::%s.\n",
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].name,
|
||||
@ -258,7 +258,7 @@ jint JNICALL string_callback(jlong class_tag,
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].fields[DECODE_FIELD(*tag_ptr)].found++;
|
||||
|
||||
//check that reported length is the same as expected
|
||||
if(value_length != (jint) wcslen(STRING)) {
|
||||
if (value_length != (jint) wcslen(STRING)) {
|
||||
NSK_COMPLAIN4("Length of reported string %s::%s is %d while %d is expected.\n",
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].name,
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].fields[DECODE_FIELD(*tag_ptr)].name,
|
||||
@ -269,11 +269,11 @@ jint JNICALL string_callback(jlong class_tag,
|
||||
}
|
||||
|
||||
//compare reported value with expected one
|
||||
for(i = 0; i<value_length && matched; i++) {
|
||||
for (i = 0; i<value_length && matched; i++) {
|
||||
matched = value[i] == STRING[i];
|
||||
}
|
||||
|
||||
if(!matched) {
|
||||
if (!matched) {
|
||||
NSK_COMPLAIN2("Value of field %s::%s has unexpected value.\n",
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].name,
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].fields[DECODE_FIELD(*tag_ptr)].name);
|
||||
@ -291,9 +291,9 @@ jint JNICALL array_callback(jlong class_tag,
|
||||
const void* elements,
|
||||
void* user_data) {
|
||||
//skip untegged arrays
|
||||
if(*tag_ptr == 0) {
|
||||
if (*tag_ptr == 0) {
|
||||
return 0;
|
||||
} else if(DECODE_TYPE(*tag_ptr) != TAG_TYPE_ARRAY) {
|
||||
} else if (DECODE_TYPE(*tag_ptr) != TAG_TYPE_ARRAY) {
|
||||
NSK_COMPLAIN2("jvmtiArrayPrimitiveValueCallbak was invoked for object "
|
||||
"with non-array tag corresponding to %s::%s.\n",
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].name,
|
||||
@ -305,14 +305,14 @@ jint JNICALL array_callback(jlong class_tag,
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].fields[DECODE_FIELD(*tag_ptr)].found++;
|
||||
|
||||
//check if reported length is the same as expected
|
||||
if(element_count != ARRAY_LENGTH) {
|
||||
if (element_count != ARRAY_LENGTH) {
|
||||
NSK_COMPLAIN4("Length of array %s::%s is %d while %d is expected.\n",
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].name,
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].fields[DECODE_FIELD(*tag_ptr)].name,
|
||||
element_count,
|
||||
ARRAY_LENGTH);
|
||||
nsk_jvmti_setFailStatus();
|
||||
} else if(!verify_array(elements, element_type, element_count)) {
|
||||
} else if (!verify_array(elements, element_type, element_count)) {
|
||||
//compare array with expected one
|
||||
NSK_COMPLAIN2("Value of field %s::%s has unexpected value.\n",
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].name,
|
||||
@ -328,11 +328,11 @@ jint JNICALL heap_callback(jlong class_tag,
|
||||
jint length,
|
||||
void* user_data) {
|
||||
//skip untagged objects
|
||||
if(*tag_ptr == 0) {
|
||||
if (*tag_ptr == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(DECODE_TYPE(*tag_ptr) != TAG_TYPE_PRIMITIVE) {
|
||||
if (DECODE_TYPE(*tag_ptr) != TAG_TYPE_PRIMITIVE) {
|
||||
objects_info[DECODE_OBJECT(*tag_ptr)].fields[DECODE_FIELD(*tag_ptr)].found++;
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ jint JNICALL heap_callback(jlong class_tag,
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
object_free_callback(jvmtiEnv* jvmti, jlong tag) {
|
||||
if(DECODE_TYPE(tag)==TAG_TYPE_PRIMITIVE) {
|
||||
if (DECODE_TYPE(tag)==TAG_TYPE_PRIMITIVE) {
|
||||
int object = DECODE_OBJECT(tag);
|
||||
objects_info[object].collected = 1;
|
||||
NSK_DISPLAY1("Object %s collected.\n",
|
||||
@ -368,69 +368,69 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
jobjectArray testObjects;
|
||||
int object;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (debugee = jni->FindClass(className))))
|
||||
if (!NSK_VERIFY(NULL != (debugee = jni->FindClass(className))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig))))
|
||||
if (!NSK_VERIFY(NULL != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (testObjects = (jobjectArray)(jni->GetStaticObjectField(
|
||||
if (!NSK_VERIFY(NULL != (testObjects = (jobjectArray)(jni->GetStaticObjectField(
|
||||
debugee, testObjectsField)))))
|
||||
return JNI_ERR;
|
||||
|
||||
// For each of test objects tag every field
|
||||
for(object = 0; object<TEST_OBJECTS_COUNT; object++) {
|
||||
for (object = 0; object<TEST_OBJECTS_COUNT; object++) {
|
||||
jobject target;
|
||||
jclass targetClass;
|
||||
jfieldID *targetFields;
|
||||
jint field;
|
||||
|
||||
memset(&objects_info[object],0,sizeof(object_info_t));
|
||||
if(!NSK_VERIFY(NULL != (target = jni->GetObjectArrayElement(testObjects, object))))
|
||||
if (!NSK_VERIFY(NULL != (target = jni->GetObjectArrayElement(testObjects, object))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (targetClass = jni->GetObjectClass(target))))
|
||||
if (!NSK_VERIFY(NULL != (targetClass = jni->GetObjectClass(target))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), NULL)))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), NULL)))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetClassFields(
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetClassFields(
|
||||
targetClass, &(objects_info[object].fields_count), &targetFields)))
|
||||
return JNI_ERR;
|
||||
|
||||
objects_info[object].fields = (field_info_t*)calloc(objects_info[object].fields_count,sizeof(field_info_t));
|
||||
|
||||
// Iterate over fields, collect info about it and tag non primitive fields.
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetFieldName(targetClass,
|
||||
targetFields[field],
|
||||
&objects_info[object].fields[field].name,
|
||||
&objects_info[object].fields[field].signature,
|
||||
NULL)))
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetFieldName(targetClass,
|
||||
targetFields[field],
|
||||
&objects_info[object].fields[field].name,
|
||||
&objects_info[object].fields[field].signature,
|
||||
NULL)))
|
||||
return JNI_ERR;
|
||||
if(is_primitive_type(objects_info[object].fields[field].signature)) {
|
||||
if (is_primitive_type(objects_info[object].fields[field].signature)) {
|
||||
objects_info[object].fields[field].primitive = 1;
|
||||
} else {
|
||||
jint modifiers;
|
||||
jobject value;
|
||||
int tag_type = get_tag_type(objects_info[object].fields[field].signature);
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers(
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers(
|
||||
targetClass, targetFields[field], &modifiers))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
if(modifiers & STATIC_FIELD) {
|
||||
if(!NSK_VERIFY(NULL != (value = jni->GetStaticObjectField(targetClass,
|
||||
targetFields[field])))) {
|
||||
if (modifiers & STATIC_FIELD) {
|
||||
if (!NSK_VERIFY(NULL != (value = jni->GetStaticObjectField(targetClass,
|
||||
targetFields[field])))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
} else {
|
||||
if(!NSK_VERIFY(NULL != (value = jni->GetObjectField(target, targetFields[field])))) {
|
||||
if (!NSK_VERIFY(NULL != (value = jni->GetObjectField(target, targetFields[field])))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
}
|
||||
//tag field's value
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(value, ENCODE_TAG(tag_type,object,field)))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(value, ENCODE_TAG(tag_type,object,field)))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
//remove local reference so object will have a chance to become unreachable
|
||||
@ -439,9 +439,9 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
}
|
||||
|
||||
// tag class and it's instance to pass this tag into primitive field callback
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(target, ENCODE_TAG(TAG_TYPE_PRIMITIVE,object,0))))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(target, ENCODE_TAG(TAG_TYPE_PRIMITIVE,object,0))))
|
||||
return JNI_ERR;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(targetClass, ENCODE_TAG(TAG_TYPE_PRIMITIVE,object,0))))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(targetClass, ENCODE_TAG(TAG_TYPE_PRIMITIVE,object,0))))
|
||||
return JNI_ERR;
|
||||
|
||||
NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)targetFields));
|
||||
@ -459,8 +459,8 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
void release_object_info(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
int object;
|
||||
int field;
|
||||
for(object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
for (object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].name);
|
||||
jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].signature);
|
||||
}
|
||||
@ -473,15 +473,15 @@ void release_object_info(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
void verify_objects() {
|
||||
int object;
|
||||
int field;
|
||||
for(object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
for (object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
// If primitive field of object that was not collected or
|
||||
// non primitive field that was not collected was not found
|
||||
// expected amount of times, than test failed.
|
||||
if((objects_info[object].fields[field].primitive && !objects_info[object].collected)
|
||||
|| !objects_info[object].fields[field].collected) {
|
||||
if ((objects_info[object].fields[field].primitive && !objects_info[object].collected)
|
||||
|| !objects_info[object].fields[field].collected) {
|
||||
int expected = 0;
|
||||
switch(get_tag_type(objects_info[object].fields[field].signature)) {
|
||||
switch (get_tag_type(objects_info[object].fields[field].signature)) {
|
||||
case TAG_TYPE_STRING:
|
||||
expected = STRING_OCCURANCE_COUNT;
|
||||
break;
|
||||
@ -495,7 +495,7 @@ void verify_objects() {
|
||||
expected = NONPRIMITIVE_OCCURANCE_COUNT;
|
||||
break;
|
||||
}
|
||||
if(expected != objects_info[object].fields[field].found) {
|
||||
if (expected != objects_info[object].fields[field].found) {
|
||||
NSK_COMPLAIN4("Field %s::%s expected to be found %d times, "
|
||||
"but it was found %d times.\n",
|
||||
objects_info[object].name,
|
||||
@ -515,15 +515,15 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
jvmtiHeapCallbacks primitive_callbacks;
|
||||
|
||||
NSK_DISPLAY0("Waiting debugee.\n");
|
||||
if(!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
return;
|
||||
}
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY0("Tagging fields.\n");
|
||||
if(!NSK_VERIFY(JNI_OK==tag_objects(jvmti, jni))) {
|
||||
if (!NSK_VERIFY(JNI_OK==tag_objects(jvmti, jni))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -534,7 +534,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
primitive_callbacks.heap_iteration_callback = &heap_callback;
|
||||
|
||||
NSK_DISPLAY0("Iterating over reachable objects.\n");
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
@ -542,16 +542,16 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
NSK_DISPLAY0("Verifying that all filds were found.\n");
|
||||
verify_objects();
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync())) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY0("Iterating over unreachable objects.\n");
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, NULL, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
@ -559,13 +559,13 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
NSK_DISPLAY0("Verifying that all filds were found.\n");
|
||||
verify_objects();
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_DISABLE, 1, &event, NULL))) {
|
||||
return;
|
||||
}
|
||||
|
||||
release_object_info(jvmti, jni);
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -598,13 +598,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&event_callbacks, 0, sizeof(jvmtiEventCallbacks));
|
||||
event_callbacks.ObjectFree = &object_free_callback;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
jvmtiPrimitiveType value_type,
|
||||
void* user_data) {
|
||||
//only field of our test object are expected
|
||||
if(*object_tag_ptr != TEST_OBJECT_TAG) {
|
||||
if (*object_tag_ptr != TEST_OBJECT_TAG) {
|
||||
NSK_COMPLAIN2("jvmtiPrimitiveFieldCallback was invoked for primitive "
|
||||
"field with unexpected class tag 0x%lX and object tag 0x%lX.\n",
|
||||
object_class_tag, *object_tag_ptr);
|
||||
@ -64,13 +64,13 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
return 0;
|
||||
}
|
||||
//expected field is long
|
||||
if(value_type != JVMTI_PRIMITIVE_TYPE_LONG) {
|
||||
if (value_type != JVMTI_PRIMITIVE_TYPE_LONG) {
|
||||
NSK_COMPLAIN0("jvmtiPrimitiveFieldCallback was invoked for non-long field.\n");
|
||||
nsk_jvmti_setFailStatus();
|
||||
return 0;
|
||||
}
|
||||
//check value
|
||||
if(value.j != EXPECTED_PRIMITIVE_VALUE) {
|
||||
if (value.j != EXPECTED_PRIMITIVE_VALUE) {
|
||||
NSK_COMPLAIN0("Unexpected value was passed to jvmtiPrimitiveFieldCallback.\n");
|
||||
NSK_COMPLAIN1("Expected value: 0x%lX.\n", EXPECTED_PRIMITIVE_VALUE);
|
||||
NSK_COMPLAIN1("Passed value: 0x%lX.\n", value.j);
|
||||
@ -114,7 +114,7 @@ jint JNICALL heap_callback(jlong class_tag,
|
||||
jint length,
|
||||
void* user_data) {
|
||||
//test object have to be reported by this callback
|
||||
if(*tag_ptr != TEST_OBJECT_TAG) {
|
||||
if (*tag_ptr != TEST_OBJECT_TAG) {
|
||||
NSK_COMPLAIN2("Object with unexpected class tag 0x%lX and object tag 0x%lX "
|
||||
"was passed to jvmtiHeapIterationCallback.\n", class_tag, *tag_ptr);
|
||||
nsk_jvmti_setFailStatus();
|
||||
@ -123,7 +123,7 @@ jint JNICALL heap_callback(jlong class_tag,
|
||||
|
||||
non_primitive_reported++;
|
||||
|
||||
if(non_primitive_reported>EXPECTED_NON_PRIMITIVES_COUNT) {
|
||||
if (non_primitive_reported>EXPECTED_NON_PRIMITIVES_COUNT) {
|
||||
NSK_COMPLAIN1("Test object was reported more than %d times.\n",
|
||||
EXPECTED_NON_PRIMITIVES_COUNT);
|
||||
nsk_jvmti_setFailStatus();
|
||||
@ -134,7 +134,7 @@ jint JNICALL heap_callback(jlong class_tag,
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
object_free_callback(jvmtiEnv* jvmti, jlong tag) {
|
||||
if(tag != TEST_OBJECT_TAG) {
|
||||
if (tag != TEST_OBJECT_TAG) {
|
||||
NSK_COMPLAIN1("object free callback was invoked for an object with "
|
||||
"unexpected tag 0x%lX.\n",tag);
|
||||
nsk_jvmti_setFailStatus();
|
||||
@ -152,22 +152,22 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
jobject testObject;
|
||||
jclass testObjectClass;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (debugee = jni->FindClass(className))))
|
||||
if (!NSK_VERIFY(NULL != (debugee = jni->FindClass(className))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (testObjectField = jni->GetStaticFieldID(debugee, fieldName, fieldSig))))
|
||||
if (!NSK_VERIFY(NULL != (testObjectField = jni->GetStaticFieldID(debugee, fieldName, fieldSig))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (testObject = (jni->GetStaticObjectField(debugee, testObjectField)))))
|
||||
if (!NSK_VERIFY(NULL != (testObject = (jni->GetStaticObjectField(debugee, testObjectField)))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (testObjectClass = (jni->GetObjectClass(testObject)))))
|
||||
if (!NSK_VERIFY(NULL != (testObjectClass = (jni->GetObjectClass(testObject)))))
|
||||
return JNI_ERR;
|
||||
|
||||
// tag class and it's instance to pass this tag into primitive field callback
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(testObject, TEST_OBJECT_TAG)))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(testObject, TEST_OBJECT_TAG)))
|
||||
return JNI_ERR;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(testObjectClass, TEST_OBJECT_TAG)))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(testObjectClass, TEST_OBJECT_TAG)))
|
||||
return JNI_ERR;
|
||||
|
||||
jni->DeleteLocalRef(testObjectClass);
|
||||
@ -178,8 +178,8 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
|
||||
void verify_objects() {
|
||||
//if test object was not unloaded then it's field expected to be found once.
|
||||
if(object_unloaded) return;
|
||||
if(field_found == 0) {
|
||||
if (object_unloaded) return;
|
||||
if (field_found == 0) {
|
||||
NSK_COMPLAIN0("TestClass instance field was not found.\n");
|
||||
nsk_jvmti_setFailStatus();
|
||||
} if (field_found > 1) {
|
||||
@ -197,22 +197,22 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
jvmtiHeapCallbacks primitive_callbacks;
|
||||
jclass klass;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (klass = jni->FindClass(testClassName)))) {
|
||||
if (!NSK_VERIFY(NULL != (klass = jni->FindClass(testClassName)))) {
|
||||
NSK_COMPLAIN1("Can't find class %s.\n",testClassName);
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY0("Waiting debugee.\n");
|
||||
if(!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
return;
|
||||
}
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY0("Tagging fields.\n");
|
||||
if(!NSK_VERIFY(JNI_OK==tag_objects(jvmti, jni))) {
|
||||
if (!NSK_VERIFY(JNI_OK==tag_objects(jvmti, jni))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
primitive_callbacks.heap_iteration_callback = &heap_callback;
|
||||
|
||||
NSK_DISPLAY0("Iterating over reachable objects.\n");
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
@ -231,16 +231,16 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
NSK_DISPLAY0("Verifying that all filds were found.\n");
|
||||
verify_objects();
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync())) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY0("Iterating over unreachable objects.\n");
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
@ -248,7 +248,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
NSK_DISPLAY0("Verifying that all filds were found.\n");
|
||||
verify_objects();
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -281,13 +281,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&event_callbacks, 0, sizeof(jvmtiEventCallbacks));
|
||||
event_callbacks.ObjectFree = &object_free_callback;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
|
@ -108,21 +108,21 @@ static object_info_t objects_info[TEST_OBJECTS_COUNT];
|
||||
|
||||
// Check if the signature is signature of primitive type.
|
||||
jboolean is_primitive_type(const char *signature) {
|
||||
if(!strcmp(signature,"C")
|
||||
|| !strcmp(signature, "B")
|
||||
|| !strcmp(signature, "S")
|
||||
|| !strcmp(signature, "I")
|
||||
|| !strcmp(signature, "J")
|
||||
|| !strcmp(signature, "F")
|
||||
|| !strcmp(signature, "D")
|
||||
|| !strcmp(signature, "Z"))
|
||||
if (!strcmp(signature,"C")
|
||||
|| !strcmp(signature, "B")
|
||||
|| !strcmp(signature, "S")
|
||||
|| !strcmp(signature, "I")
|
||||
|| !strcmp(signature, "J")
|
||||
|| !strcmp(signature, "F")
|
||||
|| !strcmp(signature, "D")
|
||||
|| !strcmp(signature, "Z"))
|
||||
return JNI_TRUE;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
//check tag values accoring to heap filter choosed for test
|
||||
jboolean verify_tag(jlong class_tag, jlong object_tag) {
|
||||
switch(filter_type) {
|
||||
switch (filter_type) {
|
||||
case JVMTI_HEAP_FILTER_TAGGED:
|
||||
return object_tag == 0;
|
||||
case JVMTI_HEAP_FILTER_UNTAGGED:
|
||||
@ -138,7 +138,7 @@ jboolean verify_tag(jlong class_tag, jlong object_tag) {
|
||||
|
||||
//check whether or not field expected to be reported
|
||||
jboolean occurance_expected(int tagged, int is_static, int is_primitive) {
|
||||
switch(filter_type) {
|
||||
switch (filter_type) {
|
||||
case JVMTI_HEAP_FILTER_TAGGED:
|
||||
return !tagged;
|
||||
case JVMTI_HEAP_FILTER_UNTAGGED:
|
||||
@ -167,11 +167,11 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
|
||||
//iterate over all fields found during tagging and compare reported value
|
||||
//with their values.
|
||||
if(value_type != JVMTI_PRIMITIVE_TYPE_INT)
|
||||
if (value_type != JVMTI_PRIMITIVE_TYPE_INT)
|
||||
return 0;
|
||||
for(object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if(objects_info[object].fields[field].type == TYPE_FIELD &&
|
||||
for (object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if (objects_info[object].fields[field].type == TYPE_FIELD &&
|
||||
*(jint*)(objects_info[object].fields[field].value) == value.i) {
|
||||
objects_info[object].fields[field].found++;
|
||||
}
|
||||
@ -191,17 +191,17 @@ jint JNICALL string_callback(jlong class_tag,
|
||||
if (!NSK_VERIFY(verify_tag(class_tag, *tag_ptr))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
}
|
||||
for(object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if(objects_info[object].fields[field].type == TYPE_STRING &&
|
||||
for (object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if (objects_info[object].fields[field].type == TYPE_STRING &&
|
||||
value_length == objects_info[object].fields[field].size) {
|
||||
int matched = 1;
|
||||
int i;
|
||||
wchar_t *str = (wchar_t*)objects_info[object].fields[field].value;
|
||||
for(i = 0; i < value_length && matched; i++) {
|
||||
for (i = 0; i < value_length && matched; i++) {
|
||||
matched = (str[i] == value[i]);
|
||||
}
|
||||
if(matched)
|
||||
if (matched)
|
||||
objects_info[object].fields[field].found++;
|
||||
}
|
||||
}
|
||||
@ -222,17 +222,17 @@ jint JNICALL array_callback(jlong class_tag,
|
||||
if (!NSK_VERIFY(verify_tag(class_tag, *tag_ptr))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
}
|
||||
for(object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if(objects_info[object].fields[field].type == TYPE_ARRAY &&
|
||||
for (object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
if (objects_info[object].fields[field].type == TYPE_ARRAY &&
|
||||
element_count == objects_info[object].fields[field].size) {
|
||||
int matched = 1;
|
||||
int i;
|
||||
for(i = 0; i < element_count && matched; i++) {
|
||||
for (i = 0; i < element_count && matched; i++) {
|
||||
matched = ((jint*)objects_info[object].fields[field].value)[i]==
|
||||
((jint*)elements)[i];
|
||||
}
|
||||
if(matched)
|
||||
if (matched)
|
||||
objects_info[object].fields[field].found++;
|
||||
}
|
||||
}
|
||||
@ -257,18 +257,18 @@ jint JNICALL heap_callback(jlong class_tag,
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
object_free_callback(jvmtiEnv* jvmti, jlong tag) {
|
||||
if(DECODE_TYPE(tag) == OBJECT_TAG) {
|
||||
if (DECODE_TYPE(tag) == OBJECT_TAG) {
|
||||
objects_info[DECODE_OBJECT(tag)].collected = 1;
|
||||
} else if(DECODE_TYPE(tag) == FIELD_TAG) {
|
||||
} else if (DECODE_TYPE(tag) == FIELD_TAG) {
|
||||
objects_info[DECODE_OBJECT(tag)].fields[DECODE_FIELD(tag)].collected = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//set expected fields value according to it's type
|
||||
void set_expected_value(field_info_t *field, int tagged, int is_static) {
|
||||
if(field->primitive) {
|
||||
if (field->primitive) {
|
||||
field->size = (int) sizeof(jint);
|
||||
if(is_static) {
|
||||
if (is_static) {
|
||||
field->value = (void*)(tagged ? &TAGGED_STATIC_INT_VALUE:
|
||||
&UNTAGGED_STATIC_INT_VALUE);
|
||||
} else {
|
||||
@ -299,18 +299,18 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
jobjectArray testObjects;
|
||||
int object;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (debugee = jni->FindClass(className))))
|
||||
if (!NSK_VERIFY(NULL != (debugee = jni->FindClass(className))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig))))
|
||||
if (!NSK_VERIFY(NULL != (testObjectsField = jni->GetStaticFieldID(debugee, fieldName, fieldSig))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (testObjects = (jobjectArray)(jni->GetStaticObjectField(
|
||||
if (!NSK_VERIFY(NULL != (testObjects = (jobjectArray)(jni->GetStaticObjectField(
|
||||
debugee, testObjectsField)))))
|
||||
return JNI_ERR;
|
||||
|
||||
// For each of test objects tag every field
|
||||
for(object = 0; object<TEST_OBJECTS_COUNT; object++) {
|
||||
for (object = 0; object<TEST_OBJECTS_COUNT; object++) {
|
||||
jobject target;
|
||||
jclass targetClass;
|
||||
jfieldID *targetFields;
|
||||
@ -318,58 +318,58 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
int tagged = object == 0;
|
||||
|
||||
memset(&objects_info[object],0,sizeof(object_info_t));
|
||||
if(!NSK_VERIFY(NULL != (target = jni->GetObjectArrayElement(testObjects, object))))
|
||||
if (!NSK_VERIFY(NULL != (target = jni->GetObjectArrayElement(testObjects, object))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_VERIFY(NULL != (targetClass = jni->GetObjectClass(target))))
|
||||
if (!NSK_VERIFY(NULL != (targetClass = jni->GetObjectClass(target))))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), NULL)))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(targetClass, &(objects_info[object].name), NULL)))
|
||||
return JNI_ERR;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetClassFields(
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetClassFields(
|
||||
targetClass, &(objects_info[object].fields_count), &targetFields)))
|
||||
return JNI_ERR;
|
||||
|
||||
objects_info[object].fields = (field_info_t*)calloc(objects_info[object].fields_count,sizeof(field_info_t));
|
||||
|
||||
// Iterate over fields, collect info about it and tag non primitive fields.
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
jint modifiers;
|
||||
int is_static = 0;
|
||||
int is_primitive = 0;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetFieldName(targetClass,
|
||||
targetFields[field],
|
||||
&objects_info[object].fields[field].name,
|
||||
&objects_info[object].fields[field].signature,
|
||||
NULL)))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetFieldName(targetClass,
|
||||
targetFields[field],
|
||||
&objects_info[object].fields[field].name,
|
||||
&objects_info[object].fields[field].signature,
|
||||
NULL)))
|
||||
return JNI_ERR;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers(
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers(
|
||||
targetClass, targetFields[field], &modifiers))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
is_static = (modifiers & STATIC_FIELD) == STATIC_FIELD;
|
||||
if(is_primitive_type(objects_info[object].fields[field].signature)) {
|
||||
if (is_primitive_type(objects_info[object].fields[field].signature)) {
|
||||
objects_info[object].fields[field].primitive = 1;
|
||||
is_primitive = 1;
|
||||
} else {
|
||||
jobject value;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers(
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetFieldModifiers(
|
||||
targetClass, targetFields[field], &modifiers))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
if(is_static) {
|
||||
if(!NSK_VERIFY(NULL != (value = jni->GetStaticObjectField(
|
||||
if (is_static) {
|
||||
if (!NSK_VERIFY(NULL != (value = jni->GetStaticObjectField(
|
||||
targetClass, targetFields[field])))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
} else {
|
||||
if(!NSK_VERIFY(NULL != (value = jni->GetObjectField(target, targetFields[field])))) {
|
||||
if (!NSK_VERIFY(NULL != (value = jni->GetObjectField(target, targetFields[field])))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
}
|
||||
if(tagged) {
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(value, ENCODE_TAG(FIELD_TAG,object,field)))) {
|
||||
if (tagged) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(value, ENCODE_TAG(FIELD_TAG,object,field)))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
}
|
||||
@ -384,10 +384,10 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
}
|
||||
|
||||
// tag class and it's instance to pass this tag into primitive field callback
|
||||
if(tagged) {
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(target, ENCODE_TAG(OBJECT_TAG,object,0))))
|
||||
if (tagged) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(target, ENCODE_TAG(OBJECT_TAG,object,0))))
|
||||
return JNI_ERR;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetTag(targetClass, ENCODE_TAG(CLASS_TAG,object,0))))
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetTag(targetClass, ENCODE_TAG(CLASS_TAG,object,0))))
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
@ -406,8 +406,8 @@ int tag_objects(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
void release_object_info(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
int object;
|
||||
int field;
|
||||
for(object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
for (object = 0; object < TEST_OBJECTS_COUNT; object++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].name);
|
||||
jvmti->Deallocate((unsigned char*)objects_info[object].fields[field].signature);
|
||||
}
|
||||
@ -420,18 +420,18 @@ void release_object_info(jvmtiEnv *jvmti, JNIEnv *jni) {
|
||||
void verify_objects(int reachable) {
|
||||
int object;
|
||||
int field;
|
||||
for(object = 0; object < (reachable?TEST_OBJECTS_COUNT:TAGGED_OBJECTS); object++) {
|
||||
for(field = 0; field < objects_info[object].fields_count; field++) {
|
||||
for (object = 0; object < (reachable?TEST_OBJECTS_COUNT:TAGGED_OBJECTS); object++) {
|
||||
for (field = 0; field < objects_info[object].fields_count; field++) {
|
||||
// If primitive field of object that was not collected or
|
||||
// non primitive field that was not collected was not found
|
||||
// expected amount of times, than test failed.
|
||||
if((objects_info[object].fields[field].primitive &&
|
||||
!objects_info[object].collected)
|
||||
||
|
||||
(!objects_info[object].fields[field].primitive &&
|
||||
!objects_info[object].fields[field].collected)) {
|
||||
if(objects_info[object].fields[field].expected !=
|
||||
objects_info[object].fields[field].found) {
|
||||
if ((objects_info[object].fields[field].primitive &&
|
||||
!objects_info[object].collected)
|
||||
||
|
||||
(!objects_info[object].fields[field].primitive &&
|
||||
!objects_info[object].fields[field].collected)) {
|
||||
if (objects_info[object].fields[field].expected !=
|
||||
objects_info[object].fields[field].found) {
|
||||
NSK_COMPLAIN4("Field %s::%s expected to be found %d times, "
|
||||
"but it was found %d times.\n",
|
||||
objects_info[object].name,
|
||||
@ -453,15 +453,15 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
jvmtiEventCallbacks event_callbacks;
|
||||
|
||||
NSK_DISPLAY0("Waiting debugee.\n");
|
||||
if(!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
return;
|
||||
}
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY0("Tagging fields.\n");
|
||||
if(!NSK_VERIFY(JNI_OK==tag_objects(jvmti, jni))) {
|
||||
if (!NSK_VERIFY(JNI_OK==tag_objects(jvmti, jni))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -472,7 +472,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
primitive_callbacks.heap_iteration_callback = &heap_callback;
|
||||
|
||||
NSK_DISPLAY0("Iterating over reachable objects.\n");
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, NULL, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, NULL, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
@ -480,16 +480,16 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
NSK_DISPLAY0("Verifying that all fields were found.\n");
|
||||
verify_objects(1);
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync())) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSK_DISPLAY0("Iterating over unreachable objects.\n");
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, NULL, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(filter_type, NULL, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
@ -502,13 +502,13 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
* since it will free some memory that the callback will access.
|
||||
*/
|
||||
memset(&event_callbacks, 0, sizeof(jvmtiEventCallbacks));
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
release_object_info(jvmti, jni);
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -537,14 +537,14 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
nsk_jvmti_parseOptions(options);
|
||||
|
||||
type = nsk_jvmti_findOptionValue("filter");
|
||||
if(type != NULL) {
|
||||
if(0 == strcmp(type, "JVMTI_HEAP_FILTER_TAGGED")) {
|
||||
if (type != NULL) {
|
||||
if (0 == strcmp(type, "JVMTI_HEAP_FILTER_TAGGED")) {
|
||||
filter_type = JVMTI_HEAP_FILTER_TAGGED;
|
||||
} else if(0 == strcmp(type, "JVMTI_HEAP_FILTER_UNTAGGED")) {
|
||||
} else if (0 == strcmp(type, "JVMTI_HEAP_FILTER_UNTAGGED")) {
|
||||
filter_type = JVMTI_HEAP_FILTER_UNTAGGED;
|
||||
} else if(0 == strcmp(type, "JVMTI_HEAP_FILTER_CLASS_TAGGED")) {
|
||||
} else if (0 == strcmp(type, "JVMTI_HEAP_FILTER_CLASS_TAGGED")) {
|
||||
filter_type = JVMTI_HEAP_FILTER_CLASS_TAGGED;
|
||||
} else if(0 == strcmp(type, "JVMTI_HEAP_FILTER_CLASS_UNTAGGED")) {
|
||||
} else if (0 == strcmp(type, "JVMTI_HEAP_FILTER_CLASS_UNTAGGED")) {
|
||||
filter_type = JVMTI_HEAP_FILTER_CLASS_UNTAGGED;
|
||||
} else {
|
||||
NSK_COMPLAIN1("unknown filter value '%s'.\n",type);
|
||||
@ -561,13 +561,13 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&event_callbacks, 0, sizeof(jvmtiEventCallbacks));
|
||||
event_callbacks.ObjectFree = &object_free_callback;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
jvmtiPrimitiveType value_type,
|
||||
void* user_data) {
|
||||
//nothing should be reported in ZERO_INVOCATIONS_PHASE
|
||||
if(phase == ZERO_INVOCATIONS_PHASE) {
|
||||
if (phase == ZERO_INVOCATIONS_PHASE) {
|
||||
NSK_COMPLAIN2("jvmtiPrimitiveFieldCallback was invoked for a field with "
|
||||
"class tag 0x%lX and object tag 0x%lX during iteration with "
|
||||
"interface or abstract class as a filter.\n",
|
||||
@ -70,10 +70,10 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
nsk_jvmti_setFailStatus();
|
||||
} else {
|
||||
int i;
|
||||
if(value_type != JVMTI_PRIMITIVE_TYPE_LONG)
|
||||
if (value_type != JVMTI_PRIMITIVE_TYPE_LONG)
|
||||
return 0;
|
||||
|
||||
if(IS_FIELD_UNEXPECTED(value.j)) {
|
||||
if (IS_FIELD_UNEXPECTED(value.j)) {
|
||||
NSK_COMPLAIN3("Unexpected value 0x%lX was repotrted by "
|
||||
"jvmtiPrimitiveFieldCallback for an object with "
|
||||
"class tag 0x%lX and object tag 0x%lX.\n",
|
||||
@ -83,8 +83,8 @@ jint JNICALL field_callback(jvmtiHeapReferenceKind kind,
|
||||
}
|
||||
|
||||
//find reported field in expected values
|
||||
for(i = 0; i < EXPECTED_PRIMITIVES; i++) {
|
||||
if(expected_values[i] == value.j)
|
||||
for (i = 0; i < EXPECTED_PRIMITIVES; i++) {
|
||||
if (expected_values[i] == value.j)
|
||||
occurancies[i]++;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ jint JNICALL heap_callback(jlong class_tag,
|
||||
jint length,
|
||||
void* user_data) {
|
||||
//nothing should be reported in ZERO_INVOCATIONS_PHASE
|
||||
if(phase == ZERO_INVOCATIONS_PHASE) {
|
||||
if (phase == ZERO_INVOCATIONS_PHASE) {
|
||||
NSK_COMPLAIN2("jvmtiHeapIterationCallback was invoked for an object with "
|
||||
"class tag 0x%lX and object tag 0x%lX during iteration with "
|
||||
"interface or abstract class as a klass-filter.\n",
|
||||
@ -141,10 +141,10 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
int i;
|
||||
|
||||
NSK_DISPLAY0("Waiting debugee.\n");
|
||||
if(!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_enableEvents(JVMTI_ENABLE, 1, &event, NULL))) {
|
||||
return;
|
||||
}
|
||||
if(!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -155,14 +155,14 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
primitive_callbacks.heap_iteration_callback = &heap_callback;
|
||||
|
||||
phase = ZERO_INVOCATIONS_PHASE;
|
||||
for(i = 0; i < FILTER_COUNT; i++) {
|
||||
if(!NSK_VERIFY(NULL != (klass = jni->FindClass(types[i])))) {
|
||||
for (i = 0; i < FILTER_COUNT; i++) {
|
||||
if (!NSK_VERIFY(NULL != (klass = jni->FindClass(types[i])))) {
|
||||
NSK_COMPLAIN1("Can't find class %s.\n",types[i]);
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
NSK_DISPLAY1("Iterating through heap with klass-filter '%s'.\n",types[i]);
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
@ -170,17 +170,17 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
|
||||
phase = STATIC_FIELDS_FINDING_PHASE;
|
||||
NSK_DISPLAY0("Iterating through heap with klass-filter 'java/lang/Class'.\n");
|
||||
if(!NSK_VERIFY(NULL != (klass = jni->FindClass("java/lang/Class")))) {
|
||||
if (!NSK_VERIFY(NULL != (klass = jni->FindClass("java/lang/Class")))) {
|
||||
NSK_COMPLAIN0("Can't find class java/lang/Class.\n");
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->IterateThroughHeap(0, klass, &primitive_callbacks, NULL))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
return;
|
||||
}
|
||||
for(i = 0; i < EXPECTED_PRIMITIVES; i++) {
|
||||
if(occurancies[i] != EXPECTED_OCCURANCE_COUNT) {
|
||||
for (i = 0; i < EXPECTED_PRIMITIVES; i++) {
|
||||
if (occurancies[i] != EXPECTED_OCCURANCE_COUNT) {
|
||||
NSK_COMPLAIN3("Primitive static field with value 0x%lX was reported "
|
||||
"%d times while expected to be reported %d times.\n",
|
||||
expected_values[i], occurancies[i], EXPECTED_OCCURANCE_COUNT);
|
||||
@ -188,7 +188,7 @@ agent(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
|
||||
return;
|
||||
}
|
||||
|
||||
@ -221,12 +221,12 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
|
||||
caps.can_tag_objects = 1;
|
||||
caps.can_generate_object_free_events = 1;
|
||||
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
memset(&event_callbacks, 0, sizeof(jvmtiEventCallbacks));
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&event_callbacks, sizeof(jvmtiEventCallbacks)))) {
|
||||
return JNI_ERR;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ Java_nsk_jvmti_PopFrame_popframe002_doPopFrame(JNIEnv *env,
|
||||
tot_result = STATUS_FAILED;
|
||||
}
|
||||
|
||||
switch(t_case) {
|
||||
switch (t_case) {
|
||||
/* NULL pointer to the thread in debug mode */
|
||||
case 1:
|
||||
printf("\nInvoke PopFrame() with NULL pointer to a thread...\n");
|
||||
|
@ -124,7 +124,7 @@ MethodExit(
|
||||
, entry_name
|
||||
, entry_sig
|
||||
);
|
||||
} while(0);
|
||||
} while (0);
|
||||
|
||||
if (failure) {
|
||||
NSK_COMPLAIN1("#### MethodExit event occurred (tid: %d) ####\n"
|
||||
|
@ -110,7 +110,7 @@ Java_nsk_jvmti_PopFrame_popframe011_doPopFrame(JNIEnv *env,
|
||||
return STATUS_FAILED;
|
||||
}
|
||||
|
||||
switch(t_case) {
|
||||
switch (t_case) {
|
||||
/* NULL pointer to the thread in debug mode */
|
||||
case 1:
|
||||
printf("\nInvoke PopFrame() with NULL pointer to a thread...\n");
|
||||
|
@ -100,7 +100,7 @@ Java_nsk_jvmti_RedefineClasses_redefclass006_makeRedefinition(JNIEnv *env,
|
||||
return PASSED;
|
||||
}
|
||||
|
||||
switch(t_case) {
|
||||
switch (t_case) {
|
||||
/* NULL pointer to the jvmtiClassDefinition */
|
||||
case 0:
|
||||
break;
|
||||
|
@ -179,7 +179,7 @@ agentProc(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) {
|
||||
nsk_jvmti_resumeSync();
|
||||
exit(95 + PASSED);
|
||||
}
|
||||
} while(fire == 0);
|
||||
} while (fire == 0);
|
||||
|
||||
NSK_DISPLAY0("agentProc: hotspot method compiled\n\n");
|
||||
|
||||
|
@ -178,7 +178,7 @@ agentProc(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) {
|
||||
nsk_jvmti_resumeSync();
|
||||
exit(95 + PASSED);
|
||||
}
|
||||
} while(fire == 0);
|
||||
} while (fire == 0);
|
||||
|
||||
NSK_DISPLAY0("agentProc: hotspot method compiled\n\n");
|
||||
|
||||
|
@ -179,7 +179,7 @@ agentProc(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) {
|
||||
nsk_jvmti_resumeSync();
|
||||
exit(95 + PASSED);
|
||||
}
|
||||
} while(fire == 0);
|
||||
} while (fire == 0);
|
||||
|
||||
NSK_DISPLAY0("agentProc: hotspot method compiled\n\n");
|
||||
|
||||
|
@ -157,7 +157,7 @@ jint Agent_Initialize(JavaVM *vm, char *options, void *reserved)
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
|
||||
return JNI_ERR;
|
||||
|
||||
if(nsk_jvmti_findOptionIntValue("can_retransform_classes", 1)) {
|
||||
if (nsk_jvmti_findOptionIntValue("can_retransform_classes", 1)) {
|
||||
caps.can_retransform_classes = 1;
|
||||
} else {
|
||||
caps.can_retransform_classes = 0;
|
||||
|
@ -287,7 +287,7 @@ void startThreads() {
|
||||
i+1);
|
||||
result = STATUS_FAILED;
|
||||
}
|
||||
} while(thrStarted[i] != 1);
|
||||
} while (thrStarted[i] != 1);
|
||||
if (verbose)
|
||||
printf("\nthe waiting thread #%d started\n",
|
||||
i+1);
|
||||
|
@ -121,7 +121,7 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object,
|
||||
nsk_jvmti_setFailStatus();
|
||||
NSK_COMPLAIN1("VMObjectAlloc: event's thread was found in the list of live threads: %s\n\n", threadInfo.name);
|
||||
}
|
||||
} while(0);
|
||||
} while (0);
|
||||
|
||||
|
||||
/* Check that object_klass is loaded class
|
||||
@ -143,7 +143,7 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object,
|
||||
|
||||
if (classes != NULL)
|
||||
jvmti->Deallocate((unsigned char*)classes);
|
||||
} while(0);
|
||||
} while (0);
|
||||
|
||||
|
||||
/* Check for object_klass
|
||||
@ -172,7 +172,7 @@ VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object,
|
||||
NSK_COMPLAIN2("VMObjectAlloc: inconsistent object size data\n\t"
|
||||
" size passed in to callback: %d\n\t size returned by GetObjectSize: %d\n\n", (long)size, (long)objSize);
|
||||
}
|
||||
} while(0);
|
||||
} while (0);
|
||||
|
||||
if (signature != NULL)
|
||||
jvmti->Deallocate((unsigned char*)signature);
|
||||
|
@ -71,7 +71,7 @@ JNIEXPORT void JNICALL doRedefineInNativeThread(jvmtiEnv * jvmti,
|
||||
nsk_printf("doRedefineInNativeThread\n");
|
||||
cla = jni->FindClass(SEARCH_NAME);
|
||||
nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char));
|
||||
for(i = 0; i < 30; i++) {
|
||||
for (i = 0; i < 30; i++) {
|
||||
nsk_printf(" Inside the redefine method..\n");
|
||||
if (nsk_jvmti_redefineClass(jvmti, cla,fileName) == NSK_TRUE) {
|
||||
nsk_printf("\nMyClass :: Successfully redefined..\n");
|
||||
|
@ -48,7 +48,7 @@ JNIEXPORT jint JNI_OnLoad_hs104t002(JavaVM *jvm, char *options, void *reserved)
|
||||
return JNI_VERSION_1_8;
|
||||
}
|
||||
#endif
|
||||
jint Agent_Initialize(JavaVM *vm, char *options, void *reserved){
|
||||
jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) {
|
||||
if (!NSK_VERIFY (JNI_OK == vm->GetEnv((void **)&jvmti, JVMTI_VERSION_1_1))) {
|
||||
nsk_printf("#error Agent :: Could not load JVMTI interface.\n");
|
||||
return JNI_ERR;
|
||||
|
@ -98,7 +98,7 @@ void JNICALL callbackSingleStep(jvmtiEnv *jvmti,
|
||||
nsk_printf(" %d..",redefineNumber);
|
||||
nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName, sizeof(fileName)/sizeof(char));
|
||||
|
||||
if(nsk_jvmti_redefineClass(jvmti, threadClass,fileName) == NSK_TRUE) {
|
||||
if (nsk_jvmti_redefineClass(jvmti, threadClass,fileName) == NSK_TRUE) {
|
||||
nsk_printf("Agent:: Redefined..\n");
|
||||
} else {
|
||||
nsk_printf(" Failed to redefine..\n");
|
||||
|
@ -51,7 +51,7 @@ static jint newClassSize;
|
||||
char *getClassName(jvmtiEnv *jvmti, jclass klass) {
|
||||
char * className;
|
||||
char * generic;
|
||||
if(!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &className, &generic))) {
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(klass, &className, &generic))) {
|
||||
nsk_jvmti_setFailStatus();
|
||||
}
|
||||
return className;
|
||||
@ -64,7 +64,7 @@ callbackClassLoad(jvmtiEnv *jvmti_env,
|
||||
jclass klass) {
|
||||
char * name;
|
||||
name = getClassName(jvmti_env,klass);
|
||||
if((strcmp(name,CLASS_NAME) == 0) && (redefineNumber== 1)) {
|
||||
if ((strcmp(name,CLASS_NAME) == 0) && (redefineNumber== 1)) {
|
||||
char fileName[512];
|
||||
nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
|
||||
sizeof(fileName)/sizeof(char));
|
||||
@ -100,7 +100,7 @@ callbackClassPrepare(jvmtiEnv *jvmti_env,
|
||||
} else {
|
||||
NSK_COMPLAIN0("\nMyClass :: Failed to redefine ..\n");
|
||||
}
|
||||
if((myTestClass = (jclass) jni_env->NewGlobalRef(klass)) == NULL) {
|
||||
if ((myTestClass = (jclass) jni_env->NewGlobalRef(klass)) == NULL) {
|
||||
NSK_COMPLAIN0("Failed to create global ref...");
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ callbackClassPrepare(jvmtiEnv *jvmti,
|
||||
redefineNumber=0;
|
||||
jvmti->GetClassSignature(klass, &className, &generic);
|
||||
/* printf("Agent::Class Name %s \n",className); */
|
||||
if((strcmp(className, CLASS_NAME) == 0)) {
|
||||
if ((strcmp(className, CLASS_NAME) == 0)) {
|
||||
jclass cls;
|
||||
cls = jni->FindClass(SEARCH_NAME);
|
||||
if (cls == NULL) {
|
||||
|
@ -55,7 +55,7 @@ JNIEXPORT void JNICALL callbackClassPrepare(jvmtiEnv *jvmti_env,
|
||||
NSK_DISPLAY0(" Agent :: Failed get class signature.\n");
|
||||
nsk_jvmti_agentFailed();
|
||||
} else {
|
||||
if((strcmp(className, CLASS_NAME) == 0)) {
|
||||
if ((strcmp(className, CLASS_NAME) == 0)) {
|
||||
jfieldID fieldId;
|
||||
if (!NSK_JNI_VERIFY(jni, (fieldId = jni->GetStaticFieldID(klass, FIELDNAME, TYPE)) != NULL)) {
|
||||
NSK_DISPLAY0(" Agent :: Failed to get FieldId.\n");
|
||||
@ -114,7 +114,7 @@ JNIEXPORT void JNICALL callbackFieldAccess(jvmtiEnv *jvmti_env,
|
||||
NSK_DISPLAY0(" Agent :: Failed get class signature.\n");
|
||||
nsk_jvmti_agentFailed();
|
||||
} else {
|
||||
if((strcmp(className, CLASS_NAME) == 0)) {
|
||||
if ((strcmp(className, CLASS_NAME) == 0)) {
|
||||
jvmtiThreadInfo info;
|
||||
nsk_jvmti_getFileName(redefineNumber, FILE_NAME, fileName,
|
||||
sizeof(fileName)/sizeof(char));
|
||||
|
@ -145,7 +145,7 @@ void doRedirect(JNIEnv *env, jclass cls) {
|
||||
env->FatalError("cannot get field ID");
|
||||
}
|
||||
|
||||
switch(i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
if (verbose)
|
||||
printf("\ndoRedirect: overwriting the function CallStaticDoubleMethodV ...\n");
|
||||
@ -199,7 +199,7 @@ void doCall(JNIEnv *env, jobject obj, jclass objCls, const char *msg) {
|
||||
if (verbose)
|
||||
printf("\ndoCall: calling %s JNI method for \"%s %s\"...\n",
|
||||
msg, meth_info[i].m_name, meth_info[i].m_sign);
|
||||
switch(i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
dVal = env->CallStaticDoubleMethod(objCls, meth_info[i].mid, 73);
|
||||
break;
|
||||
|
@ -186,7 +186,7 @@ static int initAgent(int indx) {
|
||||
NSK_DISPLAY1("\nagent %s initializer: the JVMTI env obtained\n\tsetting event callbacks ...\n",
|
||||
(indx==0)?"A":"B");
|
||||
(void) memset(&callbacks, 0, sizeof(callbacks));
|
||||
switch(indx) {
|
||||
switch (indx) {
|
||||
case 0:
|
||||
callbacks.VMInit = &VMInitA;
|
||||
break;
|
||||
@ -240,7 +240,7 @@ static void startAgent(int indx) {
|
||||
(indx==0)?"A":"B", TRIES);
|
||||
exit(STATUS_FAILED);
|
||||
}
|
||||
} while(thrstarted[indx] != 1);
|
||||
} while (thrstarted[indx] != 1);
|
||||
|
||||
NSK_DISPLAY1("\nstartAgent: the agent %s thread started\n",
|
||||
(indx==0)?"A":"B");
|
||||
@ -288,7 +288,7 @@ static int agentA(void *context) {
|
||||
TRIES);
|
||||
exit(STATUS_FAILED);
|
||||
}
|
||||
} while(redir[1] != 1);
|
||||
} while (redir[1] != 1);
|
||||
|
||||
/* check the interception set in another JVMTI env */
|
||||
NSK_DISPLAY0("\n>>> TEST CASE #4) First JVMTI env: checking the redirection set in second JVMTI env ...\n");
|
||||
@ -335,7 +335,7 @@ static int agentB(void *context) {
|
||||
TRIES);
|
||||
exit(STATUS_FAILED);
|
||||
}
|
||||
} while(redir[0] != 1);
|
||||
} while (redir[0] != 1);
|
||||
|
||||
/* check the interception set in another JVMTI env */
|
||||
NSK_DISPLAY0("\n>>> TEST CASE #2) Second JVMTI env: checking the redirection set in first JVMTI env ...\n");
|
||||
|
@ -252,7 +252,7 @@ static int ownerThread(void *context) {
|
||||
TRIES);
|
||||
env->FatalError("ownerThread: time exceed");
|
||||
}
|
||||
} while(releaseMon != 1);
|
||||
} while (releaseMon != 1);
|
||||
|
||||
if (exitMonitor(env, "ownerThread") == STATUS_FAILED)
|
||||
THREAD_return(STATUS_FAILED);
|
||||
@ -344,7 +344,7 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj
|
||||
TRIES);
|
||||
env->FatalError(" the monitor is still not entered by the owner thread");
|
||||
}
|
||||
} while(monEntered != 1);
|
||||
} while (monEntered != 1);
|
||||
|
||||
for (i=0; i<MAX_THREADS-1; i++) {
|
||||
NSK_DISPLAY1("starting waiting thread #%d ...\n",
|
||||
@ -368,7 +368,7 @@ Java_nsk_jvmti_scenarios_jni_1interception_JI06_ji06t001_check(JNIEnv *env, jobj
|
||||
i+1);
|
||||
exit(STATUS_FAILED);
|
||||
}
|
||||
} while(thrStarted[i] != 1);
|
||||
} while (thrStarted[i] != 1);
|
||||
NSK_DISPLAY1("the waiting thread #%d started\n",
|
||||
i+1);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
|
||||
if (signature != NULL)
|
||||
jvmti_env->Deallocate((unsigned char*)signature);
|
||||
|
||||
switch(BreakpointEventsCount) {
|
||||
switch (BreakpointEventsCount) {
|
||||
case 1:
|
||||
NSK_DISPLAY0("Testcase #1: FramePop in both agents\n");
|
||||
break;
|
||||
|
@ -69,7 +69,7 @@ MethodEntry(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
|
||||
if (signature != NULL)
|
||||
jvmti_env->Deallocate((unsigned char*)signature);
|
||||
|
||||
switch(MethodEntryEventsCount) {
|
||||
switch (MethodEntryEventsCount) {
|
||||
case 1:
|
||||
NSK_DISPLAY0("Testcase #1: FramePop in both agents\n");
|
||||
if (!NSK_JVMTI_VERIFY(jvmti_env->NotifyFramePop(thread, 0)))
|
||||
@ -115,7 +115,7 @@ FramePop(jvmtiEnv *jvmti_env, JNIEnv *jni_env,
|
||||
if (signature != NULL)
|
||||
jvmti_env->Deallocate((unsigned char*)signature);
|
||||
|
||||
switch(MethodEntryEventsCount) {
|
||||
switch (MethodEntryEventsCount) {
|
||||
case 1:
|
||||
/* It's ok */
|
||||
break;
|
||||
|
@ -178,7 +178,7 @@ Java_nsk_jvmti_unit_timers_JvmtiTest_RegisterCompletedThread(JNIEnv * env,
|
||||
static void print_timerinfo(jvmtiTimerInfo* timerInfo) {
|
||||
char buffer[32];
|
||||
const char* timerKind;
|
||||
switch(timerInfo->kind) {
|
||||
switch (timerInfo->kind) {
|
||||
case JVMTI_TIMER_USER_CPU:
|
||||
timerKind = "JVMTI_TIMER_USER_CPU";
|
||||
break;
|
||||
|
@ -441,7 +441,7 @@ extern "C" {
|
||||
// while (!threadsGroupLocks.runnableCanExit.get()) {
|
||||
// Thread.yield();
|
||||
// }
|
||||
while(flag==JNI_FALSE)
|
||||
while (flag==JNI_FALSE)
|
||||
{
|
||||
GET_BOOL_FIELD(flag, threadsGroupLocks, ThreadsGroupLocks, "runnableCanExit");
|
||||
CALL_STATIC_VOID_NOPARAM(Thread, "yield");
|
||||
@ -476,7 +476,7 @@ extern "C" {
|
||||
*/
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_nsk_monitoring_share_ThreadController_getThreadState(JNIEnv *env,
|
||||
jobject obj, jobject thread){
|
||||
jobject obj, jobject thread) {
|
||||
|
||||
JavaVM *vm;
|
||||
jvmtiEnv *jvmti;
|
||||
@ -486,18 +486,18 @@ extern "C" {
|
||||
jstring stateName;
|
||||
jint state;
|
||||
|
||||
if(!NSK_VERIFY(
|
||||
if (!NSK_VERIFY(
|
||||
env->GetJavaVM(&vm) == 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!NSK_VERIFY(
|
||||
if (!NSK_VERIFY(
|
||||
vm->GetEnv((void **)&jvmti, JVMTI_VERSION_1)
|
||||
== JNI_OK)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!NSK_VERIFY(
|
||||
if (!NSK_VERIFY(
|
||||
jvmti->GetThreadState((jthread)thread, &state)
|
||||
== JVMTI_ERROR_NONE)) {
|
||||
return NULL;
|
||||
|
@ -627,7 +627,7 @@ static void deallocClsInfo(JNIEnv *jni_env) {
|
||||
|
||||
NSK_TRACE(jni_env->DeleteGlobalRef(rasCls));
|
||||
|
||||
while(clsInfoCurr != NULL) {
|
||||
while (clsInfoCurr != NULL) {
|
||||
class_info *_clsInfo = clsInfoCurr;
|
||||
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*) clsInfoCurr->clazzsig)))
|
||||
@ -659,7 +659,7 @@ static int findAndHotSwap(JNIEnv *jni_env, jclass clazz) {
|
||||
lock(jni_env);
|
||||
display(0, "#### JVMTIagent: findAndHotSwap: >>>>>>>> entered the raw monitor \"eventLock\" ####\n");
|
||||
|
||||
while(clsInfoCurr != NULL) {
|
||||
while (clsInfoCurr != NULL) {
|
||||
if (hotswap == HOTSWAP_EVERY_METHOD_ENTRY_FOR_EVERY_CLASS ||
|
||||
hotswap == HOTSWAP_EVERY_EXCEPTION_FOR_EVERY_CLASS) {
|
||||
display(1, "\n#### JVMTIagent: findAndHotSwap: going to hotswap tested class \"%s\" during execution of class \"%s\" ...\n",
|
||||
|
@ -148,7 +148,7 @@ const char* nsk_aod_getOptionValue(Options* options, const char* option) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(i = 0; i < options->size; i++) {
|
||||
for (i = 0; i < options->size; i++) {
|
||||
if (strcmp(option, options->names[i]) == 0) {
|
||||
return options->values[i];
|
||||
}
|
||||
@ -167,7 +167,7 @@ int nsk_aod_optionSpecified(Options* options, const char* option) {
|
||||
return NSK_FALSE;
|
||||
}
|
||||
|
||||
for(i = 0; i < options->size; i++) {
|
||||
for (i = 0; i < options->size; i++) {
|
||||
if (strcmp(option, options->names[i]) == 0) {
|
||||
return NSK_TRUE;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ Java_nsk_share_jdi_MonitorEnterExecutor_nativeJNIMonitorEnter(JNIEnv *env, jobje
|
||||
|
||||
success = env->MonitorEnter(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
@ -44,7 +44,7 @@ Java_nsk_share_jdi_MonitorEnterExecutor_nativeJNIMonitorEnter(JNIEnv *env, jobje
|
||||
|
||||
success = env->MonitorExit(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
|
||||
|
||||
@ -61,7 +61,7 @@ Java_nsk_share_jdi_MonitorEnterExecutor_11Subclass_nativeJNIMonitorEnter(JNIEnv
|
||||
|
||||
success = env->MonitorEnter(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
@ -72,7 +72,7 @@ Java_nsk_share_jdi_MonitorEnterExecutor_11Subclass_nativeJNIMonitorEnter(JNIEnv
|
||||
|
||||
success = env->MonitorExit(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
|
||||
|
||||
@ -89,7 +89,7 @@ Java_nsk_share_jdi_MonitorEnterExecutor_12Subclass_nativeJNIMonitorEnter(JNIEnv
|
||||
|
||||
success = env->MonitorEnter(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
@ -100,7 +100,7 @@ Java_nsk_share_jdi_MonitorEnterExecutor_12Subclass_nativeJNIMonitorEnter(JNIEnv
|
||||
|
||||
success = env->MonitorExit(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
|
||||
|
||||
|
@ -37,31 +37,31 @@ Java_nsk_share_ReferringObject_createJNIGlobalReferenceNative(JNIEnv *env,
|
||||
jint i;
|
||||
jint result = -1;
|
||||
|
||||
if(globalReferences == NULL)
|
||||
if (globalReferences == NULL)
|
||||
{
|
||||
globalReferences = (jobject*)malloc(sizeof(jobject) * maxJNIGlobalReferences);
|
||||
|
||||
if(globalReferences == NULL)
|
||||
if (globalReferences == NULL)
|
||||
{
|
||||
NSK_COMPLAIN0("malloc return NULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < maxJNIGlobalReferences; i++)
|
||||
for (i = 0; i < maxJNIGlobalReferences; i++)
|
||||
{
|
||||
globalReferences[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < maxJNIGlobalReferences; i++)
|
||||
for (i = 0; i < maxJNIGlobalReferences; i++)
|
||||
{
|
||||
jobject reference = globalReferences[i];
|
||||
|
||||
if(reference == NULL)
|
||||
if (reference == NULL)
|
||||
{
|
||||
reference = env->NewGlobalRef(object);
|
||||
|
||||
if(reference == NULL)
|
||||
if (reference == NULL)
|
||||
{
|
||||
NSK_COMPLAIN0("NewGlobalRef return NULL\n");
|
||||
|
||||
@ -87,7 +87,7 @@ Java_nsk_share_ReferringObject_deleteJNIGlobalReferenceNative(JNIEnv *env,
|
||||
{
|
||||
jobject reference = globalReferences[index];
|
||||
|
||||
if(reference == NULL)
|
||||
if (reference == NULL)
|
||||
{
|
||||
NSK_COMPLAIN1("globalReferences[%d] = NULL, possible wrong index is passed\n", index);
|
||||
|
||||
@ -109,7 +109,7 @@ Java_nsk_share_ReferringObject_createJNILocalReferenceNative(JNIEnv *env,
|
||||
jobject reference = env->NewLocalRef(object);
|
||||
jclass klass;
|
||||
|
||||
if(reference == NULL)
|
||||
if (reference == NULL)
|
||||
{
|
||||
NSK_COMPLAIN0("NewLocalRef return NULL\n");
|
||||
|
||||
@ -136,32 +136,32 @@ Java_nsk_share_ReferringObject_createJNIWeakReferenceNative(JNIEnv *env,
|
||||
jint i;
|
||||
jint result = -1;
|
||||
|
||||
if(weakReferences == NULL)
|
||||
if (weakReferences == NULL)
|
||||
{
|
||||
weakReferences = (jweak*)malloc(sizeof(jweak) * maxJNIWeakReferences);
|
||||
|
||||
if(weakReferences == NULL)
|
||||
if (weakReferences == NULL)
|
||||
{
|
||||
NSK_COMPLAIN0("malloc return NULL\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < maxJNIWeakReferences; i++)
|
||||
for (i = 0; i < maxJNIWeakReferences; i++)
|
||||
{
|
||||
weakReferences[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < maxJNIWeakReferences; i++)
|
||||
for (i = 0; i < maxJNIWeakReferences; i++)
|
||||
{
|
||||
jobject reference = weakReferences[i];
|
||||
|
||||
if(reference == NULL)
|
||||
if (reference == NULL)
|
||||
{
|
||||
reference = env->NewWeakGlobalRef(object);
|
||||
|
||||
if(reference == NULL)
|
||||
if (reference == NULL)
|
||||
{
|
||||
NSK_COMPLAIN0("NewWeakGlobalRef return NULL\n");
|
||||
|
||||
@ -187,7 +187,7 @@ Java_nsk_share_ReferringObject_deleteJNIWeakReferenceNative(JNIEnv *env,
|
||||
{
|
||||
jweak reference = weakReferences[index];
|
||||
|
||||
if(reference == NULL)
|
||||
if (reference == NULL)
|
||||
{
|
||||
NSK_COMPLAIN1("weakReferences[%d] = NULL, possible wrong index is passed\n", index);
|
||||
|
||||
@ -196,7 +196,7 @@ Java_nsk_share_ReferringObject_deleteJNIWeakReferenceNative(JNIEnv *env,
|
||||
"Requested weakReferences[] element is NULL, possible wrong index is passed");
|
||||
}
|
||||
|
||||
if(env->IsSameObject(reference, NULL) == JNI_TRUE)
|
||||
if (env->IsSameObject(reference, NULL) == JNI_TRUE)
|
||||
{
|
||||
NSK_COMPLAIN0("TEST BUG: Weak reference was collected\n");
|
||||
|
||||
|
@ -377,7 +377,7 @@ extern "C" {
|
||||
static u2 calculateOffsetDelta(u2 frameNumber, u2 frameOffsetDelta) {
|
||||
u2 oldOffset;
|
||||
u2 newOffset;
|
||||
if(frameNumber == 0) {
|
||||
if (frameNumber == 0) {
|
||||
stackFrameOffset = frameOffsetDelta;
|
||||
return (u2) map[stackFrameOffset];
|
||||
} else {
|
||||
@ -392,10 +392,10 @@ extern "C" {
|
||||
u2 i;
|
||||
u2 offset;
|
||||
u1 tag;
|
||||
for(i=0; i<count; i++) {
|
||||
for (i=0; i<count; i++) {
|
||||
tag = get_u1();
|
||||
put_u1(tag);
|
||||
if(tag == ITEM_Object) {
|
||||
if (tag == ITEM_Object) {
|
||||
copy_u2();
|
||||
} else if (tag == ITEM_Uninitialized) {
|
||||
copy_u2();
|
||||
@ -421,10 +421,10 @@ extern "C" {
|
||||
|
||||
|
||||
|
||||
for(i=0; i<number_of_entries; i++) {
|
||||
for (i=0; i<number_of_entries; i++) {
|
||||
frame_type = get_u1();
|
||||
|
||||
if(frame_type <= SAME_END) {
|
||||
if (frame_type <= SAME_END) {
|
||||
// same_frame {
|
||||
// u1 frame_type = SAME; /* 0-63 */
|
||||
// }
|
||||
@ -432,7 +432,7 @@ extern "C" {
|
||||
put_u1(SAME_FRAME_EXTENDED);
|
||||
put_u2(calculateOffsetDelta(i, (u2) frame_type));
|
||||
|
||||
} else if((frame_type >= SAME_LOCALS_1_STACK_ITEM_BEGIN) && (frame_type<=SAME_LOCALS_1_STACK_ITEM_END)) {
|
||||
} else if ((frame_type >= SAME_LOCALS_1_STACK_ITEM_BEGIN) && (frame_type<=SAME_LOCALS_1_STACK_ITEM_END)) {
|
||||
// same_locals_1_stack_item_frame {
|
||||
// u1 frame_type = SAME_LOCALS_1_STACK_ITEM;/* 64-127 */
|
||||
// verification_type_info stack[1];
|
||||
@ -443,7 +443,7 @@ extern "C" {
|
||||
copyVerificationTypeInfo(1);
|
||||
|
||||
// Tags in the range [128-246] are reserved for future use.
|
||||
} else if(frame_type == SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
|
||||
} else if (frame_type == SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
|
||||
// same_locals_1_stack_item_frame_extended {
|
||||
// u1 frame_type = SAME_LOCALS_1_STACK_ITEM_EXTENDED; /* 247 */
|
||||
// u2 offset_delta;
|
||||
@ -455,7 +455,7 @@ extern "C" {
|
||||
put_u2(calculateOffsetDelta(i, frameOffsetDelta));
|
||||
copyVerificationTypeInfo(1);
|
||||
|
||||
} else if((frame_type >= CHOP_BEGIN) && (frame_type <= CHOP_END)) {
|
||||
} else if ((frame_type >= CHOP_BEGIN) && (frame_type <= CHOP_END)) {
|
||||
// chop_frame {
|
||||
// u1 frame_type = CHOP; /* 248-250 */
|
||||
// u2 offset_delta;
|
||||
@ -464,7 +464,7 @@ extern "C" {
|
||||
frameOffsetDelta = get_u2();
|
||||
put_u2(calculateOffsetDelta(i, frameOffsetDelta));
|
||||
|
||||
} else if(frame_type == SAME_FRAME_EXTENDED) {
|
||||
} else if (frame_type == SAME_FRAME_EXTENDED) {
|
||||
// same_frame_extended {
|
||||
// u1 frame_type = SAME_FRAME_EXTENDED; /* 251 */
|
||||
// u2 offset_delta;
|
||||
@ -474,7 +474,7 @@ extern "C" {
|
||||
frameOffsetDelta = get_u2();
|
||||
put_u2(calculateOffsetDelta(i, frameOffsetDelta));
|
||||
|
||||
} else if((frame_type >= APPEND_BEGIN) && (frame_type <= APPEND_END)) {
|
||||
} else if ((frame_type >= APPEND_BEGIN) && (frame_type <= APPEND_END)) {
|
||||
// append_frame {
|
||||
// u1 frame_type = APPEND; /* 252-254 */
|
||||
// u2 offset_delta;
|
||||
@ -486,7 +486,7 @@ extern "C" {
|
||||
put_u2(calculateOffsetDelta(i, frameOffsetDelta));
|
||||
copyVerificationTypeInfo((u1)(frame_type - 251));
|
||||
|
||||
} else if(frame_type == FULL_FRAME) {
|
||||
} else if (frame_type == FULL_FRAME) {
|
||||
// sfull_frame {
|
||||
// u1 frame_type = FULL_FRAME; /* 255 */
|
||||
// u2 offset_delta;
|
||||
|
@ -116,7 +116,7 @@ int nsk_jvmti_aod_getClassName(jvmtiEnv *jvmti, jclass klass, char classNameBuff
|
||||
|
||||
int nsk_jvmti_aod_getThreadName(jvmtiEnv * jvmti, jthread thread, char threadNameBuffer[]) {
|
||||
jvmtiThreadInfo info;
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))){
|
||||
if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &info))) {
|
||||
NSK_COMPLAIN0("Failed to get thread info\n");
|
||||
threadNameBuffer[0] = '\0';
|
||||
return NSK_FALSE;
|
||||
|
@ -268,7 +268,7 @@ int nsk_jvmti_parseOptions(const char options[]) {
|
||||
* If this break is not there then It will expects
|
||||
* to have. so a space should be sufficient as well.
|
||||
*/
|
||||
for(val_len=0; !(*opt_end == '\0' || isOptSep(*opt_end)); opt_end++,val_len++) {
|
||||
for (val_len=0; !(*opt_end == '\0' || isOptSep(*opt_end)); opt_end++,val_len++) {
|
||||
//if (*opt_end == NSK_JVMTI_OPTION_START) {
|
||||
// break;
|
||||
//}
|
||||
|
@ -59,7 +59,7 @@ This method executes JNI analog for following Java code:
|
||||
|
||||
success = env->MonitorEnter(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
@ -103,7 +103,7 @@ This method executes JNI analog for following Java code:
|
||||
|
||||
success = env->MonitorExit(thisObject);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
|
||||
|
||||
|
@ -34,7 +34,7 @@ Java_nsk_share_locks_LockingThread_nativeJNIMonitorEnter(JNIEnv *env, jobject th
|
||||
|
||||
success = env->MonitorEnter(object);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorEnter return non-zero: %d\n", success);
|
||||
|
||||
@ -50,7 +50,7 @@ Java_nsk_share_locks_LockingThread_nativeJNIMonitorEnter(JNIEnv *env, jobject th
|
||||
|
||||
success = env->MonitorExit(object);
|
||||
|
||||
if(success != 0)
|
||||
if (success != 0)
|
||||
{
|
||||
NSK_COMPLAIN1("MonitorExit return non-zero: %d\n", success);
|
||||
|
||||
|
@ -72,7 +72,7 @@ Java_nsk_stress_jni_JNIter001_jnistress (JNIEnv *env, jobject jobj, jstring jstr
|
||||
for (j=0;j<nstr;j++)
|
||||
element->checkstr[j] = (char *)c_malloc(env, DIGESTLENGTH*sizeof(char));
|
||||
}
|
||||
for(j=0;j<DIGESTLENGTH;j++) {
|
||||
for (j=0;j<DIGESTLENGTH;j++) {
|
||||
digest[j]=0;
|
||||
}
|
||||
element->str[allocs] = env->GetStringUTFChars(jstr,0); CE
|
||||
@ -97,7 +97,7 @@ Java_nsk_stress_jni_JNIter001_jnistress (JNIEnv *env, jobject jobj, jstring jstr
|
||||
tmpstr=env->NewStringUTF(element->str[allocs-1]); CE
|
||||
for (j=0; j<nstr; j++) {
|
||||
|
||||
for(i=0;i<DIGESTLENGTH;i++) {
|
||||
for (i=0;i<DIGESTLENGTH;i++) {
|
||||
digest[i]=0;
|
||||
}
|
||||
for (k=0; k < strlen(element->str[j]); k++) {
|
||||
@ -168,7 +168,7 @@ Java_nsk_stress_jni_JNIter001_jnistress1(JNIEnv *env, jobject jobj, jstring jstr
|
||||
for (j=0;j<nstr;j++)
|
||||
javachars->checkstr[j] = (char *)c_malloc(env, DIGESTLENGTH*sizeof(char));
|
||||
}
|
||||
for(j=0;j<DIGESTLENGTH;j++) {
|
||||
for (j=0;j<DIGESTLENGTH;j++) {
|
||||
digest[j]=0;
|
||||
}
|
||||
javachars->str[index] = env->GetStringChars(jstr,0); CE
|
||||
@ -181,7 +181,7 @@ Java_nsk_stress_jni_JNIter001_jnistress1(JNIEnv *env, jobject jobj, jstring jstr
|
||||
}
|
||||
|
||||
//memcpy(digest, elem, javachars->size[index]);
|
||||
for(j=0;j<elem_len; j++) {
|
||||
for (j=0;j<elem_len; j++) {
|
||||
digest[j % DIGESTLENGTH]+=elem[j];
|
||||
}
|
||||
memcpy(javachars->checkstr[index++],digest,DIGESTLENGTH);
|
||||
@ -201,10 +201,10 @@ Java_nsk_stress_jni_JNIter001_jnistress1(JNIEnv *env, jobject jobj, jstring jstr
|
||||
elem[i] = (char) javachars->str[j][i];
|
||||
}
|
||||
//memcpy(digest, elem, javachars->size[j]);
|
||||
for(i=0;i<DIGESTLENGTH;i++) {
|
||||
for (i=0;i<DIGESTLENGTH;i++) {
|
||||
digest[i]=0;
|
||||
}
|
||||
for(i=0;i<javachars->size[j]; i++) {
|
||||
for (i=0;i<javachars->size[j]; i++) {
|
||||
digest[i % DIGESTLENGTH]+=elem[i];
|
||||
}
|
||||
free(elem);
|
||||
@ -217,7 +217,7 @@ Java_nsk_stress_jni_JNIter001_jnistress1(JNIEnv *env, jobject jobj, jstring jstr
|
||||
else {
|
||||
equal=0;
|
||||
printf("The Unicode element No. %d has been corrupted\n",j);
|
||||
for(i=0;i<DIGESTLENGTH;i++) {
|
||||
for (i=0;i<DIGESTLENGTH;i++) {
|
||||
printf("digest[%d]=%02x checkstr[%d]=%02x\n",i,digest[i],i,javachars->checkstr[j][i]);
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ Java_nsk_stress_jni_JNIter003_jniInitArrays (JNIEnv *env, jobject jobj, jint siz
|
||||
arrayArray[FLOAT]=env->NewFloatArray(SIZE); CE
|
||||
arrayArray[DOUBLE]=env->NewDoubleArray(SIZE); CE
|
||||
|
||||
for(i=0;i<8;i++)
|
||||
for (i=0;i<8;i++)
|
||||
{env->SetObjectArrayElement(objectsArray,i,arrayArray[i]); CE }
|
||||
|
||||
boolBuf=(jboolean *)malloc(SIZE*sizeof(jboolean));
|
||||
@ -163,7 +163,7 @@ Java_nsk_stress_jni_JNIter003_jniBodyChangeArray (JNIEnv *env, jobject jobj,
|
||||
env->MonitorExit(jobj); CE
|
||||
arrayOrig=(jarray *)malloc(8*sizeof(jarray));
|
||||
arrayClone=(jarray *)malloc(8*sizeof(jarray));
|
||||
for(i=0;i<8;i++) {
|
||||
for (i=0;i<8;i++) {
|
||||
arrayOrig[i]=(jarray) env->GetObjectArrayElement(orig,i); CE
|
||||
arrayClone[i]=(jarray) env->GetObjectArrayElement(clone,i); CE
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ Java_nsk_stress_jni_JNIter004_CheckSum (JNIEnv *env, jobject jobj, jstring jstr)
|
||||
char *str;
|
||||
jint len=env->GetStringUTFLength(jstr); CE
|
||||
|
||||
for(i=0;i<DIGESTLENGTH;i++) {
|
||||
for (i=0;i<DIGESTLENGTH;i++) {
|
||||
digest[i]=0;
|
||||
}
|
||||
str=(char *)malloc(len*sizeof(char));
|
||||
@ -56,10 +56,10 @@ Java_nsk_stress_jni_JNIter004_CheckSum (JNIEnv *env, jobject jobj, jstring jstr)
|
||||
env->ExceptionClear();
|
||||
}
|
||||
critstr=env->GetStringCritical(jstr, 0); CE
|
||||
for(i=0;i<len;i++)
|
||||
for (i=0;i<len;i++)
|
||||
str[i] = (char) critstr[i];
|
||||
env->ReleaseStringCritical(jstr,critstr); CE
|
||||
for(i=0;i<len;i++) {
|
||||
for (i=0;i<len;i++) {
|
||||
digest[i % DIGESTLENGTH]+=str[i];
|
||||
}
|
||||
free(str);
|
||||
@ -93,7 +93,7 @@ Java_nsk_stress_jni_JNIter004_CheckCompare (JNIEnv *env, jobject jobj, jstring j
|
||||
jint len;
|
||||
jchar *ch;
|
||||
|
||||
for(i=0;i<DIGESTLENGTH;i++) {
|
||||
for (i=0;i<DIGESTLENGTH;i++) {
|
||||
digest[i]=0;
|
||||
}
|
||||
strlen = env->GetStringUTFLength(jstr); CE
|
||||
@ -112,10 +112,10 @@ Java_nsk_stress_jni_JNIter004_CheckCompare (JNIEnv *env, jobject jobj, jstring j
|
||||
env->ExceptionClear();
|
||||
}
|
||||
critstr=env->GetStringCritical(jstr, 0); CE
|
||||
for(i=0;i<strlen;i++)
|
||||
for (i=0;i<strlen;i++)
|
||||
str[i] = (char) critstr[i];
|
||||
env->ReleaseStringCritical(jstr,critstr); CE
|
||||
for(i=0;i<strlen; i++) {
|
||||
for (i=0;i<strlen; i++) {
|
||||
digest[i % DIGESTLENGTH]+=str[i % DIGESTLENGTH];
|
||||
}
|
||||
|
||||
@ -139,8 +139,8 @@ Java_nsk_stress_jni_JNIter004_CheckCompare (JNIEnv *env, jobject jobj, jstring j
|
||||
ch=(jchar *)env->GetPrimitiveArrayCritical(cArr,0); CE
|
||||
|
||||
printf("Comparing: ");
|
||||
for(i=0;i<len;i++)
|
||||
if(ch[i]!=tmp[i]) {
|
||||
for (i=0;i<len;i++)
|
||||
if (ch[i]!=tmp[i]) {
|
||||
printf("Error in %d\n",i);
|
||||
printf("ch[%d]=%02x tmp[%d]=%02x\n",i,ch[i],i,tmp[i]);
|
||||
ret=JNI_FALSE;
|
||||
|
@ -55,7 +55,7 @@ Java_nsk_stress_jni_JNIter005_except (JNIEnv *env, jobject jobj, jthrowable tobj
|
||||
env->MonitorEnter(jobj);
|
||||
CHECK_EXCEPTION
|
||||
if (!env->Throw(tobj)) {
|
||||
if(env->ExceptionOccurred())
|
||||
if (env->ExceptionOccurred())
|
||||
if (Exceptcalls%1000==0)
|
||||
fprintf(stderr, "NATIVE: Throw has been catched in native\n");
|
||||
env->ExceptionClear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user