< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp

Print this page
rev 52185 : [mq]: refactor


 435         nsk_ltrace(NSK_TRACE_AFTER,file,line,
 436             "  jvmti error: code=%d, name=%s\n",errorCode,errorName);
 437     if ((error == expected) == negative) {
 438         nsk_lvcomplain(file,line,format,ap);
 439         nsk_printf("#   jvmti error: code=%d, name=%s\n",errorCode,errorName);
 440         if (expected != JVMTI_ERROR_NONE)
 441             nsk_printf("#   error expected: code=%d, name=%s\n",
 442                 expected, TranslateError(expected));
 443         failure=1;
 444     };
 445     va_end(ap);
 446     return !failure;
 447 }
 448 
 449 /*************************************************************/
 450 
 451 JNIEXPORT jstring JNICALL
 452 Java_nsk_share_jvmti_ArgumentHandler_getAgentOptionsString(JNIEnv *jni, jobject obj) {
 453     jstring str_obj = NULL;
 454 
 455     if (!NSK_JNI_VERIFY(jni, (str_obj =
 456             NSK_CPP_STUB2(NewStringUTF, jni, context.options.string)) != NULL)) {
 457         return NULL;
 458     }
 459     return str_obj;
 460 }
 461 
 462 /*************************************************************/
 463 
 464 /**
 465   * This method will try to redefine the class (classToRedefine) by loading
 466   * physical file.  <b>pathToNewByteCode</b> option which is passed
 467   * on OnLoad Phase also used.
 468   *
 469   * So This method will do a file read pathToByteCode+fileName+.class (total path).
 470   * Constrcuts a class objects and does a redefine of the class.
 471   * On successfull redefine this method will return eaither JNI_TRUE or JNI_FALSE
 472   *
 473   * Hint::
 474   *     1)
 475   *      If there are many redefine on same testcase, then please try to use
 476   *      integer value (newclass00, newclass01, newclass02 , ....) way.


 620     agentFailed = NSK_TRUE;
 621 }
 622 
 623 int isThreadExpected(jvmtiEnv *jvmti, jthread thread) {
 624     static const char *vm_jfr_buffer_thread_name = "VM JFR Buffer Thread";
 625     static const char *jfr_request_timer_thread_name = "JFR request timer";
 626 
 627     jvmtiThreadInfo threadinfo;
 628     NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &threadinfo));
 629 
 630     if (strcmp(threadinfo.name, vm_jfr_buffer_thread_name) == 0)
 631         return 0;
 632 
 633     if (strcmp(threadinfo.name, jfr_request_timer_thread_name) == 0)
 634         return 0;
 635 
 636     return 1;
 637 }
 638 
 639 jint createRawMonitor(jvmtiEnv *env, const char *name, jrawMonitorID *monitor) {
 640     jvmtiError error = NSK_CPP_STUB3(CreateRawMonitor, env, name, monitor);
 641     if (!NSK_JVMTI_VERIFY(error)) {
 642         return JNI_ERR;
 643     }
 644     return JNI_OK;
 645 }
 646 
 647 void exitOnError(jvmtiError error) {
 648     if (!NSK_JVMTI_VERIFY(error)) {
 649         exit(error);
 650     }
 651 }
 652 
 653 void rawMonitorEnter(jvmtiEnv *env, jrawMonitorID monitor) {
 654     jvmtiError error = NSK_CPP_STUB2(RawMonitorEnter, env, monitor);
 655     exitOnError(error);
 656 }
 657 
 658 void rawMonitorExit(jvmtiEnv *env, jrawMonitorID monitor) {
 659     jvmtiError error = NSK_CPP_STUB2(RawMonitorExit, env, monitor);
 660     exitOnError(error);
 661 }
 662 
 663 void rawMonitorNotify(jvmtiEnv *env, jrawMonitorID monitor) {
 664     jvmtiError error = NSK_CPP_STUB2(RawMonitorNotify, env, monitor);
 665     exitOnError(error);
 666 }
 667 
 668 void rawMonitorWait(jvmtiEnv *env, jrawMonitorID monitor, jlong millis) {
 669     jvmtiError error = NSK_CPP_STUB3(RawMonitorWait, env, monitor, millis);
 670     exitOnError(error);
 671 }
 672 
 673 void getPhase(jvmtiEnv *env, jvmtiPhase *phase) {
 674     jvmtiError error = NSK_CPP_STUB2(GetPhase, env, phase);
 675     exitOnError(error);
 676 }
 677 
 678 /*************************************************************/
 679 
 680 }


 435         nsk_ltrace(NSK_TRACE_AFTER,file,line,
 436             "  jvmti error: code=%d, name=%s\n",errorCode,errorName);
 437     if ((error == expected) == negative) {
 438         nsk_lvcomplain(file,line,format,ap);
 439         nsk_printf("#   jvmti error: code=%d, name=%s\n",errorCode,errorName);
 440         if (expected != JVMTI_ERROR_NONE)
 441             nsk_printf("#   error expected: code=%d, name=%s\n",
 442                 expected, TranslateError(expected));
 443         failure=1;
 444     };
 445     va_end(ap);
 446     return !failure;
 447 }
 448 
 449 /*************************************************************/
 450 
 451 JNIEXPORT jstring JNICALL
 452 Java_nsk_share_jvmti_ArgumentHandler_getAgentOptionsString(JNIEnv *jni, jobject obj) {
 453     jstring str_obj = NULL;
 454 
 455     if (!NSK_JNI_VERIFY(jni, (str_obj = jni->NewStringUTF(context.options.string)) != NULL)) {

 456         return NULL;
 457     }
 458     return str_obj;
 459 }
 460 
 461 /*************************************************************/
 462 
 463 /**
 464   * This method will try to redefine the class (classToRedefine) by loading
 465   * physical file.  <b>pathToNewByteCode</b> option which is passed
 466   * on OnLoad Phase also used.
 467   *
 468   * So This method will do a file read pathToByteCode+fileName+.class (total path).
 469   * Constrcuts a class objects and does a redefine of the class.
 470   * On successfull redefine this method will return eaither JNI_TRUE or JNI_FALSE
 471   *
 472   * Hint::
 473   *     1)
 474   *      If there are many redefine on same testcase, then please try to use
 475   *      integer value (newclass00, newclass01, newclass02 , ....) way.


 619     agentFailed = NSK_TRUE;
 620 }
 621 
 622 int isThreadExpected(jvmtiEnv *jvmti, jthread thread) {
 623     static const char *vm_jfr_buffer_thread_name = "VM JFR Buffer Thread";
 624     static const char *jfr_request_timer_thread_name = "JFR request timer";
 625 
 626     jvmtiThreadInfo threadinfo;
 627     NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(thread, &threadinfo));
 628 
 629     if (strcmp(threadinfo.name, vm_jfr_buffer_thread_name) == 0)
 630         return 0;
 631 
 632     if (strcmp(threadinfo.name, jfr_request_timer_thread_name) == 0)
 633         return 0;
 634 
 635     return 1;
 636 }
 637 
 638 jint createRawMonitor(jvmtiEnv *env, const char *name, jrawMonitorID *monitor) {
 639     jvmtiError error = env->CreateRawMonitor(name, monitor);
 640     if (!NSK_JVMTI_VERIFY(error)) {
 641         return JNI_ERR;
 642     }
 643     return JNI_OK;
 644 }
 645 
 646 void exitOnError(jvmtiError error) {
 647     if (!NSK_JVMTI_VERIFY(error)) {
 648         exit(error);
 649     }
 650 }
 651 
 652 void rawMonitorEnter(jvmtiEnv *env, jrawMonitorID monitor) {
 653     jvmtiError error = env->RawMonitorEnter(monitor);
 654     exitOnError(error);
 655 }
 656 
 657 void rawMonitorExit(jvmtiEnv *env, jrawMonitorID monitor) {
 658     jvmtiError error = env->RawMonitorExit(monitor);
 659     exitOnError(error);
 660 }
 661 
 662 void rawMonitorNotify(jvmtiEnv *env, jrawMonitorID monitor) {
 663     jvmtiError error = env->RawMonitorNotify(monitor);
 664     exitOnError(error);
 665 }
 666 
 667 void rawMonitorWait(jvmtiEnv *env, jrawMonitorID monitor, jlong millis) {
 668     jvmtiError error = env->RawMonitorWait(monitor, millis);
 669     exitOnError(error);
 670 }
 671 
 672 void getPhase(jvmtiEnv *env, jvmtiPhase *phase) {
 673     jvmtiError error = env->GetPhase(phase);
 674     exitOnError(error);
 675 }
 676 
 677 /*************************************************************/
 678 
 679 }
< prev index next >