# HG changeset patch # User akulyakh # Date 1461666152 -10800 # Node ID 9e58203ef0e28dc87c6ff77c85b72ef298363666 # Parent 4819f68a93a6024ec88a2ed7bfa745c4660f94c5 8153992: Some hotspot tests fail on compact2 due to an unnecessary test library dependency Summary: Removing unnecessary dependency on java.management from the ProcessTool.getProcessId() Reviewed-by: mchung diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java --- a/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java Tue Apr 26 13:22:32 2016 +0300 @@ -77,7 +77,7 @@ throw new Error("TESTBUG: incorrect argument: "+ args[1]); } } - int pid; + long pid; try { pid = ProcessTools.getProcessId(); } catch (Exception e) { diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java --- a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java Tue Apr 26 13:22:32 2016 +0300 @@ -49,7 +49,7 @@ return; } - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); JDKToolLauncher jmap = JDKToolLauncher.create("jmap") .addToolArg("-heap") diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/gc/metaspace/PerfCounters.java --- a/hotspot/test/gc/metaspace/PerfCounters.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/gc/metaspace/PerfCounters.java Tue Apr 26 13:22:32 2016 +0300 @@ -40,7 +40,7 @@ static { try { - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); VmIdentifier vmId = new VmIdentifier(pid); MonitoredHost host = MonitoredHost.getMonitoredHost(vmId); vm = host.getMonitoredVm(vmId); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/CommandLine/PrintTouchedMethods.java --- a/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java Tue Apr 26 13:22:32 2016 +0300 @@ -106,7 +106,7 @@ output.shouldHaveExitValue(0); // Test jcmd PrintTouchedMethods VM.print_touched_methods - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); pb = new ProcessBuilder(); pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.print_touched_methods"}); output = new OutputAnalyzer(pb.start()); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/BaselineWithParameter.java --- a/hotspot/test/runtime/NMT/BaselineWithParameter.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/BaselineWithParameter.java Tue Apr 26 13:22:32 2016 +0300 @@ -38,7 +38,7 @@ public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); OutputAnalyzer output; ProcessBuilder pb = new ProcessBuilder(); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/JcmdBaselineDetail.java --- a/hotspot/test/runtime/NMT/JcmdBaselineDetail.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/JcmdBaselineDetail.java Tue Apr 26 13:22:32 2016 +0300 @@ -37,7 +37,7 @@ public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); OutputAnalyzer output; ProcessBuilder pb = new ProcessBuilder(); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/JcmdDetailDiff.java --- a/hotspot/test/runtime/NMT/JcmdDetailDiff.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/JcmdDetailDiff.java Tue Apr 26 13:22:32 2016 +0300 @@ -45,7 +45,7 @@ ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); long commitSize = 128 * 1024; long reserveSize = 256 * 1024; diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/JcmdScale.java --- a/hotspot/test/runtime/NMT/JcmdScale.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/JcmdScale.java Tue Apr 26 13:22:32 2016 +0300 @@ -39,7 +39,7 @@ ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"}); output = new OutputAnalyzer(pb.start()); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/JcmdScaleDetail.java --- a/hotspot/test/runtime/NMT/JcmdScaleDetail.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/JcmdScaleDetail.java Tue Apr 26 13:22:32 2016 +0300 @@ -39,7 +39,7 @@ ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"}); output = new OutputAnalyzer(pb.start()); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/JcmdSummaryDiff.java --- a/hotspot/test/runtime/NMT/JcmdSummaryDiff.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/JcmdSummaryDiff.java Tue Apr 26 13:22:32 2016 +0300 @@ -45,7 +45,7 @@ ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); long commitSize = 128 * 1024; long reserveSize = 256 * 1024; diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java --- a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java Tue Apr 26 13:22:32 2016 +0300 @@ -60,7 +60,7 @@ } // Grab my own PID - pid = Integer.toString(ProcessTools.getProcessId()); + pid = Long.toString(ProcessTools.getProcessId()); jcmdCommand("summary"); jcmdCommand("detail"); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/MallocRoundingReportTest.java --- a/hotspot/test/runtime/NMT/MallocRoundingReportTest.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/MallocRoundingReportTest.java Tue Apr 26 13:22:32 2016 +0300 @@ -46,7 +46,7 @@ WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); long[] additionalBytes = {0, 1, 512, 650}; diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/MallocSiteHashOverflow.java --- a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java Tue Apr 26 13:22:32 2016 +0300 @@ -48,7 +48,7 @@ int MAX_HASH_SIZE = wb.NMTGetHashSize(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Verify that current tracking level is "detail" diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/MallocStressTest.java --- a/hotspot/test/runtime/NMT/MallocStressTest.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/MallocStressTest.java Tue Apr 26 13:22:32 2016 +0300 @@ -74,7 +74,7 @@ whiteBox = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); AllocThread[] alloc_threads = new AllocThread[256]; diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/MallocTestType.java --- a/hotspot/test/runtime/NMT/MallocTestType.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/MallocTestType.java Tue Apr 26 13:22:32 2016 +0300 @@ -44,7 +44,7 @@ WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/MallocTrackingVerify.java --- a/hotspot/test/runtime/NMT/MallocTrackingVerify.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/MallocTrackingVerify.java Tue Apr 26 13:22:32 2016 +0300 @@ -53,7 +53,7 @@ OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Random random = new Random(); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/ReleaseNoCommit.java --- a/hotspot/test/runtime/NMT/ReleaseNoCommit.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/ReleaseNoCommit.java Tue Apr 26 13:22:32 2016 +0300 @@ -49,7 +49,7 @@ ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); addr = wb.NMTReserveMemory(reserveSize); // Check for reserved diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/ShutdownTwice.java --- a/hotspot/test/runtime/NMT/ShutdownTwice.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/ShutdownTwice.java Tue Apr 26 13:22:32 2016 +0300 @@ -37,7 +37,7 @@ public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); OutputAnalyzer output; ProcessBuilder pb = new ProcessBuilder(); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/SummaryAfterShutdown.java --- a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java Tue Apr 26 13:22:32 2016 +0300 @@ -38,7 +38,7 @@ public static void main(String args[]) throws Exception { OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Run 'jcmd VM.native_memory shutdown' diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/SummarySanityCheck.java --- a/hotspot/test/runtime/NMT/SummarySanityCheck.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/SummarySanityCheck.java Tue Apr 26 13:22:32 2016 +0300 @@ -45,7 +45,7 @@ private static String jcmdout; public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/ThreadedMallocTestType.java --- a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java Tue Apr 26 13:22:32 2016 +0300 @@ -46,7 +46,7 @@ final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java --- a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java Tue Apr 26 13:22:32 2016 +0300 @@ -45,7 +45,7 @@ public static void main(String args[]) throws Exception { OutputAnalyzer output; - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread reserveThread = new Thread() { diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java --- a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java Tue Apr 26 13:22:32 2016 +0300 @@ -48,7 +48,7 @@ long reserveSize = 4 * 1024 * 1024; // 4096KB long addr; - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // reserve diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/NMT/VirtualAllocTestType.java --- a/hotspot/test/runtime/NMT/VirtualAllocTestType.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java Tue Apr 26 13:22:32 2016 +0300 @@ -46,7 +46,7 @@ long reserveSize = 256 * 1024; long addr; - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); addr = wb.NMTReserveMemory(reserveSize); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java --- a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java Tue Apr 26 13:22:32 2016 +0300 @@ -36,7 +36,7 @@ public class DumpSymbolAndStringTable { public static void main(String[] args) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.symboltable", "-verbose"}); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java --- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Tue Apr 26 13:22:32 2016 +0300 @@ -55,11 +55,11 @@ System.out.println("SA attach not expected to work - test skipped."); return; } - int pid = ProcessTools.getProcessId(); + long pid = ProcessTools.getProcessId(); JDKToolLauncher jmap = JDKToolLauncher.create("jmap") .addToolArg("-F") .addToolArg("-dump:live,format=b,file=" + dumpFile) - .addToolArg(Integer.toString(pid)); + .addToolArg(Long.toString(pid)); ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); OutputBuffer output = ProcessTools.getOutput(pb); Process p = pb.start(); diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java --- a/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java Tue Apr 26 13:22:32 2016 +0300 @@ -90,11 +90,8 @@ * * @return Process id */ - public static int getProcessId() throws Exception { - RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); - int pid = Integer.parseInt(runtime.getName().split("@")[0]); - - return pid; + public static long getProcessId() throws Exception { + return ProcessHandle.current().getPid(); } /** diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java --- a/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java Tue Apr 26 13:22:32 2016 +0300 @@ -55,7 +55,7 @@ File cmdFile = createTempFile(); writeCommandToTemporaryFile(cmd, cmdFile); - return Arrays.asList(jcmdBinary, Integer.toString(pid), + return Arrays.asList(jcmdBinary, Long.toString(pid), "-f", cmdFile.getAbsolutePath()); } diff -r 4819f68a93a6 -r 9e58203ef0e2 hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java --- a/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java Tue Apr 26 11:05:11 2016 +0200 +++ b/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java Tue Apr 26 13:22:32 2016 +0300 @@ -32,7 +32,7 @@ * Executes Diagnostic Commands on the target VM (specified by pid) using the jcmd tool */ public class PidJcmdExecutor extends JcmdExecutor { - protected final int pid; + protected final long pid; /** * Instantiates a new PidJcmdExecutor targeting the current VM @@ -53,11 +53,11 @@ */ public PidJcmdExecutor(String target) { super(); - pid = Integer.valueOf(target); + pid = Long.valueOf(target); } protected List createCommandLine(String cmd) throws CommandExecutorException { - return Arrays.asList(jcmdBinary, Integer.toString(pid), cmd); + return Arrays.asList(jcmdBinary, Long.toString(pid), cmd); } }