< prev index next >

test/hotspot/jtreg/serviceability/jvmti/RedefineClasses/RedefineRunningMethods.java

Print this page
@@ -29,12 +29,17 @@
   * @library /test/lib
   * @modules java.base/jdk.internal.misc
   * @modules java.compiler
   *          java.instrument
   *          jdk.jartool/sun.tools.jar
+  * @compile --enable-preview -source ${jdk.version} RedefineRunningMethods.java
   * @run main RedefineClassHelper
-  * @run main/othervm/timeout=180 -javaagent:redefineagent.jar -Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace,class+loader+data=debug,safepoint+cleanup,gc+phases=debug:rt.log RedefineRunningMethods
+  * @run main/othervm/timeout=180
+  *         --enable-preview
+  *         -javaagent:redefineagent.jar
+  *         -Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace,class+loader+data=debug,safepoint+cleanup,gc+phases=debug:rt.log
+  *         RedefineRunningMethods
   */
  
  
  // package access top-level class to avoid problem with RedefineClassHelper
  // and nested types.

@@ -96,34 +101,25 @@
                  "}";
  
  
      public static void main(String[] args) throws Exception {
  
-         new Thread() {
-             public void run() {
-                 RedefineRunningMethods_B.infinite();
-             }
-         }.start();
- 
-         new Thread() {
-             public void run() {
-                 RedefineRunningMethods_B.infinite_emcp();
-             }
-         }.start();
+         var t1 = Thread.ofPlatform().start(RedefineRunningMethods_B::infinite);
+         var t1v = Thread.ofVirtual().start(RedefineRunningMethods_B::infinite);
+         var t2 = Thread.ofPlatform().start(RedefineRunningMethods_B::infinite_emcp);
+         var t2v = Thread.ofVirtual().start(RedefineRunningMethods_B::infinite);
  
          RedefineClassHelper.redefineClass(RedefineRunningMethods_B.class, newB);
  
          System.gc();
  
          RedefineRunningMethods_B.infinite();
  
          // Start a thread with the second version of infinite_emcp running
-         new Thread() {
-             public void run() {
-                 RedefineRunningMethods_B.infinite_emcp();
-             }
-         }.start();
+         var t3 = Thread.ofPlatform().start(RedefineRunningMethods_B::infinite_emcp);
+         var t3v = Thread.ofVirtual().start(RedefineRunningMethods_B::infinite_emcp);
+ 
  
          for (int i = 0; i < 20 ; i++) {
              String s = new String("some garbage");
              System.gc();
          }

@@ -145,7 +141,15 @@
          for (int i = 0; i < 20 ; i++) {
              RedefineRunningMethods_B.infinite();
              String s = new String("some garbage");
              System.gc();
          }
+ /*
+         TODO uncomment, should be join added to orginal test?
+         t1.join();
+         t2.join();
+         t3.join();
+         t1v.join();
+         t2v.join();
+  */
      }
  }
< prev index next >