Mercurial > hg > graal-compiler
annotate test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java @ 9399:25c2e9b29e97
Add comments to write barrier verification phase
author | Christos Kotselidis <christos.kotselidis@oracle.com> |
---|---|
date | Thu, 25 Apr 2013 12:25:38 +0200 |
parents | 8bf6338972ce |
children | 8ef918538e22 |
rev | line source |
---|---|
8856
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
1 /* |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
4 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
8 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
13 * accompanied this code). |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
14 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
18 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
21 * questions. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
22 */ |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
23 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
24 package com.oracle.java.testlibrary; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
25 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
26 import java.util.List; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
27 import java.util.ArrayList; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
28 import java.util.Arrays; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
29 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
30 import com.oracle.java.testlibrary.JDKToolFinder; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
31 import com.oracle.java.testlibrary.ProcessTools; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
32 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
33 /** |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
34 * A utility for constructing command lines for starting JDK tool processes. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
35 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
36 * The JDKToolLauncher can in particular be combined with a |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
37 * java.lang.ProcessBuilder to easily run a JDK tool. For example, the |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
38 * following code run {@code jmap -heap} against a process with GC logging |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
39 * turned on for the {@code jmap} process: |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
40 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
41 * <pre> |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
42 * {@code |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
43 * JDKToolLauncher jmap = JDKToolLauncher.create("jmap") |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
44 * .addVMArg("-XX:+PrintGC"); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
45 * .addVMArg("-XX:+PrintGCDetails") |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
46 * .addToolArg("-heap") |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
47 * .addToolArg(pid); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
48 * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
49 * Process p = pb.start(); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
50 * } |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
51 * </pre> |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
52 */ |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
53 public class JDKToolLauncher { |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
54 private final String executable; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
55 private final List<String> vmArgs = new ArrayList<String>(); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
56 private final List<String> toolArgs = new ArrayList<String>(); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
57 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
58 private JDKToolLauncher(String tool) { |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
59 executable = JDKToolFinder.getJDKTool(tool); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
60 vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs())); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
61 } |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
62 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
63 /** |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
64 * Creates a new JDKToolLauncher for the specified tool. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
65 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
66 * @param tool The name of the tool |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
67 * @return A new JDKToolLauncher |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
68 */ |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
69 public static JDKToolLauncher create(String tool) { |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
70 return new JDKToolLauncher(tool); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
71 } |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
72 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
73 /** |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
74 * Adds an argument to the JVM running the tool. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
75 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
76 * The JVM arguments are passed to the underlying JVM running the tool. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
77 * Arguments will automatically be prepended with "-J". |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
78 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
79 * Any platform specific arguments required for running the tool are |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
80 * automatically added. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
81 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
82 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
83 * @param arg The argument to VM running the tool |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
84 * @return The JDKToolLauncher instance |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
85 */ |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
86 public JDKToolLauncher addVMArg(String arg) { |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
87 vmArgs.add("-J" + arg); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
88 return this; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
89 } |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
90 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
91 /** |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
92 * Adds an argument to the tool. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
93 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
94 * @param arg The argument to the tool |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
95 * @return The JDKToolLauncher instance |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
96 */ |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
97 public JDKToolLauncher addToolArg(String arg) { |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
98 toolArgs.add(arg); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
99 return this; |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
100 } |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
101 |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
102 /** |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
103 * Returns the command that can be used for running the tool. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
104 * |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
105 * @return An array whose elements are the arguments of the command. |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
106 */ |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
107 public String[] getCommand() { |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
108 List<String> command = new ArrayList<String>(); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
109 command.add(executable); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
110 command.addAll(vmArgs); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
111 command.addAll(toolArgs); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
112 return command.toArray(new String[command.size()]); |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
113 } |
8bf6338972ce
8009408: gc/metaspace/ClassMetaspaceSizeInJmapHeap.java fails with "exit code 1"
ehelin
parents:
diff
changeset
|
114 } |