1 /*
2 * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
108 {
109 runit(class_name, null);
110 }
111
112 /*
113 * Execute a process with an -agentpath or -agentlib command option
114 * plus any set of other java options.
115 */
116 public void runit(String class_name, String vm_options[])
117 {
118 String jre_home = System.getProperty("java.home");
119 String sdk_home = (jre_home.endsWith("jre") ?
120 (jre_home + File.separator + "..") :
121 jre_home );
122 String cdir = System.getProperty("test.classes", ".");
123 String os_arch = System.getProperty("os.arch");
124 String os_name = System.getProperty("os.name");
125 String libprefix = os_name.contains("Windows")?"":"lib";
126 String libsuffix = os_name.contains("Windows")?".dll":
127 os_name.contains("OS X")?".dylib":".so";
128 boolean d64 = ( os_name.contains("Solaris") ||
129 os_name.contains("SunOS") )
130 && ( os_arch.equals("sparcv9") ||
131 os_arch.equals("amd64"));
132 boolean hprof = demo_name.equals("hprof");
133 String isa_dir = d64?(File.separator+os_arch):"";
134 String java = jre_home
135 + File.separator + "bin" + isa_dir
136 + File.separator + "java";
137 /* Array of strings to be passed in for exec:
138 * 1. java
139 * 2. -Dtest.classes=.
140 * 3. -d64 (optional)
141 * 4. -Xcheck:jni (Just because it finds bugs)
142 * 5. -Xverify:all (Make sure verification is on full blast)
143 * 6. -agent
144 * vm_options
145 * 7+i. classname
146 */
147 int nvm_options = 0;
148 if ( vm_options != null ) nvm_options = vm_options.length;
149 String cmd[] = new String[1 + (d64?1:0) + 7 + nvm_options];
150 String cmdLine;
151 int exitStatus;
152 int i,j;
153
154 i = 0;
155 cmdLine = "";
161 cmdLine += " ";
162 cmdLine += (cmd[i++] = "-Dtest.classes=" + cdir);
163 if ( d64 ) {
164 cmdLine += " ";
165 cmdLine += (cmd[i++] = "-d64");
166 }
167 cmdLine += " ";
168 cmdLine += (cmd[i++] = "-Xcheck:jni");
169 cmdLine += " ";
170 cmdLine += (cmd[i++] = "-Xverify:all");
171 if ( hprof ) {
172 /* Load hprof with -agentlib since it's part of jre */
173 cmdLine += " ";
174 cmdLine += (cmd[i++] = "-agentlib:" + demo_name
175 + (demo_options.equals("")?"":("="+demo_options)));
176 } else {
177 String libname = sdk_home
178 + File.separator + "demo"
179 + File.separator + "jvmti"
180 + File.separator + demo_name
181 + File.separator + "lib" + isa_dir
182 + File.separator + libprefix + demo_name + libsuffix;
183 cmdLine += " ";
184 cmdLine += (cmd[i++] = "-agentpath:" + libname
185 + (demo_options.equals("")?"":("="+demo_options)));
186 }
187 /* Add any special VM options */
188 for ( j = 0; j < nvm_options; j++ ) {
189 cmdLine += " ";
190 cmdLine += (cmd[i++] = vm_options[j]);
191 }
192 /* Add classname */
193 cmdLine += " ";
194 cmdLine += (cmd[i++] = class_name);
195
196 /* Begin process */
197 Process p;
198
199 System.out.println("Starting: " + cmdLine);
200 try {
201 p = Runtime.getRuntime().exec(cmd);
|
1 /*
2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
108 {
109 runit(class_name, null);
110 }
111
112 /*
113 * Execute a process with an -agentpath or -agentlib command option
114 * plus any set of other java options.
115 */
116 public void runit(String class_name, String vm_options[])
117 {
118 String jre_home = System.getProperty("java.home");
119 String sdk_home = (jre_home.endsWith("jre") ?
120 (jre_home + File.separator + "..") :
121 jre_home );
122 String cdir = System.getProperty("test.classes", ".");
123 String os_arch = System.getProperty("os.arch");
124 String os_name = System.getProperty("os.name");
125 String libprefix = os_name.contains("Windows")?"":"lib";
126 String libsuffix = os_name.contains("Windows")?".dll":
127 os_name.contains("OS X")?".dylib":".so";
128 boolean d64 = os_name.contains("Solaris");
129 boolean hprof = demo_name.equals("hprof");
130 String java = jre_home
131 + File.separator + "bin"
132 + File.separator + "java";
133 /* Array of strings to be passed in for exec:
134 * 1. java
135 * 2. -Dtest.classes=.
136 * 3. -d64 (optional)
137 * 4. -Xcheck:jni (Just because it finds bugs)
138 * 5. -Xverify:all (Make sure verification is on full blast)
139 * 6. -agent
140 * vm_options
141 * 7+i. classname
142 */
143 int nvm_options = 0;
144 if ( vm_options != null ) nvm_options = vm_options.length;
145 String cmd[] = new String[1 + (d64?1:0) + 7 + nvm_options];
146 String cmdLine;
147 int exitStatus;
148 int i,j;
149
150 i = 0;
151 cmdLine = "";
157 cmdLine += " ";
158 cmdLine += (cmd[i++] = "-Dtest.classes=" + cdir);
159 if ( d64 ) {
160 cmdLine += " ";
161 cmdLine += (cmd[i++] = "-d64");
162 }
163 cmdLine += " ";
164 cmdLine += (cmd[i++] = "-Xcheck:jni");
165 cmdLine += " ";
166 cmdLine += (cmd[i++] = "-Xverify:all");
167 if ( hprof ) {
168 /* Load hprof with -agentlib since it's part of jre */
169 cmdLine += " ";
170 cmdLine += (cmd[i++] = "-agentlib:" + demo_name
171 + (demo_options.equals("")?"":("="+demo_options)));
172 } else {
173 String libname = sdk_home
174 + File.separator + "demo"
175 + File.separator + "jvmti"
176 + File.separator + demo_name
177 + File.separator + "lib"
178 + File.separator + libprefix + demo_name + libsuffix;
179 cmdLine += " ";
180 cmdLine += (cmd[i++] = "-agentpath:" + libname
181 + (demo_options.equals("")?"":("="+demo_options)));
182 }
183 /* Add any special VM options */
184 for ( j = 0; j < nvm_options; j++ ) {
185 cmdLine += " ";
186 cmdLine += (cmd[i++] = vm_options[j]);
187 }
188 /* Add classname */
189 cmdLine += " ";
190 cmdLine += (cmd[i++] = class_name);
191
192 /* Begin process */
193 Process p;
194
195 System.out.println("Starting: " + cmdLine);
196 try {
197 p = Runtime.getRuntime().exec(cmd);
|