69 output.shouldHaveExitValue(0); 70 } 71 72 private static void run(boolean useArchive) throws Exception { 73 String flag = useArchive ? "auto" : "off"; 74 75 // (1) Launch the attachee process 76 ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder( 77 "-XX:+UnlockDiagnosticVMOptions", 78 "-XX:SharedArchiveFile=" + jsaName, 79 "-Xshare:" + flag, 80 "-showversion", // so we can see "sharing" in the output 81 "SASymbolTableTestAttachee"); 82 83 final Process p = attachee.start(); 84 85 // (2) Launch the agent process 86 long pid = p.getPid(); 87 System.out.println("Attaching agent " + pid); 88 ProcessBuilder tool = ProcessTools.createJavaProcessBuilder( 89 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", 90 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", 91 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", 92 "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", 93 "SASymbolTableTestAgent", 94 Long.toString(pid)); 95 OutputAnalyzer output = ProcessTools.executeProcess(tool); 96 System.out.println(output.getOutput()); 97 output.shouldHaveExitValue(0); 98 99 Thread t = new Thread() { 100 public void run() { 101 try { 102 OutputAnalyzer output = new OutputAnalyzer(p); 103 System.out.println("STDOUT["); 104 System.out.print(output.getStdout()); 105 System.out.println("]"); 106 System.out.println("STDERR["); 107 System.out.print(output.getStderr()); 108 System.out.println("]"); 109 } catch (Throwable t) { 110 t.printStackTrace(); 111 } 112 } | 69 output.shouldHaveExitValue(0); 70 } 71 72 private static void run(boolean useArchive) throws Exception { 73 String flag = useArchive ? "auto" : "off"; 74 75 // (1) Launch the attachee process 76 ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder( 77 "-XX:+UnlockDiagnosticVMOptions", 78 "-XX:SharedArchiveFile=" + jsaName, 79 "-Xshare:" + flag, 80 "-showversion", // so we can see "sharing" in the output 81 "SASymbolTableTestAttachee"); 82 83 final Process p = attachee.start(); 84 85 // (2) Launch the agent process 86 long pid = p.getPid(); 87 System.out.println("Attaching agent " + pid); 88 ProcessBuilder tool = ProcessTools.createJavaProcessBuilder( 89 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", 90 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", 91 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", 92 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", 93 "SASymbolTableTestAgent", 94 Long.toString(pid)); 95 OutputAnalyzer output = ProcessTools.executeProcess(tool); 96 System.out.println(output.getOutput()); 97 output.shouldHaveExitValue(0); 98 99 Thread t = new Thread() { 100 public void run() { 101 try { 102 OutputAnalyzer output = new OutputAnalyzer(p); 103 System.out.println("STDOUT["); 104 System.out.print(output.getStdout()); 105 System.out.println("]"); 106 System.out.println("STDERR["); 107 System.out.print(output.getStderr()); 108 System.out.println("]"); 109 } catch (Throwable t) { 110 t.printStackTrace(); 111 } 112 } |