1 /*
2 * Copyright (c) 2005, 2006, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
178 // returned input stream.
179 public InputStream dumpHeap(Object ... args) throws IOException {
180 return executeCommand("dumpheap", args);
181 }
182
183 // Heap histogram (heap inspection in HotSpot)
184 public InputStream heapHisto(Object ... args) throws IOException {
185 return executeCommand("inspectheap", args);
186 }
187
188 // set JVM command line flag
189 public InputStream setFlag(String name, String value) throws IOException {
190 return executeCommand("setflag", name, value);
191 }
192
193 // print command line flag
194 public InputStream printFlag(String name) throws IOException {
195 return executeCommand("printflag", name);
196 }
197
198 // -- Supporting methods
199
200
201 /*
202 * Execute the given command in the target VM - specific platform
203 * implementation must implement this.
204 */
205 abstract InputStream execute(String cmd, Object ... args)
206 throws AgentLoadException, IOException;
207
208 /*
209 * Convenience method for simple commands
210 */
211 private InputStream executeCommand(String cmd, Object ... args) throws IOException {
212 try {
213 return execute(cmd, args);
214 } catch (AgentLoadException x) {
215 throw new InternalError("Should not get here", x);
216 }
217 }
|
1 /*
2 * Copyright (c) 2005, 2011, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
178 // returned input stream.
179 public InputStream dumpHeap(Object ... args) throws IOException {
180 return executeCommand("dumpheap", args);
181 }
182
183 // Heap histogram (heap inspection in HotSpot)
184 public InputStream heapHisto(Object ... args) throws IOException {
185 return executeCommand("inspectheap", args);
186 }
187
188 // set JVM command line flag
189 public InputStream setFlag(String name, String value) throws IOException {
190 return executeCommand("setflag", name, value);
191 }
192
193 // print command line flag
194 public InputStream printFlag(String name) throws IOException {
195 return executeCommand("printflag", name);
196 }
197
198 public InputStream executeJCmd(String command) throws IOException {
199 return executeCommand("jcmd", command);
200 }
201
202 // -- Supporting methods
203
204
205 /*
206 * Execute the given command in the target VM - specific platform
207 * implementation must implement this.
208 */
209 abstract InputStream execute(String cmd, Object ... args)
210 throws AgentLoadException, IOException;
211
212 /*
213 * Convenience method for simple commands
214 */
215 private InputStream executeCommand(String cmd, Object ... args) throws IOException {
216 try {
217 return execute(cmd, args);
218 } catch (AgentLoadException x) {
219 throw new InternalError("Should not get here", x);
220 }
221 }
|