diff -r d2a0ec86d6ef -r 794e08f6dad4 hotspot/test/serviceability/sa/TestClassLoaderStats.java --- a/hotspot/test/serviceability/sa/TestClassLoaderStats.java Thu May 28 11:37:13 2015 -0700 +++ b/hotspot/test/serviceability/sa/TestClassLoaderStats.java Wed May 27 14:13:20 2015 +0200 @@ -24,11 +24,14 @@ import jdk.test.lib.Platform; import jdk.test.lib.ProcessTools; import jdk.test.lib.OutputAnalyzer; +import jdk.test.lib.apps.LingeredApp; /* * @test + * @library /../../test/lib/share/classes * @library /testlibrary * @build jdk.test.lib.* + * @build jdk.test.lib.apps.* * @run main TestClassLoaderStats */ public class TestClassLoaderStats { @@ -39,19 +42,27 @@ return; } - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( - "-XX:+UsePerfData", - "sun.jvm.hotspot.tools.ClassLoaderStats", - Integer.toString(ProcessTools.getProcessId())); - OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); - System.out.println(output.getOutput()); + LingeredApp app = null; + try { + app = LingeredApp.startApp(); - output.shouldHaveExitValue(0); - output.shouldContain("Debugger attached successfully."); - // The class loader stats header needs to be presented in the output: - output.shouldMatch("class_loader\\W+classes\\W+bytes\\W+parent_loader\\W+alive?\\W+type"); - output.stderrShouldNotMatch("[E|e]xception"); - output.stderrShouldNotMatch("[E|e]rror"); + System.out.println("Attaching sun.jvm.hotspot.tools.ClassLoaderStats to " + app.getPid()); + ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder( + "-XX:+UsePerfData", + "sun.jvm.hotspot.tools.ClassLoaderStats", + Long.toString(app.getPid())); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println(output.getOutput()); + + output.shouldHaveExitValue(0); + output.shouldContain("Debugger attached successfully."); + // The class loader stats header needs to be presented in the output: + output.shouldMatch("class_loader\\W+classes\\W+bytes\\W+parent_loader\\W+alive?\\W+type"); + output.stderrShouldNotMatch("[E|e]xception"); + output.stderrShouldNotMatch("[E|e]rror"); + } finally { + app.stopApp(); + } } }