< prev index next >

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

Print this page
*** 22,10 ***
--- 22,11 ---
   */
  
  package nsk.jvmti.GetThreadInfo;
  
  import java.io.PrintStream;
+ import java.util.concurrent.ThreadFactory;
  
  public class thrinfo001 {
  
      final static int JCK_STATUS_BASE = 95;
  

*** 72,12 ***
--- 73,37 ---
          t_b.start();
          try {
              t_b.join();
          } catch (InterruptedException e) {}
          checkInfo(t_b, t_b.getThreadGroup(), 2);
+ 
+ 
+         Thread t_c = virtualThreadFactory().newThread(new thrinfo001c());
+         t_c.setName("vthread");
+ 
+         checkInfo(t_c, t_c.getThreadGroup(), 3);
+         t_c.start();
+         try {
+             t_c.join();
+         } catch (InterruptedException e) {}
+         checkInfo(t_c, t_c.getThreadGroup(), 3);
+ 
          return getRes();
      }
+ 
+     private static ThreadFactory virtualThreadFactory() {
+         try {
+             Object builder = Thread.class.getMethod("ofVirtual").invoke(null);
+             Class<?> clazz = Class.forName("java.lang.Thread$Builder");
+             java.lang.reflect.Method factory = clazz.getMethod("factory");
+             return (ThreadFactory) factory.invoke(builder);
+         } catch (RuntimeException | Error e) {
+             throw e;
+         } catch (Exception e) {
+             throw new RuntimeException(e);
+         }
+     }
  }
  
  class thrinfo001a extends Thread {
      thrinfo001a(ThreadGroup tg, String name) {
          super(tg, name);

*** 93,5 ***
--- 119,12 ---
      public void run() {
          Thread currThr = Thread.currentThread();
          thrinfo001.checkInfo(currThr, currThr.getThreadGroup(), 2);
      }
  }
+ 
+ class thrinfo001c implements Runnable {
+     public void run() {
+         Thread currThr = Thread.currentThread();
+         thrinfo001.checkInfo(currThr, currThr.getThreadGroup(), 3);
+     }
+ }
< prev index next >