8172246: [TESTBUG] runtime/RedefineTests/RedefinePreviousVersions.java 'Class unloading: has_previous_versions = true' missing from stdout/stderr

Add boolean to gate redefinition start

Reviewed-by: sspitsyn, dholmes
This commit is contained in:
Coleen Phillimore 2017-01-04 21:13:04 -05:00
parent b58bb4740e
commit 08aa21deb7

View File

@ -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 class RedefinePreviousVersions {
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 @@ public class RedefinePreviousVersions {
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 @@ public class RedefinePreviousVersions {
}
}.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);