< prev index next >

test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorStackDepthInfo/GetOwnedMonitorStackDepthInfoTest.java

Print this page
@@ -25,12 +25,12 @@
  /**
   * @test
   * @bug 8153629
   * @summary Need to cover JVMTI's GetOwnedMonitorStackDepthInfo function
   * @requires vm.jvmti
-  * @compile GetOwnedMonitorStackDepthInfoTest.java
-  * @run main/othervm/native -agentlib:GetOwnedMonitorStackDepthInfoTest GetOwnedMonitorStackDepthInfoTest
+  * @compile --enable-preview -source ${jdk.version} GetOwnedMonitorStackDepthInfoTest.java
+  * @run main/othervm/native --enable-preview -agentlib:GetOwnedMonitorStackDepthInfoTest GetOwnedMonitorStackDepthInfoTest
   */
  
  
  public class GetOwnedMonitorStackDepthInfoTest {
  

@@ -49,18 +49,18 @@
  
      private static volatile int results = -1;
  
  
      public static void main(String[] args) throws Exception {
- 
-         new GetOwnedMonitorStackDepthInfoTest().runTest();
- 
+         new GetOwnedMonitorStackDepthInfoTest().runTest(true);
+         new GetOwnedMonitorStackDepthInfoTest().runTest(false);
      }
  
-     public void runTest() throws Exception {
+     public void runTest(boolean isVirtual) throws Exception {
+         var threadFactory = isVirtual ? Thread.ofVirtual().factory() : Thread.ofPlatform().factory();
          final Object lock1 = new Lock1();
-         Thread t1 = new Thread(() -> {
+         Thread t1 = threadFactory.newThread(() -> {
              synchronized (lock1) {
                  System.out.println("Thread in sync section 1: "
                          + Thread.currentThread().getName());
                  test1();
              }

@@ -95,6 +95,5 @@
  
      private static class Lock2 {
  
      }
  }
- 
< prev index next >