jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java
author martin
Thu, 30 Oct 2014 07:31:41 -0700
changeset 28059 e576535359cc
parent 25859 3317bb8137f4
child 30037 3e785fad2c3b
permissions -rw-r--r--
8067377: My hobby: caning, then then canning, the the can-can Summary: Fix ALL the stutters! Reviewed-by: rriggs, mchung, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20742
diff changeset
     2
 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jdi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import com.sun.jdi.connect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jdi.connect.spi.Connection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A manager of connections to target virtual machines. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * VirtualMachineManager allows one application to debug
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * multiple target VMs. (Note that the converse is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * supported; a target VM can be debugged by only one
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * debugger application.) This interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * contains methods to manage connections
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * to remote target VMs and to obtain the {@link VirtualMachine}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * mirror for available target VMs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Connections can be made using one of several different
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * {@link com.sun.jdi.connect.Connector} objects. Each connector encapsulates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * a different way of connecting the debugger with a target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * The VirtualMachineManager supports many different scenarios for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * connecting a debugger to a virtual machine. Four examples
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * are presented in the table below. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * examples use the command line syntax in Sun's implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Some {@link com.sun.jdi.connect.Connector} implementations may require slightly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * different handling than presented below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <TABLE BORDER WIDTH="75%" SUMMARY="Four scenarios for connecting a debugger
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *  to a virtual machine">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <TH scope=col>Scenario</TH>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * <TH scope=col>Description</TH>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <TD>Debugger launches target VM (simplest, most-common scenario)</TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <TD>Debugger calls the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * {@link com.sun.jdi.connect.LaunchingConnector#launch(java.util.Map)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * method of the default connector, obtained with {@link #defaultConnector}. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * target VM is launched, and a connection between that VM and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * debugger is established. A {@link VirtualMachine} mirror is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <P>Or, for more control
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * Debugger selects a connector from the list returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * {@link #launchingConnectors} with desired characteristics
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * (for example, transport type, etc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * Debugger calls the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * {@link com.sun.jdi.connect.LaunchingConnector#launch(java.util.Map)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * method of the selected connector. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * target VM is launched, and a connection between that VM and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * debugger is established. A {@link VirtualMachine} mirror is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * </TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * </TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <TD>Debugger attaches to previously-running VM</TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * Target VM is launched using the options
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * <code>-agentlib:jdwp=transport=xxx,server=y</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * </LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * Target VM generates and outputs the tranport-specific address at which it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * listen for a connection.</LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * Debugger is launched. Debugger selects a connector in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * returned by {@link #attachingConnectors} matching the transport with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * the name "xxx".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * Debugger presents the default connector parameters (obtained through
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * {@link com.sun.jdi.connect.Connector#defaultArguments()}) to the end user,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * allowing the user to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * fill in the transport-specific address generated by the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * Debugger calls the {@link com.sun.jdi.connect.AttachingConnector#attach(java.util.Map)} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * of the selected to attach to the target VM. A {@link VirtualMachine}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * mirror is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * </TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * </TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * <TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * <TD>Target VM attaches to previously-running debugger</TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * <TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * At startup, debugger selects one or more connectors from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * the list returned by {@link #listeningConnectors} for one or more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * transports.</LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * Debugger calls the {@link com.sun.jdi.connect.ListeningConnector#startListening(java.util.Map)} method for each selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * connector. For each call, a transport-specific address string is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * generated and returned. The debugger makes the transport names and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * corresponding address strings available to the end user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * Debugger calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * for each selected connector to wait for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * a target VM to connect.</LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * Later, target VM is launched by end user with the options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * <code>-agentlib:jdwp=transport=xxx,address=yyy</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * where "xxx" the transport for one of the connectors selected by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * the debugger and "yyy"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * is the address generated by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)} for that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * transport.</LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * Debugger's call to {@link com.sun.jdi.connect.ListeningConnector#accept(java.util.Map)} returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * a {@link VirtualMachine} mirror.</LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * </TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * </TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * <TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * <TD>Target VM launches debugger (sometimes called "Just-In-Time" debugging)</TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * <TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 * Target VM is launched with the options
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 * <code>-agentlib:jdwp=launch=cmdline,onuncaught=y,transport=xxx,server=y</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * </LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * Later, an uncaught exception is thrown in the target VM. The target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 * VM generates the tranport-specific address at which it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * listen for a connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * <LI>Target VM launches the debugger with the following items concatenated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * together (separated by spaces) to form the command line:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 * <LI> The launch= value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 * <LI> The transport= value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * <LI> The generated transport-specific address at which VM is listening for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 * debugger connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 * </UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 * Upon launch, debugger selects a connector in the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 * returned by {@link #attachingConnectors} matching the transport with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * the name "xxx".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * Debugger changes the default connector parameters (obtained through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 * {@link com.sun.jdi.connect.Connector#defaultArguments()}) to specify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 * the transport specific address at which the VM is listenig. Optionally,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 * other connector arguments can be presented to the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 * <LI>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 * Debugger calls the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 * {@link com.sun.jdi.connect.AttachingConnector#attach(java.util.Map)} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 * of the selected to attach to the target VM. A {@link VirtualMachine}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * mirror is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * </TD>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * </TR>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 * </TABLE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 * <p> Connectors are created at start-up time. That is, they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * are created the first time that {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * com.sun.jdi.Bootstrap#virtualMachineManager()} is invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * The list of all Connectors created at start-up time can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 * obtained from the VirtualMachineManager by invoking the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * {@link #allConnectors allConnectors} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * <p> Connectors are created at start-up time if they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * installed on the platform. In addition, Connectors are created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * automatically by the VirtualMachineManager to encapsulate any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * {@link com.sun.jdi.connect.spi.TransportService} implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * that are installed on the platform. These two mechanisms for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * creating Connectors are described here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * <p> A Connector is installed on the platform if it is installed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * in a jar file that is visible to the defining class loader of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 * the {@link com.sun.jdi.connect.Connector} type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 * and that jar file contains a provider configuration file named
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
 * <tt>com.sun.jdi.connect.Connector</tt> in the resource directory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
 * <tt>META-INF/services</tt>, and the provider configuration file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 * lists the full-qualified class name of the Connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * implementation. A Connector is a class that implements the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * {@link com.sun.jdi.connect.Connector Connector} interface. More
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * appropriately the class implements one of the specific Connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * types, namely {@link com.sun.jdi.connect.AttachingConnector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 * AttachingConnector}, {@link com.sun.jdi.connect.ListeningConnector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 * ListeningConnector}, or {@link com.sun.jdi.connect.LaunchingConnector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * LaunchingConnector}. The format of the provider configuration file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 * is one fully-qualified class name per line. Space and tab characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * surrounding each class, as well as blank lines are ignored. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * comment character is <tt>'#'</tt> (<tt>0x23</tt>), and on each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 * line all characters following the first comment character are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 * ignored. The file must be encoded in UTF-8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 * <p> At start-up time the VirtualMachineManager attempts to load
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
 * and instantiate (using the no-arg constructor) each class listed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
 * in the provider configuration file. Exceptions thrown when loading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
 * or creating the Connector are caught and ignored. In other words,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * the start-up process continues despite of errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 * <p> In addition to Connectors installed on the platform the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * VirtualMachineManager will also create Connectors to encapsulate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 * any {@link com.sun.jdi.connect.spi.TransportService} implementations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 * that are installed on the platform. A TransportService is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
 * installed on the platform if it installed in a jar file that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
 * visible to the defining class loader for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 * {@link com.sun.jdi.connect.spi.TransportService} type, and that jar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
 * file contains a provider configuration file named
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
 * <tt>com.sun.jdi.connect.spi.TransportService</tt> in the resource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
 * directory <tt>META-INF/services</tt>, and the provider
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   228
 * configuration file lists the full-qualified class name of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
 * TransportService implementation. A TransportService is a concrete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
 * sub-class of {@link com.sun.jdi.connect.spi.TransportService
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 * TransportService}. The format of the provider configuration file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
 * is the same as the provider configuration file for Connectors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
 * except that each class listed must be the fully-qualified class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
 * name of a class that implements the TransportService interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
 * <p> For each TransportService installed on the platform, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
 * VirtualMachineManager creates a corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
 * {@link com.sun.jdi.connect.AttachingConnector} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
 * {@link com.sun.jdi.connect.ListeningConnector}. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
 * Connectors are created to encapsulate a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
 * com.sun.jdi.connect.Transport Transport} that in turn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
 * encapsulates the TransportService.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
 * The AttachingConnector will be named based on the name of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
 * transport service concatenated with the string <tt>Attach</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
 * For example, if the transport service {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
 * com.sun.jdi.connect.spi.TransportService#name() name()} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
 * returns <tt>telepathic</tt> then the AttachingConnector will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
 * be named <tt>telepathicAttach</tt>. Similiarly the ListeningConnector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
 * will be named with the string <tt>Listen</tt> tagged onto the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
 * name of the transport service. The {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
 * com.sun.jdi.connect.Connector#description() description()} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * of both the AttachingConnector, and the ListeningConnector, will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * delegate to the {@link com.sun.jdi.connect.spi.TransportService#description()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 * description()} method of the underlying transport service. Both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 * the AttachingConnector and the ListeningConnector will have two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 * Connector {@link com.sun.jdi.connect.Connector$Argument Arguments}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
 * A {@link com.sun.jdi.connect.Connector$StringArgument StringArgument}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
 * named <tt>address</tt> is the connector argument to specify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
 * address to attach too, or to listen on. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
 * {@link com.sun.jdi.connect.Connector$IntegerArgument IntegerArgument}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
 * named <tt>timeout</tt> is the connector argument to specify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
 * timeout when attaching, or accepting. The timeout connector may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
 * ignored depending on if the transport service supports an attach
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
 * timeout or accept timeout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
 * <p> Initialization of the virtual machine manager will fail, that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
 * {@link com.sun.jdi.Bootstrap#virtualMachineManager()} will throw an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
 * error if the virtual machine manager is unable to create any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
 * connectors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
 * @author Gordon Hirsch
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
 * @since  1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
 */
20742
4ae78e8060d6 8008662: Add @jdk.Exported to JDK-specific/exported APIs
alanb
parents: 5506
diff changeset
   274
@jdk.Exported
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
public interface VirtualMachineManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * Identifies the default connector. This connector should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * be used as the launching connector when selection of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * connector with specific characteristics is unnecessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @return the default {@link com.sun.jdi.connect.LaunchingConnector}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    LaunchingConnector defaultConnector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * Returns the list of known {@link com.sun.jdi.connect.LaunchingConnector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Any of the returned objects can be used to launch a new target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * VM and immediately create a {@link VirtualMachine} mirror for it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Note that a target VM launched by a launching connector is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * received.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @return a list of {@link com.sun.jdi.connect.LaunchingConnector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    List<LaunchingConnector> launchingConnectors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * Returns the list of known {@link com.sun.jdi.connect.AttachingConnector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Any of the returned objects can be used to attach to an existing target
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * VM and create a {@link VirtualMachine} mirror for it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @return a list of {@link com.sun.jdi.connect.AttachingConnector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    List<AttachingConnector> attachingConnectors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * Returns the list of known {@link com.sun.jdi.connect.ListeningConnector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * Any of the returned objects can be used to listen for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * connection initiated by a target VM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * and create a {@link VirtualMachine} mirror for it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @return a list of {@link com.sun.jdi.connect.ListeningConnector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    List<ListeningConnector> listeningConnectors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * Returns the list of all known {@link com.sun.jdi.connect.Connector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @return a list of {@link com.sun.jdi.connect.Connector} objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     List<Connector> allConnectors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Lists all target VMs which are connected to the debugger.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * The list includes {@link VirtualMachine} instances for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * any target VMs which initiated a connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * and any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * target VMs to which this manager has initiated a connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * A target VM will remain in this list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * until the VM is disconnected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * {@link com.sun.jdi.event.VMDisconnectEvent} is placed in the event queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * after the VM is removed from the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @return a list of {@link VirtualMachine} objects, each mirroring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * a target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     List<VirtualMachine> connectedVirtualMachines();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      * Returns the major version number of the JDI interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
      * See {@link VirtualMachine#version} target VM version and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
      * information and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
      * {@link VirtualMachine#description} more version information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
      * @return the integer major version number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     int majorInterfaceVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
      * Returns the minor version number of the JDI interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
      * See {@link VirtualMachine#version} target VM version and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
      * information and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
      * {@link VirtualMachine#description} more version information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
      * @return the integer minor version number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     int minorInterfaceVersion();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
      * Create a virtual machine mirror for a target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
      * <p> Creates a virtual machine mirror for a target VM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
      * for which a {@link com.sun.jdi.connect.spi.Connection Connection}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
      * already exists. A Connection is created when a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
      * com.sun.jdi.connect.Connector Connector} establishes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
      * a connection and successfully handshakes with a target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
      * A Connector can then use this method to create a virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
      * mirror to represent the composite state of the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
      * <p> The <tt>process</tt> argument specifies the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
      * {@link java.lang.Process} object for the taget VM. It may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      * specified as <tt>null</tt>. If the target VM is launched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
      * by a {@link com.sun.jdi.connect.LaunchingConnector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
      * LaunchingConnector} the <tt>process</tt> argument should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
      * specified, otherwise calling {@link com.sun.jdi.VirtualMachine#process()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
      * on the created virtual machine will return <tt>null</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
      * <p> This method exists so that Connectors may create
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
      * a virtual machine mirror when a connection is established
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
      * to a target VM. Only developers creating new Connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
      * implementations should need to make direct use of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
      * method. </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
      * @param  connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
      *         The open connection to the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
      * @param  process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
      *         If launched, the {@link java.lang.Process} object for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
      *         the target VM. <tt>null</tt> if not launched.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
      * @return new virtual machine representing the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
      * @throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
      *         if an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
      * @throws IllegalStateException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
      *         if the connection is not open
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
      * @see com.sun.jdi.connect.spi.Connection#isOpen()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
      * @see com.sun.jdi.VirtualMachine#process()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
      * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     VirtualMachine createVirtualMachine(Connection connection, Process process) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
      * Creates a new virtual machine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
      * <p> This convenience method works as if by invoking {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
      * #createVirtualMachine(Connection, Process)} method and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
      * specifying <tt>null</tt> as the <tt>process</tt> argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
      * <p> This method exists so that Connectors may create
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
      * a virtual machine mirror when a connection is established
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
      * to a target VM. Only developers creating new Connector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
      * implementations should need to make direct use of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
      * method. </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
      * @return the new virtual machine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
      * @throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
      *         if an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
      * @throws IllegalStateException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
      *         if the connection is not open
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
      * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     VirtualMachine createVirtualMachine(Connection connection) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
}