comparison test/hotspot/jtreg/vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk003/classfloadhk003.cpp @ 52064:054a24c46812

8211261: Remove the NSK_CPP_STUB macros from vmTestbase for jvmti/[A-G]* Summary: Remove the NSK_CPP_STUB macros Reviewed-by: amenkov, cjplummer
author jcbeyler
date Mon, 08 Oct 2018 13:54:43 -0700
parents 79dc492c00ab
children
comparison
equal deleted inserted replaced
1:cd8c2dda97f7 2:d7f8ce5e1b9d
125 jbyte* elements; 125 jbyte* elements;
126 int i; 126 int i;
127 127
128 NSK_DISPLAY1("Find static field: %s\n", fieldName); 128 NSK_DISPLAY1("Find static field: %s\n", fieldName);
129 if (!NSK_JNI_VERIFY(jni, (fieldID = 129 if (!NSK_JNI_VERIFY(jni, (fieldID =
130 NSK_CPP_STUB4(GetStaticFieldID, jni, cls, fieldName, fieldSig)) != NULL)) { 130 jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) {
131 nsk_jvmti_setFailStatus(); 131 nsk_jvmti_setFailStatus();
132 return NSK_FALSE; 132 return NSK_FALSE;
133 } 133 }
134 NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); 134 NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID);
135 135
136 NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName); 136 NSK_DISPLAY1("Get classfile bytes array from static field: %s\n", fieldName);
137 if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray) 137 if (!NSK_JNI_VERIFY(jni, (array = (jbyteArray)
138 NSK_CPP_STUB3(GetStaticObjectField, jni, cls, fieldID)) != NULL)) { 138 jni->GetStaticObjectField(cls, fieldID)) != NULL)) {
139 nsk_jvmti_setFailStatus(); 139 nsk_jvmti_setFailStatus();
140 return NSK_FALSE; 140 return NSK_FALSE;
141 } 141 }
142 NSK_DISPLAY1(" ... got array object: 0x%p\n", (void*)array); 142 NSK_DISPLAY1(" ... got array object: 0x%p\n", (void*)array);
143 143
144 if (!NSK_JNI_VERIFY(jni, (*size = 144 if (!NSK_JNI_VERIFY(jni, (*size = jni->GetArrayLength(array)) > 0)) {
145 NSK_CPP_STUB2(GetArrayLength, jni, array)) > 0)) {
146 nsk_jvmti_setFailStatus(); 145 nsk_jvmti_setFailStatus();
147 return NSK_FALSE; 146 return NSK_FALSE;
148 } 147 }
149 NSK_DISPLAY1(" ... got array size: %d bytes\n", (int)*size); 148 NSK_DISPLAY1(" ... got array size: %d bytes\n", (int)*size);
150 149
151 { 150 {
152 jboolean isCopy; 151 jboolean isCopy;
153 if (!NSK_JNI_VERIFY(jni, (elements = 152 if (!NSK_JNI_VERIFY(jni, (elements = jni->GetByteArrayElements(array, &isCopy)) != NULL)) {
154 NSK_CPP_STUB3(GetByteArrayElements, jni, array,
155 &isCopy)) != NULL)) {
156 nsk_jvmti_setFailStatus(); 153 nsk_jvmti_setFailStatus();
157 return NSK_FALSE; 154 return NSK_FALSE;
158 } 155 }
159 } 156 }
160 NSK_DISPLAY1(" ... got elements list: 0x%p\n", (void*)elements); 157 NSK_DISPLAY1(" ... got elements list: 0x%p\n", (void*)elements);
161 158
162 if (!NSK_JVMTI_VERIFY( 159 if (!NSK_JVMTI_VERIFY(jvmti->Allocate(*size, bytes))) {
163 NSK_CPP_STUB3(Allocate, jvmti, *size, bytes))) {
164 nsk_jvmti_setFailStatus(); 160 nsk_jvmti_setFailStatus();
165 return NSK_FALSE; 161 return NSK_FALSE;
166 } 162 }
167 NSK_DISPLAY1(" ... created bytes array: 0x%p\n", (void*)*bytes); 163 NSK_DISPLAY1(" ... created bytes array: 0x%p\n", (void*)*bytes);
168 164
170 (*bytes)[i] = (unsigned char)elements[i]; 166 (*bytes)[i] = (unsigned char)elements[i];
171 } 167 }
172 NSK_DISPLAY1(" ... copied bytecode: %d bytes\n", (int)*size); 168 NSK_DISPLAY1(" ... copied bytecode: %d bytes\n", (int)*size);
173 169
174 NSK_DISPLAY1("Release elements list: 0x%p\n", (void*)elements); 170 NSK_DISPLAY1("Release elements list: 0x%p\n", (void*)elements);
175 NSK_TRACE(NSK_CPP_STUB4(ReleaseByteArrayElements, jni, array, elements, JNI_ABORT)); 171 NSK_TRACE(jni->ReleaseByteArrayElements(array, elements, JNI_ABORT));
176 NSK_DISPLAY0(" ... released\n"); 172 NSK_DISPLAY0(" ... released\n");
177 173
178 return NSK_TRUE; 174 return NSK_TRUE;
179 } 175 }
180 176
185 jfieldID fieldID = NULL; 181 jfieldID fieldID = NULL;
186 jobject obj = NULL; 182 jobject obj = NULL;
187 183
188 NSK_DISPLAY1("Find static field: %s\n", fieldName); 184 NSK_DISPLAY1("Find static field: %s\n", fieldName);
189 if (!NSK_JNI_VERIFY(jni, (fieldID = 185 if (!NSK_JNI_VERIFY(jni, (fieldID =
190 NSK_CPP_STUB4(GetStaticFieldID, jni, cls, fieldName, fieldSig)) != NULL)) { 186 jni->GetStaticFieldID(cls, fieldName, fieldSig)) != NULL)) {
191 nsk_jvmti_setFailStatus(); 187 nsk_jvmti_setFailStatus();
192 return NULL; 188 return NULL;
193 } 189 }
194 NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID); 190 NSK_DISPLAY1(" ... got fieldID: 0x%p\n", (void*)fieldID);
195 191
196 NSK_DISPLAY1("Get object from static field: %s\n", fieldName); 192 NSK_DISPLAY1("Get object from static field: %s\n", fieldName);
197 if (!NSK_JNI_VERIFY(jni, (obj = 193 if (!NSK_JNI_VERIFY(jni, (obj = jni->GetStaticObjectField(cls, fieldID)) != NULL)) {
198 NSK_CPP_STUB3(GetStaticObjectField, jni, cls, fieldID)) != NULL)) {
199 nsk_jvmti_setFailStatus(); 194 nsk_jvmti_setFailStatus();
200 return NULL; 195 return NULL;
201 } 196 }
202 NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj); 197 NSK_DISPLAY1(" ... got object: 0x%p\n", (void*)obj);
203 198
204 NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj); 199 NSK_DISPLAY1("Make global reference to object: 0x%p\n", obj);
205 if (!NSK_JNI_VERIFY(jni, (obj = 200 if (!NSK_JNI_VERIFY(jni, (obj = jni->NewGlobalRef(obj)) != NULL)) {
206 NSK_CPP_STUB2(NewGlobalRef, jni, obj)) != NULL)) {
207 nsk_jvmti_setFailStatus(); 201 nsk_jvmti_setFailStatus();
208 return NULL; 202 return NULL;
209 } 203 }
210 NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj); 204 NSK_DISPLAY1(" ... got global ref: 0x%p\n", (void*)obj);
211 205
227 jclass debugeeClass = NULL; 221 jclass debugeeClass = NULL;
228 222
229 NSK_DISPLAY0(">>> Obtain debuggee class\n"); 223 NSK_DISPLAY0(">>> Obtain debuggee class\n");
230 NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME); 224 NSK_DISPLAY1("Find debugee class: %s\n", DEBUGEE_CLASS_NAME);
231 if (!NSK_JNI_VERIFY(jni, (debugeeClass = 225 if (!NSK_JNI_VERIFY(jni, (debugeeClass =
232 NSK_CPP_STUB2(FindClass, jni, DEBUGEE_CLASS_NAME)) != NULL)) { 226 jni->FindClass(DEBUGEE_CLASS_NAME)) != NULL)) {
233 nsk_jvmti_setFailStatus(); 227 nsk_jvmti_setFailStatus();
234 return; 228 return;
235 } 229 }
236 NSK_DISPLAY1(" ... found class: 0x%p\n", (void*)debugeeClass); 230 NSK_DISPLAY1(" ... found class: 0x%p\n", (void*)debugeeClass);
237 231
284 } 278 }
285 279
286 NSK_DISPLAY0(">>> Clean used data\n"); 280 NSK_DISPLAY0(">>> Clean used data\n");
287 { 281 {
288 NSK_DISPLAY1("Delete global reference to classloader object: 0x%p\n", (void*)classLoader); 282 NSK_DISPLAY1("Delete global reference to classloader object: 0x%p\n", (void*)classLoader);
289 NSK_CPP_STUB2(DeleteGlobalRef, jni, classLoader); 283 jni->DeleteGlobalRef(classLoader);
290 284
291 NSK_DISPLAY1("Deallocate classfile bytes array: 0x%p\n", (void*)origClassBytes); 285 NSK_DISPLAY1("Deallocate classfile bytes array: 0x%p\n", (void*)origClassBytes);
292 if (!NSK_JVMTI_VERIFY( 286 if (!NSK_JVMTI_VERIFY(jvmti->Deallocate(origClassBytes))) {
293 NSK_CPP_STUB2(Deallocate, jvmti, origClassBytes))) {
294 nsk_jvmti_setFailStatus(); 287 nsk_jvmti_setFailStatus();
295 } 288 }
296 } 289 }
297 } 290 }
298 291
329 NSK_DISPLAY1("Check classloader: 0x%p\n", (void*)loader); 322 NSK_DISPLAY1("Check classloader: 0x%p\n", (void*)loader);
330 if (loader == NULL) { 323 if (loader == NULL) {
331 NSK_COMPLAIN1("Unexpected NULL classloader in CLASS_FILE_LOAD_HOOK: 0x%p\n", 324 NSK_COMPLAIN1("Unexpected NULL classloader in CLASS_FILE_LOAD_HOOK: 0x%p\n",
332 (void*)loader); 325 (void*)loader);
333 nsk_jvmti_setFailStatus(); 326 nsk_jvmti_setFailStatus();
334 } else if (!NSK_CPP_STUB3(IsSameObject, jni, loader, classLoader)) { 327 } else if (!jni->IsSameObject(loader, classLoader)) {
335 NSK_COMPLAIN2("Unexpected classloader in CLASS_FILE_LOAD_HOOK for tested class:\n" 328 NSK_COMPLAIN2("Unexpected classloader in CLASS_FILE_LOAD_HOOK for tested class:\n"
336 "# got classloder: 0x%p\n" 329 "# got classloder: 0x%p\n"
337 "# expected same as: 0x%p\n", 330 "# expected same as: 0x%p\n",
338 (void*)loader, (void*)classLoader); 331 (void*)loader, (void*)classLoader);
339 nsk_jvmti_setFailStatus(); 332 nsk_jvmti_setFailStatus();
378 { 371 {
379 jvmtiCapabilities caps; 372 jvmtiCapabilities caps;
380 373
381 memset(&caps, 0, sizeof(caps)); 374 memset(&caps, 0, sizeof(caps));
382 caps.can_generate_all_class_hook_events = 1; 375 caps.can_generate_all_class_hook_events = 1;
383 if (!NSK_JVMTI_VERIFY( 376 if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
384 NSK_CPP_STUB2(AddCapabilities, jvmti, &caps))) {
385 return JNI_ERR; 377 return JNI_ERR;
386 } 378 }
387 } 379 }
388 NSK_DISPLAY0(" ... added\n"); 380 NSK_DISPLAY0(" ... added\n");
389 381
392 jvmtiEventCallbacks callbacks; 384 jvmtiEventCallbacks callbacks;
393 jint size = (jint)sizeof(callbacks); 385 jint size = (jint)sizeof(callbacks);
394 386
395 memset(&callbacks, 0, sizeof(callbacks)); 387 memset(&callbacks, 0, sizeof(callbacks));
396 callbacks.ClassFileLoadHook = callbackClassFileLoadHook; 388 callbacks.ClassFileLoadHook = callbackClassFileLoadHook;
397 if (!NSK_JVMTI_VERIFY( 389 if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, size))) {
398 NSK_CPP_STUB3(SetEventCallbacks, jvmti, &callbacks, size))) {
399 return JNI_ERR; 390 return JNI_ERR;
400 } 391 }
401 } 392 }
402 NSK_DISPLAY0(" ... set\n"); 393 NSK_DISPLAY0(" ... set\n");
403 394