changeset 12518:f99f3a34981a

8172246: [TESTBUG] runtime/RedefineTests/RedefinePreviousVersions.java 'Class unloading: has_previous_versions = true' missing from stdout/stderr Summary: add boolean to gate redefinition start Reviewed-by: sspitsyn, dholmes
author coleenp
date Wed, 04 Jan 2017 21:13:04 -0500
parents 0b7902758a32
children 57d199c7daa9
files test/runtime/RedefineTests/RedefinePreviousVersions.java
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/test/runtime/RedefineTests/RedefinePreviousVersions.java	Wed Jan 04 11:44:26 2017 -0800
+++ b/test/runtime/RedefineTests/RedefinePreviousVersions.java	Wed Jan 04 21:13:04 2017 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,20 +48,23 @@
     public static String newRunning =
         "class RedefinePreviousVersions$Running {" +
         "    public static volatile boolean stop = true;" +
+        "    public static volatile boolean running = true;" +
         "    static void localSleep() { }" +
         "    public static void infinite() { }" +
         "}";
 
     static class Running {
         public static volatile boolean stop = false;
+        public static volatile boolean running = false;
         static void localSleep() {
           try{
-            Thread.currentThread().sleep(10);//sleep for 10 ms
+            Thread.sleep(10); // sleep for 10 ms
           } catch(InterruptedException ie) {
           }
         }
 
         public static void infinite() {
+            running = true;
             while (!stop) { localSleep(); }
         }
     }
@@ -70,8 +73,6 @@
 
         if (args.length > 0) {
 
-            String jarFile = System.getProperty("test.src") + "/testcase.jar";
-
             // java -javaagent:redefineagent.jar -Xlog:stuff RedefinePreviousVersions
             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-javaagent:redefineagent.jar",
                "-Xlog:redefine+class+iklass+add=trace,redefine+class+iklass+purge=trace",
@@ -100,6 +101,10 @@
             }
         }.start();
 
+        while (!Running.running) {
+            Thread.sleep(10); // sleep for 10 ms
+        }
+
         // Since a method of newRunning is running, this class should be added to the previous_version_list
         // of Running, and _has_previous_versions should return true at class unloading.
         RedefineClassHelper.redefineClass(Running.class, newRunning);