21 * questions.
22 */
23
24 package jdk.testlibrary;
25
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.List;
29
30 /**
31 * A utility for constructing command lines for starting JDK tool processes.
32 *
33 * The JDKToolLauncher can in particular be combined with a
34 * java.lang.ProcessBuilder to easily run a JDK tool. For example, the following
35 * code run {@code jmap -heap} against a process with GC logging turned on for
36 * the {@code jmap} process:
37 *
38 * <pre>
39 * {@code
40 * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
41 * .addVMArg("-XX:+PrintGC");
42 * .addVMArg("-XX:+PrintGCDetails")
43 * .addToolArg("-heap")
44 * .addToolArg(pid);
45 * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
46 * Process p = pb.start();
47 * }
48 * </pre>
49 */
50 public class JDKToolLauncher {
51 private final String executable;
52 private final List<String> vmArgs = new ArrayList<String>();
53 private final List<String> toolArgs = new ArrayList<String>();
54
55 private JDKToolLauncher(String tool, boolean useCompilerJDK) {
56 if (useCompilerJDK) {
57 executable = JDKToolFinder.getJDKTool(tool);
58 } else {
59 executable = JDKToolFinder.getTestJDKTool(tool);
60 }
61 vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
62 }
|
21 * questions.
22 */
23
24 package jdk.testlibrary;
25
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import java.util.List;
29
30 /**
31 * A utility for constructing command lines for starting JDK tool processes.
32 *
33 * The JDKToolLauncher can in particular be combined with a
34 * java.lang.ProcessBuilder to easily run a JDK tool. For example, the following
35 * code run {@code jmap -heap} against a process with GC logging turned on for
36 * the {@code jmap} process:
37 *
38 * <pre>
39 * {@code
40 * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
41 * .addVMArg("-Xlog:gc*=debug")
42 * .addToolArg("-heap")
43 * .addToolArg(pid);
44 * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
45 * Process p = pb.start();
46 * }
47 * </pre>
48 */
49 public class JDKToolLauncher {
50 private final String executable;
51 private final List<String> vmArgs = new ArrayList<String>();
52 private final List<String> toolArgs = new ArrayList<String>();
53
54 private JDKToolLauncher(String tool, boolean useCompilerJDK) {
55 if (useCompilerJDK) {
56 executable = JDKToolFinder.getJDKTool(tool);
57 } else {
58 executable = JDKToolFinder.getTestJDKTool(tool);
59 }
60 vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
61 }
|