mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-03 19:48:46 +00:00
8171318: serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java fails latest Jigsaw integration
Reviewed-by: sspitsyn, dholmes
This commit is contained in:
parent
2d444d6f19
commit
89bfef80d0
@ -21,12 +21,9 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
import sun.management.VMManagement;
|
||||
|
||||
@ -38,7 +35,7 @@ public class JMapHProfLargeHeapProc {
|
||||
buildLargeHeap(args);
|
||||
|
||||
// Print our pid on stdout
|
||||
System.out.println("PID[" + getProcessId() + "]");
|
||||
System.out.println("PID[" + ProcessTools.getProcessId() + "]");
|
||||
|
||||
// Wait for input before termination
|
||||
System.in.read();
|
||||
@ -50,22 +47,4 @@ public class JMapHProfLargeHeapProc {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getProcessId() throws Exception {
|
||||
|
||||
// Get the current process id using a reflection hack
|
||||
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
|
||||
Field jvm = runtime.getClass().getDeclaredField("jvm");
|
||||
|
||||
jvm.setAccessible(true);
|
||||
VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
|
||||
|
||||
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
|
||||
|
||||
pid_method.setAccessible(true);
|
||||
|
||||
int pid = (Integer) pid_method.invoke(mgmt);
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -90,6 +90,9 @@ public class JMapHProfLargeHeapTest {
|
||||
try (Scanner largeHeapScanner = new Scanner(
|
||||
largeHeapProc.getInputStream());) {
|
||||
String pidstring = null;
|
||||
if (!largeHeapScanner.hasNext()) {
|
||||
throw new RuntimeException ("Test failed: could not open largeHeapScanner.");
|
||||
}
|
||||
while ((pidstring = largeHeapScanner.findInLine("PID\\[[0-9].*\\]")) == null) {
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user