Skip to content
Snippets Groups Projects
Commit be4f913e authored by Daniel Hu's avatar Daniel Hu Committed by Paul Hohensee
Browse files

8312049: runtime/logging/ClassLoadUnloadTest can be improved

Reviewed-by: phh
Backport-of: 4676b40f17dd18941f5883cb9b989ad639992a50
parent 8dbd6772
No related branches found
No related tags found
No related merge requests found
...@@ -44,8 +44,6 @@ import java.util.List; ...@@ -44,8 +44,6 @@ import java.util.List;
import jdk.test.lib.classloader.ClassUnloadCommon; import jdk.test.lib.classloader.ClassUnloadCommon;
public class ClassLoadUnloadTest { public class ClassLoadUnloadTest {
private static OutputAnalyzer out;
private static ProcessBuilder pb;
private static class ClassUnloadTestMain { private static class ClassUnloadTestMain {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
String className = "test.Empty"; String className = "test.Empty";
...@@ -56,63 +54,62 @@ public class ClassLoadUnloadTest { ...@@ -56,63 +54,62 @@ public class ClassLoadUnloadTest {
} }
} }
static void checkFor(String... outputStrings) throws Exception { static void checkFor(OutputAnalyzer output, String... outputStrings) throws Exception {
out = new OutputAnalyzer(pb.start());
for (String s: outputStrings) { for (String s: outputStrings) {
out.shouldContain(s); output.shouldContain(s);
} }
out.shouldHaveExitValue(0);
} }
static void checkAbsent(String... outputStrings) throws Exception { static void checkAbsent(OutputAnalyzer output, String... outputStrings) throws Exception {
out = new OutputAnalyzer(pb.start());
for (String s: outputStrings) { for (String s: outputStrings) {
out.shouldNotContain(s); output.shouldNotContain(s);
} }
out.shouldHaveExitValue(0);
} }
// Use the same command-line heap size setting as ../ClassUnload/UnloadTest.java // Use the same command-line heap size setting as ../ClassUnload/UnloadTest.java
static ProcessBuilder exec(String... args) throws Exception { static OutputAnalyzer exec(String... args) throws Exception {
List<String> argsList = new ArrayList<>(); List<String> argsList = new ArrayList<>();
Collections.addAll(argsList, args); Collections.addAll(argsList, args);
Collections.addAll(argsList, "-Xmn8m"); Collections.addAll(argsList, "-Xmn8m", "-Dtest.class.path=" + System.getProperty("test.class.path", "."),
Collections.addAll(argsList, "-Dtest.class.path=" + System.getProperty("test.class.path", ".")); "-XX:+ClassUnloading", ClassUnloadTestMain.class.getName());
Collections.addAll(argsList, "-XX:+ClassUnloading"); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(argsList);
Collections.addAll(argsList, ClassUnloadTestMain.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
return ProcessTools.createJavaProcessBuilder(argsList); output.shouldHaveExitValue(0);
return output;
} }
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
OutputAnalyzer output;
// -Xlog:class+unload=info // -Xlog:class+unload=info
pb = exec("-Xlog:class+unload=info"); output = exec("-Xlog:class+unload=info");
checkFor("[class,unload]", "unloading class"); checkFor(output, "[class,unload]", "unloading class");
// -Xlog:class+unload=off // -Xlog:class+unload=off
pb = exec("-Xlog:class+unload=off"); output = exec("-Xlog:class+unload=off");
checkAbsent("[class,unload]"); checkAbsent(output,"[class,unload]");
// -Xlog:class+load=info // -Xlog:class+load=info
pb = exec("-Xlog:class+load=info"); output = exec("-Xlog:class+load=info");
checkFor("[class,load]", "java.lang.Object", "source:"); checkFor(output,"[class,load]", "java.lang.Object", "source:");
// -Xlog:class+load=debug // -Xlog:class+load=debug
pb = exec("-Xlog:class+load=debug"); output = exec("-Xlog:class+load=debug");
checkFor("[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:"); checkFor(output,"[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:");
// -Xlog:class+load=off // -Xlog:class+load=off
pb = exec("-Xlog:class+load=off"); output = exec("-Xlog:class+load=off");
checkAbsent("[class,load]"); checkAbsent(output,"[class,load]");
// -verbose:class // -verbose:class
pb = exec("-verbose:class"); output = exec("-verbose:class");
checkFor("[class,load]", "java.lang.Object", "source:"); checkFor(output,"[class,load]", "java.lang.Object", "source:");
checkFor("[class,unload]", "unloading class"); checkFor(output,"[class,unload]", "unloading class");
// -Xlog:class+loader+data=trace // -Xlog:class+loader+data=trace
pb = exec("-Xlog:class+loader+data=trace"); output = exec("-Xlog:class+loader+data=trace");
checkFor("[class,loader,data]", "create loader data"); checkFor(output, "[class,loader,data]", "create loader data");
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment