author | joehw |
Wed, 26 Aug 2015 10:16:04 -0700 | |
changeset 32328 | a09e22b759a7 |
parent 32210 | 958d823579c3 |
child 34894 | 3248b89d1921 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
24363
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
2 |
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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 |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.attach; |
|
27 |
||
28 |
import com.sun.tools.attach.spi.AttachProvider; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.List; |
|
31 |
import java.util.Properties; |
|
32 |
import java.io.IOException; |
|
33 |
||
34 |
||
35 |
/** |
|
36 |
* A Java virtual machine. |
|
37 |
* |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
38 |
* <p> A {@code VirtualMachine} represents a Java virtual machine to which this |
2 | 39 |
* Java virtual machine has attached. The Java virtual machine to which it is |
40 |
* attached is sometimes called the <i>target virtual machine</i>, or <i>target VM</i>. |
|
41 |
* An application (typically a tool such as a managemet console or profiler) uses a |
|
42 |
* VirtualMachine to load an agent into the target VM. For example, a profiler tool |
|
43 |
* written in the Java Language might attach to a running application and load its |
|
44 |
* profiler agent to profile the running application. </p> |
|
45 |
* |
|
46 |
* <p> A VirtualMachine is obtained by invoking the {@link #attach(String) attach} method |
|
47 |
* with an identifier that identifies the target virtual machine. The identifier is |
|
48 |
* implementation-dependent but is typically the process identifier (or pid) in |
|
49 |
* environments where each Java virtual machine runs in its own operating system process. |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
50 |
* Alternatively, a {@code VirtualMachine} instance is obtained by invoking the |
2 | 51 |
* {@link #attach(VirtualMachineDescriptor) attach} method with a {@link |
52 |
* com.sun.tools.attach.VirtualMachineDescriptor VirtualMachineDescriptor} obtained |
|
53 |
* from the list of virtual machine descriptors returned by the {@link #list list} method. |
|
54 |
* Once a reference to a virtual machine is obtained, the {@link #loadAgent loadAgent}, |
|
55 |
* {@link #loadAgentLibrary loadAgentLibrary}, and {@link #loadAgentPath loadAgentPath} |
|
56 |
* methods are used to load agents into target virtual machine. The {@link |
|
57 |
* #loadAgent loadAgent} method is used to load agents that are written in the Java |
|
58 |
* Language and deployed in a {@link java.util.jar.JarFile JAR file}. (See |
|
59 |
* {@link java.lang.instrument} for a detailed description on how these agents |
|
60 |
* are loaded and started). The {@link #loadAgentLibrary loadAgentLibrary} and |
|
61 |
* {@link #loadAgentPath loadAgentPath} methods are used to load agents that |
|
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
62 |
* are deployed either in a dynamic library or statically linked into the VM and make use of the <a |
2 | 63 |
* href="../../../../../../../../technotes/guides/jvmti/index.html">JVM Tools |
64 |
* Interface</a>. </p> |
|
65 |
* |
|
66 |
* <p> In addition to loading agents a VirtualMachine provides read access to the |
|
67 |
* {@link java.lang.System#getProperties() system properties} in the target VM. |
|
68 |
* This can be useful in some environments where properties such as |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
69 |
* {@code java.home}, {@code os.name}, or {@code os.arch} are |
2 | 70 |
* used to construct the path to agent that will be loaded into the target VM. |
71 |
* |
|
72 |
* <p> The following example demonstrates how VirtualMachine may be used:</p> |
|
73 |
* |
|
74 |
* <pre> |
|
75 |
* |
|
76 |
* // attach to target VM |
|
77 |
* VirtualMachine vm = VirtualMachine.attach("2177"); |
|
78 |
* |
|
24870
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
79 |
* // start management agent |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
80 |
* Properties props = new Properties(); |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
81 |
* props.put("com.sun.management.jmxremote.port", "5000"); |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
82 |
* vm.startManagementAgent(props); |
2 | 83 |
* |
84 |
* // detach |
|
85 |
* vm.detach(); |
|
86 |
* |
|
87 |
* </pre> |
|
88 |
* |
|
89 |
* <p> In this example we attach to a Java virtual machine that is identified by |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
90 |
* the process identifier {@code 2177}. Then the JMX management agent is |
24870
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
91 |
* started in the target process using the supplied arguments. Finally, the |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
92 |
* client detaches from the target VM. </p> |
2 | 93 |
* |
94 |
* <p> A VirtualMachine is safe for use by multiple concurrent threads. </p> |
|
95 |
* |
|
96 |
* @since 1.6 |
|
97 |
*/ |
|
98 |
||
20742
4ae78e8060d6
8008662: Add @jdk.Exported to JDK-specific/exported APIs
alanb
parents:
19594
diff
changeset
|
99 |
@jdk.Exported |
2 | 100 |
public abstract class VirtualMachine { |
101 |
private AttachProvider provider; |
|
102 |
private String id; |
|
103 |
private volatile int hash; // 0 => not computed |
|
104 |
||
105 |
/** |
|
106 |
* Initializes a new instance of this class. |
|
107 |
* |
|
108 |
* @param provider |
|
109 |
* The attach provider creating this class. |
|
110 |
* @param id |
|
111 |
* The abstract identifier that identifies the Java virtual machine. |
|
112 |
* |
|
113 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
114 |
* If {@code provider} or {@code id} is {@code null}. |
2 | 115 |
*/ |
116 |
protected VirtualMachine(AttachProvider provider, String id) { |
|
117 |
if (provider == null) { |
|
118 |
throw new NullPointerException("provider cannot be null"); |
|
119 |
} |
|
120 |
if (id == null) { |
|
121 |
throw new NullPointerException("id cannot be null"); |
|
122 |
} |
|
123 |
this.provider = provider; |
|
124 |
this.id = id; |
|
125 |
} |
|
126 |
||
127 |
/** |
|
128 |
* Return a list of Java virtual machines. |
|
129 |
* |
|
130 |
* <p> This method returns a list of Java {@link |
|
131 |
* com.sun.tools.attach.VirtualMachineDescriptor} elements. |
|
132 |
* The list is an aggregation of the virtual machine |
|
133 |
* descriptor lists obtained by invoking the {@link |
|
134 |
* com.sun.tools.attach.spi.AttachProvider#listVirtualMachines |
|
135 |
* listVirtualMachines} method of all installed |
|
136 |
* {@link com.sun.tools.attach.spi.AttachProvider attach providers}. |
|
137 |
* If there are no Java virtual machines known to any provider |
|
138 |
* then an empty list is returned. |
|
139 |
* |
|
140 |
* @return The list of virtual machine descriptors. |
|
141 |
*/ |
|
142 |
public static List<VirtualMachineDescriptor> list() { |
|
143 |
ArrayList<VirtualMachineDescriptor> l = |
|
144 |
new ArrayList<VirtualMachineDescriptor>(); |
|
145 |
List<AttachProvider> providers = AttachProvider.providers(); |
|
146 |
for (AttachProvider provider: providers) { |
|
147 |
l.addAll(provider.listVirtualMachines()); |
|
148 |
} |
|
149 |
return l; |
|
150 |
} |
|
151 |
||
152 |
/** |
|
153 |
* Attaches to a Java virtual machine. |
|
154 |
* |
|
155 |
* <p> This method obtains the list of attach providers by invoking the |
|
156 |
* {@link com.sun.tools.attach.spi.AttachProvider#providers() |
|
157 |
* AttachProvider.providers()} method. It then iterates overs the list |
|
158 |
* and invokes each provider's {@link |
|
159 |
* com.sun.tools.attach.spi.AttachProvider#attachVirtualMachine(java.lang.String) |
|
160 |
* attachVirtualMachine} method in turn. If a provider successfully |
|
161 |
* attaches then the iteration terminates, and the VirtualMachine created |
|
162 |
* by the provider that successfully attached is returned by this method. |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
163 |
* If the {@code attachVirtualMachine} method of all providers throws |
2 | 164 |
* {@link com.sun.tools.attach.AttachNotSupportedException AttachNotSupportedException} |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
165 |
* then this method also throws {@code AttachNotSupportedException}. |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
166 |
* This means that {@code AttachNotSupportedException} is thrown when |
2 | 167 |
* the identifier provided to this method is invalid, or the identifier |
168 |
* corresponds to a Java virtual machine that does not exist, or none |
|
169 |
* of the providers can attach to it. This exception is also thrown if |
|
170 |
* {@link com.sun.tools.attach.spi.AttachProvider#providers() |
|
171 |
* AttachProvider.providers()} returns an empty list. </p> |
|
172 |
* |
|
173 |
* @param id |
|
174 |
* The abstract identifier that identifies the Java virtual machine. |
|
175 |
* |
|
176 |
* @return A VirtualMachine representing the target VM. |
|
177 |
* |
|
178 |
* @throws SecurityException |
|
179 |
* If a security manager has been installed and it denies |
|
180 |
* {@link com.sun.tools.attach.AttachPermission AttachPermission} |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
181 |
* {@code ("attachVirtualMachine")}, or another permission |
2 | 182 |
* required by the implementation. |
183 |
* |
|
184 |
* @throws AttachNotSupportedException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
185 |
* If the {@code attachVirtualmachine} method of all installed |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
186 |
* providers throws {@code AttachNotSupportedException}, or |
2 | 187 |
* there aren't any providers installed. |
188 |
* |
|
189 |
* @throws IOException |
|
190 |
* If an I/O error occurs |
|
191 |
* |
|
192 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
193 |
* If {@code id} is {@code null}. |
2 | 194 |
*/ |
195 |
public static VirtualMachine attach(String id) |
|
196 |
throws AttachNotSupportedException, IOException |
|
197 |
{ |
|
198 |
if (id == null) { |
|
199 |
throw new NullPointerException("id cannot be null"); |
|
200 |
} |
|
201 |
List<AttachProvider> providers = AttachProvider.providers(); |
|
202 |
if (providers.size() == 0) { |
|
203 |
throw new AttachNotSupportedException("no providers installed"); |
|
204 |
} |
|
205 |
AttachNotSupportedException lastExc = null; |
|
206 |
for (AttachProvider provider: providers) { |
|
207 |
try { |
|
208 |
return provider.attachVirtualMachine(id); |
|
209 |
} catch (AttachNotSupportedException x) { |
|
210 |
lastExc = x; |
|
211 |
} |
|
212 |
} |
|
213 |
throw lastExc; |
|
214 |
} |
|
215 |
||
216 |
/** |
|
217 |
* Attaches to a Java virtual machine. |
|
218 |
* |
|
219 |
* <p> This method first invokes the {@link |
|
220 |
* com.sun.tools.attach.VirtualMachineDescriptor#provider() provider()} method |
|
221 |
* of the given virtual machine descriptor to obtain the attach provider. It |
|
222 |
* then invokes the attach provider's {@link |
|
223 |
* com.sun.tools.attach.spi.AttachProvider#attachVirtualMachine(VirtualMachineDescriptor) |
|
224 |
* attachVirtualMachine} to attach to the target VM. |
|
225 |
* |
|
226 |
* @param vmd |
|
227 |
* The virtual machine descriptor. |
|
228 |
* |
|
229 |
* @return A VirtualMachine representing the target VM. |
|
230 |
* |
|
231 |
* @throws SecurityException |
|
232 |
* If a security manager has been installed and it denies |
|
233 |
* {@link com.sun.tools.attach.AttachPermission AttachPermission} |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
234 |
* {@code ("attachVirtualMachine")}, or another permission |
2 | 235 |
* required by the implementation. |
236 |
* |
|
237 |
* @throws AttachNotSupportedException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
238 |
* If the attach provider's {@code attachVirtualmachine} |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
239 |
* throws {@code AttachNotSupportedException}. |
2 | 240 |
* |
241 |
* @throws IOException |
|
242 |
* If an I/O error occurs |
|
243 |
* |
|
244 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
245 |
* If {@code vmd} is {@code null}. |
2 | 246 |
*/ |
247 |
public static VirtualMachine attach(VirtualMachineDescriptor vmd) |
|
248 |
throws AttachNotSupportedException, IOException |
|
249 |
{ |
|
250 |
return vmd.provider().attachVirtualMachine(vmd); |
|
251 |
} |
|
252 |
||
253 |
/** |
|
254 |
* Detach from the virtual machine. |
|
255 |
* |
|
256 |
* <p> After detaching from the virtual machine, any further attempt to invoke |
|
257 |
* operations on that virtual machine will cause an {@link java.io.IOException |
|
258 |
* IOException} to be thrown. If an operation (such as {@link #loadAgent |
|
259 |
* loadAgent} for example) is in progress when this method is invoked then |
|
260 |
* the behaviour is implementation dependent. In other words, it is |
|
261 |
* implementation specific if the operation completes or throws |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
262 |
* {@code IOException}. |
2 | 263 |
* |
264 |
* <p> If already detached from the virtual machine then invoking this |
|
265 |
* method has no effect. </p> |
|
266 |
* |
|
267 |
* @throws IOException |
|
268 |
* If an I/O error occurs |
|
269 |
*/ |
|
270 |
public abstract void detach() throws IOException; |
|
271 |
||
272 |
/** |
|
273 |
* Returns the provider that created this virtual machine. |
|
274 |
* |
|
275 |
* @return The provider that created this virtual machine. |
|
276 |
*/ |
|
277 |
public final AttachProvider provider() { |
|
278 |
return provider; |
|
279 |
} |
|
280 |
||
281 |
/** |
|
282 |
* Returns the identifier for this Java virtual machine. |
|
283 |
* |
|
284 |
* @return The identifier for this Java virtual machine. |
|
285 |
*/ |
|
286 |
public final String id() { |
|
287 |
return id; |
|
288 |
} |
|
289 |
||
290 |
/** |
|
291 |
* Loads an agent library. |
|
292 |
* |
|
293 |
* <p> A <a href="../../../../../../../../technotes/guides/jvmti/index.html">JVM |
|
294 |
* TI</a> client is called an <i>agent</i>. It is developed in a native language. |
|
295 |
* A JVM TI agent is deployed in a platform specific manner but it is typically the |
|
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
296 |
* platform equivalent of a dynamic library. Alternatively, it may be statically linked into the VM. |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
297 |
* This method causes the given agent library to be loaded into the target |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
298 |
* VM (if not already loaded or if not statically linked into the VM). |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
299 |
* It then causes the target VM to invoke the {@code Agent_OnAttach} function |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
300 |
* or, for a statically linked agent named 'L', the {@code Agent_OnAttach_L} function |
2 | 301 |
* as specified in the |
302 |
* <a href="../../../../../../../../technotes/guides/jvmti/index.html"> JVM Tools |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
303 |
* Interface</a> specification. Note that the {@code Agent_OnAttach[_L]} |
2 | 304 |
* function is invoked even if the agent library was loaded prior to invoking |
305 |
* this method. |
|
306 |
* |
|
307 |
* <p> The agent library provided is the name of the agent library. It is interpreted |
|
308 |
* in the target virtual machine in an implementation-dependent manner. Typically an |
|
309 |
* implementation will expand the library name into an operating system specific file |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
310 |
* name. For example, on UNIX systems, the name {@code L} might be expanded to |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
311 |
* {@code libL.so}, and located using the search path specified by the |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
312 |
* {@code LD_LIBRARY_PATH} environment variable. If the agent named 'L' is |
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
313 |
* statically linked into the VM then the VM must export a function named |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
314 |
* {@code Agent_OnAttach_L}.</p> |
2 | 315 |
* |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
316 |
* <p> If the {@code Agent_OnAttach[_L]} function in the agent library returns |
2 | 317 |
* an error then an {@link com.sun.tools.attach.AgentInitializationException} is |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
318 |
* thrown. The return value from the {@code Agent_OnAttach[_L]} can then be |
2 | 319 |
* obtained by invoking the {@link |
320 |
* com.sun.tools.attach.AgentInitializationException#returnValue() returnValue} |
|
321 |
* method on the exception. </p> |
|
322 |
* |
|
323 |
* @param agentLibrary |
|
324 |
* The name of the agent library. |
|
325 |
* |
|
326 |
* @param options |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
327 |
* The options to provide to the {@code Agent_OnAttach[_L]} |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
328 |
* function (can be {@code null}). |
2 | 329 |
* |
330 |
* @throws AgentLoadException |
|
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
331 |
* If the agent library does not exist, the agent library is not |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
332 |
* statically linked with the VM, or the agent library cannot be |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
333 |
* loaded for another reason. |
2 | 334 |
* |
335 |
* @throws AgentInitializationException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
336 |
* If the {@code Agent_OnAttach[_L]} function returns an error. |
2 | 337 |
* |
338 |
* @throws IOException |
|
339 |
* If an I/O error occurs |
|
340 |
* |
|
341 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
342 |
* If {@code agentLibrary} is {@code null}. |
2 | 343 |
* |
344 |
* @see com.sun.tools.attach.AgentInitializationException#returnValue() |
|
345 |
*/ |
|
346 |
public abstract void loadAgentLibrary(String agentLibrary, String options) |
|
347 |
throws AgentLoadException, AgentInitializationException, IOException; |
|
348 |
||
349 |
/** |
|
350 |
* Loads an agent library. |
|
351 |
* |
|
352 |
* <p> This convenience method works as if by invoking: |
|
353 |
* |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
354 |
* <blockquote><code> |
2 | 355 |
* {@link #loadAgentLibrary(String, String) loadAgentLibrary}(agentLibrary, null); |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
356 |
* </code></blockquote> |
2 | 357 |
* |
358 |
* @param agentLibrary |
|
359 |
* The name of the agent library. |
|
360 |
* |
|
361 |
* @throws AgentLoadException |
|
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
362 |
* If the agent library does not exist, the agent library is not |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
363 |
* statically linked with the VM, or the agent library cannot be |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
364 |
* loaded for another reason. |
2 | 365 |
* |
366 |
* @throws AgentInitializationException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
367 |
* If the {@code Agent_OnAttach[_L]} function returns an error. |
2 | 368 |
* |
369 |
* @throws IOException |
|
370 |
* If an I/O error occurs |
|
371 |
* |
|
372 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
373 |
* If {@code agentLibrary} is {@code null}. |
2 | 374 |
*/ |
375 |
public void loadAgentLibrary(String agentLibrary) |
|
376 |
throws AgentLoadException, AgentInitializationException, IOException |
|
377 |
{ |
|
378 |
loadAgentLibrary(agentLibrary, null); |
|
379 |
} |
|
380 |
||
381 |
/** |
|
382 |
* Load a native agent library by full pathname. |
|
383 |
* |
|
384 |
* <p> A <a href="../../../../../../../../technotes/guides/jvmti/index.html">JVM |
|
385 |
* TI</a> client is called an <i>agent</i>. It is developed in a native language. |
|
386 |
* A JVM TI agent is deployed in a platform specific manner but it is typically the |
|
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
387 |
* platform equivalent of a dynamic library. Alternatively, the native |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
388 |
* library specified by the agentPath parameter may be statically |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
389 |
* linked with the VM. The parsing of the agentPath parameter into |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
390 |
* a statically linked library name is done in a platform |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
391 |
* specific manner in the VM. For example, in UNIX, an agentPath parameter |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
392 |
* of {@code /a/b/libL.so} would name a library 'L'. |
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
393 |
* |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
394 |
* See the JVM TI Specification for more details. |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
395 |
* |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
396 |
* This method causes the given agent library to be loaded into the target |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
397 |
* VM (if not already loaded or if not statically linked into the VM). |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
398 |
* It then causes the target VM to invoke the {@code Agent_OnAttach} |
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
399 |
* function or, for a statically linked agent named 'L', the |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
400 |
* {@code Agent_OnAttach_L} function as specified in the |
2 | 401 |
* <a href="../../../../../../../../technotes/guides/jvmti/index.html"> JVM Tools |
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
402 |
* Interface</a> specification. |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
403 |
* Note that the {@code Agent_OnAttach[_L]} |
2 | 404 |
* function is invoked even if the agent library was loaded prior to invoking |
405 |
* this method. |
|
406 |
* |
|
407 |
* <p> The agent library provided is the absolute path from which to load the |
|
408 |
* agent library. Unlike {@link #loadAgentLibrary loadAgentLibrary}, the library name |
|
409 |
* is not expanded in the target virtual machine. </p> |
|
410 |
* |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
411 |
* <p> If the {@code Agent_OnAttach[_L]} function in the agent library returns |
2 | 412 |
* an error then an {@link com.sun.tools.attach.AgentInitializationException} is |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
413 |
* thrown. The return value from the {@code Agent_OnAttach[_L]} can then be |
2 | 414 |
* obtained by invoking the {@link |
415 |
* com.sun.tools.attach.AgentInitializationException#returnValue() returnValue} |
|
416 |
* method on the exception. </p> |
|
417 |
* |
|
418 |
* @param agentPath |
|
419 |
* The full path of the agent library. |
|
420 |
* |
|
421 |
* @param options |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
422 |
* The options to provide to the {@code Agent_OnAttach[_L]} |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
423 |
* function (can be {@code null}). |
2 | 424 |
* |
425 |
* @throws AgentLoadException |
|
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
426 |
* If the agent library does not exist, the agent library is not |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
427 |
* statically linked with the VM, or the agent library cannot be |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
428 |
* loaded for another reason. |
2 | 429 |
* |
430 |
* @throws AgentInitializationException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
431 |
* If the {@code Agent_OnAttach[_L]} function returns an error. |
2 | 432 |
* |
433 |
* @throws IOException |
|
434 |
* If an I/O error occurs |
|
435 |
* |
|
436 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
437 |
* If {@code agentPath} is {@code null}. |
2 | 438 |
* |
439 |
* @see com.sun.tools.attach.AgentInitializationException#returnValue() |
|
440 |
*/ |
|
441 |
public abstract void loadAgentPath(String agentPath, String options) |
|
442 |
throws AgentLoadException, AgentInitializationException, IOException; |
|
443 |
||
444 |
/** |
|
445 |
* Load a native agent library by full pathname. |
|
446 |
* |
|
447 |
* <p> This convenience method works as if by invoking: |
|
448 |
* |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
449 |
* <blockquote><code> |
2 | 450 |
* {@link #loadAgentPath(String, String) loadAgentPath}(agentLibrary, null); |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
451 |
* </code></blockquote> |
2 | 452 |
* |
453 |
* @param agentPath |
|
454 |
* The full path to the agent library. |
|
455 |
* |
|
456 |
* @throws AgentLoadException |
|
19594
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
457 |
* If the agent library does not exist, the agent library is not |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
458 |
* statically linked with the VM, or the agent library cannot be |
3c054071d45a
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
5506
diff
changeset
|
459 |
* loaded for another reason. |
2 | 460 |
* |
461 |
* @throws AgentInitializationException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
462 |
* If the {@code Agent_OnAttach[_L]} function returns an error. |
2 | 463 |
* |
464 |
* @throws IOException |
|
465 |
* If an I/O error occurs |
|
466 |
* |
|
467 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
468 |
* If {@code agentPath} is {@code null}. |
2 | 469 |
*/ |
470 |
public void loadAgentPath(String agentPath) |
|
471 |
throws AgentLoadException, AgentInitializationException, IOException |
|
472 |
{ |
|
473 |
loadAgentPath(agentPath, null); |
|
474 |
} |
|
475 |
||
476 |
||
477 |
/** |
|
478 |
* Loads an agent. |
|
479 |
* |
|
480 |
* <p> The agent provided to this method is a path name to a JAR file on the file |
|
481 |
* system of the target virtual machine. This path is passed to the target virtual |
|
482 |
* machine where it is interpreted. The target virtual machine attempts to start |
|
483 |
* the agent as specified by the {@link java.lang.instrument} specification. |
|
484 |
* That is, the specified JAR file is added to the system class path (of the target |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
485 |
* virtual machine), and the {@code agentmain} method of the agent class, specified |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
486 |
* by the {@code Agent-Class} attribute in the JAR manifest, is invoked. This |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
487 |
* method completes when the {@code agentmain} method completes. |
2 | 488 |
* |
489 |
* @param agent |
|
490 |
* Path to the JAR file containing the agent. |
|
491 |
* |
|
492 |
* @param options |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
493 |
* The options to provide to the agent's {@code agentmain} |
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
494 |
* method (can be {@code null}). |
2 | 495 |
* |
496 |
* @throws AgentLoadException |
|
497 |
* If the agent does not exist, or cannot be started in the manner |
|
498 |
* specified in the {@link java.lang.instrument} specification. |
|
499 |
* |
|
500 |
* @throws AgentInitializationException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
501 |
* If the {@code agentmain} throws an exception |
2 | 502 |
* |
503 |
* @throws IOException |
|
504 |
* If an I/O error occurs |
|
505 |
* |
|
506 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
507 |
* If {@code agent} is {@code null}. |
2 | 508 |
*/ |
509 |
public abstract void loadAgent(String agent, String options) |
|
510 |
throws AgentLoadException, AgentInitializationException, IOException; |
|
511 |
||
512 |
/** |
|
513 |
* Loads an agent. |
|
514 |
* |
|
515 |
* <p> This convenience method works as if by invoking: |
|
516 |
* |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
517 |
* <blockquote><code> |
2 | 518 |
* {@link #loadAgent(String, String) loadAgent}(agent, null); |
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
519 |
* </code></blockquote> |
2 | 520 |
* |
521 |
* @param agent |
|
522 |
* Path to the JAR file containing the agent. |
|
523 |
* |
|
524 |
* @throws AgentLoadException |
|
525 |
* If the agent does not exist, or cannot be started in the manner |
|
526 |
* specified in the {@link java.lang.instrument} specification. |
|
527 |
* |
|
528 |
* @throws AgentInitializationException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
529 |
* If the {@code agentmain} throws an exception |
2 | 530 |
* |
531 |
* @throws IOException |
|
532 |
* If an I/O error occurs |
|
533 |
* |
|
534 |
* @throws NullPointerException |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
535 |
* If {@code agent} is {@code null}. |
2 | 536 |
*/ |
537 |
public void loadAgent(String agent) |
|
538 |
throws AgentLoadException, AgentInitializationException, IOException |
|
539 |
{ |
|
540 |
loadAgent(agent, null); |
|
541 |
} |
|
542 |
||
543 |
/** |
|
544 |
* Returns the current system properties in the target virtual machine. |
|
545 |
* |
|
546 |
* <p> This method returns the system properties in the target virtual |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
547 |
* machine. Properties whose key or value is not a {@code String} are |
2 | 548 |
* omitted. The method is approximately equivalent to the invocation of the |
549 |
* method {@link java.lang.System#getProperties System.getProperties} |
|
550 |
* in the target virtual machine except that properties with a key or |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
551 |
* value that is not a {@code String} are not included. |
2 | 552 |
* |
553 |
* <p> This method is typically used to decide which agent to load into |
|
554 |
* the target virtual machine with {@link #loadAgent loadAgent}, or |
|
555 |
* {@link #loadAgentLibrary loadAgentLibrary}. For example, the |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
556 |
* {@code java.home} or {@code user.dir} properties might be |
2 | 557 |
* use to create the path to the agent library or JAR file. |
558 |
* |
|
559 |
* @return The system properties |
|
560 |
* |
|
24363
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
561 |
* @throws AttachOperationFailedException |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
562 |
* If the target virtual machine is unable to complete the |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
563 |
* attach operation. A more specific error message will be |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
564 |
* given by {@link AttachOperationFailedException#getMessage()}. |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
565 |
* |
2 | 566 |
* @throws IOException |
24363
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
567 |
* If an I/O error occurs, a communication error for example, |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
568 |
* that cannot be identified as an error to indicate that the |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
569 |
* operation failed in the target VM. |
2 | 570 |
* |
571 |
* @see java.lang.System#getProperties |
|
572 |
* @see #loadAgentLibrary |
|
573 |
* @see #loadAgent |
|
574 |
*/ |
|
575 |
public abstract Properties getSystemProperties() throws IOException; |
|
576 |
||
577 |
/** |
|
578 |
* Returns the current <i>agent properties</i> in the target virtual |
|
579 |
* machine. |
|
580 |
* |
|
581 |
* <p> The target virtual machine can maintain a list of properties on |
|
582 |
* behalf of agents. The manner in which this is done, the names of the |
|
583 |
* properties, and the types of values that are allowed, is implementation |
|
584 |
* specific. Agent properties are typically used to store communication |
|
585 |
* end-points and other agent configuration details. For example, a debugger |
|
586 |
* agent might create an agent property for its transport address. |
|
587 |
* |
|
588 |
* <p> This method returns the agent properties whose key and value is a |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
589 |
* {@code String}. Properties whose key or value is not a {@code String} |
2 | 590 |
* are omitted. If there are no agent properties maintained in the target |
591 |
* virtual machine then an empty property list is returned. |
|
592 |
* |
|
593 |
* @return The agent properties |
|
594 |
* |
|
24363
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
595 |
* @throws AttachOperationFailedException |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
596 |
* If the target virtual machine is unable to complete the |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
597 |
* attach operation. A more specific error message will be |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
598 |
* given by {@link AttachOperationFailedException#getMessage()}. |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
599 |
* |
2 | 600 |
* @throws IOException |
24363
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
601 |
* If an I/O error occurs, a communication error for example, |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
602 |
* that cannot be identified as an error to indicate that the |
33b869a8806b
8039173: Propagate errors from Diagnostic Commands as exceptions in the attach framework
sla
parents:
20742
diff
changeset
|
603 |
* operation failed in the target VM. |
2 | 604 |
*/ |
605 |
public abstract Properties getAgentProperties() throws IOException; |
|
606 |
||
607 |
/** |
|
24870
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
608 |
* Starts the JMX management agent in the target virtual machine. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
609 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
610 |
* <p> The configuration properties are the same as those specified on |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
611 |
* the command line when starting the JMX management agent. In the same |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
612 |
* way as on the command line, you need to specify at least the |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
613 |
* {@code com.sun.management.jmxremote.port} property. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
614 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
615 |
* <p> See the online documentation for <a |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
616 |
* href="../../../../../../../../technotes/guides/management/agent.html"> |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
617 |
* Monitoring and Management Using JMX Technology</a> for further details. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
618 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
619 |
* @param agentProperties |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
620 |
* A Properties object containing the configuration properties |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
621 |
* for the agent. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
622 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
623 |
* @throws AttachOperationFailedException |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
624 |
* If the target virtual machine is unable to complete the |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
625 |
* attach operation. A more specific error message will be |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
626 |
* given by {@link AttachOperationFailedException#getMessage()}. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
627 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
628 |
* @throws IOException |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
629 |
* If an I/O error occurs, a communication error for example, |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
630 |
* that cannot be identified as an error to indicate that the |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
631 |
* operation failed in the target VM. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
632 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
633 |
* @throws IllegalArgumentException |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
634 |
* If keys or values in agentProperties are invalid. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
635 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
636 |
* @throws NullPointerException |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
637 |
* If agentProperties is null. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
638 |
* |
26453 | 639 |
* @since 1.8 |
24870
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
640 |
*/ |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
641 |
public abstract void startManagementAgent(Properties agentProperties) throws IOException; |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
642 |
|
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
643 |
/** |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
644 |
* Starts the local JMX management agent in the target virtual machine. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
645 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
646 |
* <p> See the online documentation for <a |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
647 |
* href="../../../../../../../../technotes/guides/management/agent.html"> |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
648 |
* Monitoring and Management Using JMX Technology</a> for further details. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
649 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
650 |
* @return The String representation of the local connector's service address. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
651 |
* The value can be parsed by the |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
652 |
* {@link javax.management.remote.JMXServiceURL#JMXServiceURL(String)} |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
653 |
* constructor. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
654 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
655 |
* @throws AttachOperationFailedException |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
656 |
* If the target virtual machine is unable to complete the |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
657 |
* attach operation. A more specific error message will be |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
658 |
* given by {@link AttachOperationFailedException#getMessage()}. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
659 |
* |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
660 |
* @throws IOException |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
661 |
* If an I/O error occurs, a communication error for example, |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
662 |
* that cannot be identified as an error to indicate that the |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
663 |
* operation failed in the target VM. |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
664 |
* |
26453 | 665 |
* @since 1.8 |
24870
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
666 |
*/ |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
667 |
public abstract String startLocalManagementAgent() throws IOException; |
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
668 |
|
5d567113d043
8044135: Add API to start JMX agent from attach framework
sla
parents:
24363
diff
changeset
|
669 |
/** |
2 | 670 |
* Returns a hash-code value for this VirtualMachine. The hash |
671 |
* code is based upon the VirtualMachine's components, and satifies |
|
672 |
* the general contract of the {@link java.lang.Object#hashCode() |
|
673 |
* Object.hashCode} method. |
|
674 |
* |
|
675 |
* @return A hash-code value for this virtual machine |
|
676 |
*/ |
|
677 |
public int hashCode() { |
|
678 |
if (hash != 0) { |
|
679 |
return hash; |
|
680 |
} |
|
681 |
hash = provider.hashCode() * 127 + id.hashCode(); |
|
682 |
return hash; |
|
683 |
} |
|
684 |
||
685 |
/** |
|
686 |
* Tests this VirtualMachine for equality with another object. |
|
687 |
* |
|
688 |
* <p> If the given object is not a VirtualMachine then this |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
689 |
* method returns {@code false}. For two VirtualMachines to |
2 | 690 |
* be considered equal requires that they both reference the same |
691 |
* provider, and their {@link VirtualMachineDescriptor#id() identifiers} are equal. </p> |
|
692 |
* |
|
693 |
* <p> This method satisfies the general contract of the {@link |
|
694 |
* java.lang.Object#equals(Object) Object.equals} method. </p> |
|
695 |
* |
|
696 |
* @param ob The object to which this object is to be compared |
|
697 |
* |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
698 |
* @return {@code true} if, and only if, the given object is |
2 | 699 |
* a VirtualMachine that is equal to this |
700 |
* VirtualMachine. |
|
701 |
*/ |
|
702 |
public boolean equals(Object ob) { |
|
703 |
if (ob == this) |
|
704 |
return true; |
|
705 |
if (!(ob instanceof VirtualMachine)) |
|
706 |
return false; |
|
707 |
VirtualMachine other = (VirtualMachine)ob; |
|
708 |
if (other.provider() != this.provider()) { |
|
709 |
return false; |
|
710 |
} |
|
711 |
if (!other.id().equals(this.id())) { |
|
712 |
return false; |
|
713 |
} |
|
714 |
return true; |
|
715 |
} |
|
716 |
||
717 |
/** |
|
32210
958d823579c3
8133480: replace some <tt> tags (obsolete in html5) in core-libs docs
avstepan
parents:
26453
diff
changeset
|
718 |
* Returns the string representation of the {@code VirtualMachine}. |
2 | 719 |
*/ |
720 |
public String toString() { |
|
721 |
return provider.toString() + ": " + id; |
|
722 |
} |
|
723 |
} |