equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
141 |
141 |
142 /** |
142 /** |
143 * Execute the given command in the target VM. |
143 * Execute the given command in the target VM. |
144 */ |
144 */ |
145 InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException { |
145 InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException { |
146 assert args.length <= 3; // includes null |
146 assert args.length <= 4; // includes null |
147 |
147 |
148 // did we detach? |
148 // did we detach? |
149 synchronized (this) { |
149 synchronized (this) { |
150 if (socket_path == null) { |
150 if (socket_path == null) { |
151 throw new IOException("Detached from target VM"); |
151 throw new IOException("Detached from target VM"); |
169 // <ver> <cmd> <args...> |
169 // <ver> <cmd> <args...> |
170 try { |
170 try { |
171 writeString(s, PROTOCOL_VERSION); |
171 writeString(s, PROTOCOL_VERSION); |
172 writeString(s, cmd); |
172 writeString(s, cmd); |
173 |
173 |
174 for (int i=0; i<3; i++) { |
174 for (int i = 0; i < 4; i++) { |
175 if (i < args.length && args[i] != null) { |
175 if (i < args.length && args[i] != null) { |
176 writeString(s, (String)args[i]); |
176 writeString(s, (String)args[i]); |
177 } else { |
177 } else { |
178 writeString(s, ""); |
178 writeString(s, ""); |
179 } |
179 } |