test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/redefclass031/redefclass031.cpp
equal
deleted
inserted
replaced
75 #endif |
75 #endif |
76 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { |
76 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved) { |
77 jint res; |
77 jint res; |
78 jvmtiError err; |
78 jvmtiError err; |
79 |
79 |
80 if ((res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1)) != JNI_OK) { |
80 res = vm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); |
|
81 if (res != JNI_OK) { |
81 printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res); |
82 printf("%s: Failed to call GetEnv: error=%d\n", __FILE__, res); |
82 return JNI_ERR; |
83 return JNI_ERR; |
83 } |
84 } |
84 |
85 |
85 err = jvmti->GetPotentialCapabilities(&caps); |
86 err = jvmti->GetPotentialCapabilities(&caps); |
138 |
139 |
139 if (!caps.can_redefine_classes) { |
140 if (!caps.can_redefine_classes) { |
140 return PASSED; |
141 return PASSED; |
141 } |
142 } |
142 |
143 |
143 if ((err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, |
144 err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_NATIVE_METHOD_BIND, NULL); |
144 JVMTI_EVENT_NATIVE_METHOD_BIND, NULL)) != JVMTI_ERROR_NONE) { |
145 if (err != JVMTI_ERROR_NONE) { |
145 printf("Failed to enable JVMTI_EVENT_NATIVE_METHOD_BIND: %s (%d)\n", |
146 printf("Failed to enable JVMTI_EVENT_NATIVE_METHOD_BIND: %s (%d)\n", |
146 TranslateError(err), err); |
147 TranslateError(err), err); |
147 result = STATUS_FAILED; |
148 result = STATUS_FAILED; |
148 } |
149 } |
149 |
150 |
155 set_watch_ev(1); /* watch JVMTI events */ |
156 set_watch_ev(1); /* watch JVMTI events */ |
156 |
157 |
157 if (vrb == 1) |
158 if (vrb == 1) |
158 printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", |
159 printf(">>>>>>>> Invoke RedefineClasses():\n\tnew class byte count=%d\n", |
159 classDef.class_byte_count); |
160 classDef.class_byte_count); |
160 if ((err = (jvmti->RedefineClasses(1, &classDef))) != JVMTI_ERROR_NONE) { |
161 err = jvmti->RedefineClasses(1, &classDef); |
|
162 if (err != JVMTI_ERROR_NONE) { |
161 printf("TEST FAILED: the function RedefineClasses() returned error %d: %s\n", |
163 printf("TEST FAILED: the function RedefineClasses() returned error %d: %s\n", |
162 err, TranslateError(err)); |
164 err, TranslateError(err)); |
163 printf("\tFor more info about this error see the JVMTI spec.\n"); |
165 printf("\tFor more info about this error see the JVMTI spec.\n"); |
164 result = STATUS_FAILED; |
166 result = STATUS_FAILED; |
165 } |
167 } |