< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo001/thrinfo001.cpp

Print this page
@@ -43,11 +43,12 @@
  static jint result = PASSED;
  static jvmtiThreadInfo inf;
  static info threads[] = {
      { "main", JVMTI_THREAD_NORM_PRIORITY, 0 },
      { "thread1", JVMTI_THREAD_MIN_PRIORITY + 2, 1 },
-     { "Thread-", JVMTI_THREAD_MIN_PRIORITY, 1 }
+     { "Thread-", JVMTI_THREAD_MIN_PRIORITY, 1 },
+     { "vthread", JVMTI_THREAD_NORM_PRIORITY, 1 }
  };
  
  #ifdef STATIC_BUILD
  JNIEXPORT jint JNICALL Agent_OnLoad_thrinfo001(JavaVM *jvm, char *options, void *reserved) {
      return Agent_Initialize(jvm, options, reserved);

@@ -59,17 +60,25 @@
      return JNI_VERSION_1_8;
  }
  #endif
  jint  Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
      jint res;
+     jvmtiCapabilities caps;
  
      res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
      if (res != JNI_OK || jvmti == NULL) {
          printf("Wrong result of a valid call to GetEnv !\n");
          return JNI_ERR;
      }
  
+     memset(&caps, 0, sizeof(caps));
+     caps.can_support_virtual_threads = 1;
+     res = jvmti->AddCapabilities(&caps);
+     if (res != JVMTI_ERROR_NONE) {
+       printf("error in JVMTI AddCapabilities: %d\n", res);
+       return JNI_ERR;
+     }
      return JNI_OK;
  }
  
  JNIEXPORT void JNICALL Java_nsk_jvmti_GetThreadInfo_thrinfo001_checkInfo(JNIEnv *env, jclass cls,
          jthread thr, jthreadGroup group, jint ind) {
< prev index next >