changeset 38089:9e58203ef0e2

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
author akulyakh
date Tue, 26 Apr 2016 13:22:32 +0300
parents 4819f68a93a6
children 34d0dd634032
files hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java hotspot/test/gc/metaspace/PerfCounters.java hotspot/test/runtime/CommandLine/PrintTouchedMethods.java hotspot/test/runtime/NMT/BaselineWithParameter.java hotspot/test/runtime/NMT/JcmdBaselineDetail.java hotspot/test/runtime/NMT/JcmdDetailDiff.java hotspot/test/runtime/NMT/JcmdScale.java hotspot/test/runtime/NMT/JcmdScaleDetail.java hotspot/test/runtime/NMT/JcmdSummaryDiff.java hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java hotspot/test/runtime/NMT/MallocRoundingReportTest.java hotspot/test/runtime/NMT/MallocSiteHashOverflow.java hotspot/test/runtime/NMT/MallocStressTest.java hotspot/test/runtime/NMT/MallocTestType.java hotspot/test/runtime/NMT/MallocTrackingVerify.java hotspot/test/runtime/NMT/ReleaseNoCommit.java hotspot/test/runtime/NMT/ShutdownTwice.java hotspot/test/runtime/NMT/SummaryAfterShutdown.java hotspot/test/runtime/NMT/SummarySanityCheck.java hotspot/test/runtime/NMT/ThreadedMallocTestType.java hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java hotspot/test/runtime/NMT/VirtualAllocTestType.java hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java
diffstat 29 files changed, 33 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- 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) {
--- 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")
--- 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);
--- 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());
--- 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();
--- 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();
--- 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;
--- 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());
--- 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());
--- 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;
--- 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");
--- 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};
--- 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"
--- 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];
--- 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
--- 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();
--- 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
--- 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();
--- 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 <pid> VM.native_memory shutdown'
--- 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();
 
--- 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() {
--- 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() {
--- 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
--- 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);
--- 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"});
--- 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();
--- 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();
   }
 
   /**
--- 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());
     }
 
--- 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<String> createCommandLine(String cmd) throws CommandExecutorException {
-        return Arrays.asList(jcmdBinary, Integer.toString(pid), cmd);
+        return Arrays.asList(jcmdBinary, Long.toString(pid), cmd);
     }
 
 }