feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
70
jdkSrc/jdk8/com/sun/jdi/connect/AttachingConnector.java
Normal file
70
jdkSrc/jdk8/com/sun/jdi/connect/AttachingConnector.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A connector which attaches to a previously running target VM.
|
||||
*
|
||||
* @author Gordon Hirsch
|
||||
* @since 1.3
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface AttachingConnector extends Connector {
|
||||
/**
|
||||
* Attaches to a running application and and returns a
|
||||
* mirror of its VM.
|
||||
* <p>
|
||||
* The connector uses the given argument map in
|
||||
* attaching the application. These arguments will include addressing
|
||||
* information that identifies the VM.
|
||||
* The argument map associates argument name strings to instances
|
||||
* of {@link Connector.Argument}. The default argument map for a
|
||||
* connector can be obtained through {@link Connector#defaultArguments}.
|
||||
* Argument map values can be changed, but map entries should not be
|
||||
* added or deleted.
|
||||
*
|
||||
* @param arguments the argument map to be used in launching the VM.
|
||||
* @return the {@link VirtualMachine} mirror of the target VM.
|
||||
*
|
||||
* @throws TransportTimeoutException when the Connector encapsulates
|
||||
* a transport that supports a timeout when attaching, a
|
||||
* {@link Connector.Argument} representing a timeout has been set
|
||||
* in the argument map, and a timeout occurs when trying to attach
|
||||
* to the target VM.
|
||||
*
|
||||
* @throws java.io.IOException when unable to attach.
|
||||
* Specific exceptions are dependent on the Connector implementation
|
||||
* in use.
|
||||
* @throws IllegalConnectorArgumentsException when one of the
|
||||
* connector arguments is invalid.
|
||||
*/
|
||||
VirtualMachine attach(Map<String,? extends Connector.Argument> arguments)
|
||||
throws IOException, IllegalConnectorArgumentsException;
|
||||
}
|
||||
291
jdkSrc/jdk8/com/sun/jdi/connect/Connector.java
Normal file
291
jdkSrc/jdk8/com/sun/jdi/connect/Connector.java
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A method of connection between a debugger and a target VM.
|
||||
* A connector encapsulates exactly one {@link Transport}. used
|
||||
* to establish the connection. Each connector has a set of arguments
|
||||
* which controls its operation. The arguments are stored as a
|
||||
* map, keyed by a string. Each implementation defines the string
|
||||
* argument keys it accepts.
|
||||
*
|
||||
* @see LaunchingConnector
|
||||
* @see AttachingConnector
|
||||
* @see ListeningConnector
|
||||
* @see Connector.Argument
|
||||
*
|
||||
* @author Gordon Hirsch
|
||||
* @since 1.3
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface Connector {
|
||||
/**
|
||||
* Returns a short identifier for the connector. Connector implementors
|
||||
* should follow similar naming conventions as are used with packages
|
||||
* to avoid name collisions. For example, the Sun connector
|
||||
* implementations have names prefixed with "com.sun.jdi.".
|
||||
* Not intended for exposure to end-user.
|
||||
*
|
||||
* @return the name of this connector.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Returns a human-readable description of this connector
|
||||
* and its purpose.
|
||||
*
|
||||
* @return the description of this connector
|
||||
*/
|
||||
String description();
|
||||
|
||||
/**
|
||||
* Returns the transport mechanism used by this connector to establish
|
||||
* connections with a target VM.
|
||||
*
|
||||
* @return the {@link Transport} used by this connector.
|
||||
*/
|
||||
Transport transport();
|
||||
|
||||
/**
|
||||
* Returns the arguments accepted by this Connector and their
|
||||
* default values. The keys of the returned map are string argument
|
||||
* names. The values are {@link Connector.Argument} containing
|
||||
* information about the argument and its default value.
|
||||
*
|
||||
* @return the map associating argument names with argument
|
||||
* information and default value.
|
||||
*/
|
||||
Map<String,Connector.Argument> defaultArguments();
|
||||
|
||||
/**
|
||||
* Specification for and value of a Connector argument.
|
||||
* Will always implement a subinterface of Argument:
|
||||
* {@link Connector.StringArgument}, {@link Connector.BooleanArgument},
|
||||
* {@link Connector.IntegerArgument},
|
||||
* or {@link Connector.SelectedArgument}.
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface Argument extends Serializable {
|
||||
/**
|
||||
* Returns a short, unique identifier for the argument.
|
||||
* Not intended for exposure to end-user.
|
||||
*
|
||||
* @return the name of this argument.
|
||||
*/
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Returns a short human-readable label for this argument.
|
||||
*
|
||||
* @return a label for this argument
|
||||
*/
|
||||
String label();
|
||||
|
||||
/**
|
||||
* Returns a human-readable description of this argument
|
||||
* and its purpose.
|
||||
*
|
||||
* @return the description of this argument
|
||||
*/
|
||||
String description();
|
||||
|
||||
/**
|
||||
* Returns the current value of the argument. Initially, the
|
||||
* default value is returned. If the value is currently unspecified,
|
||||
* null is returned.
|
||||
*
|
||||
* @return the current value of the argument.
|
||||
*/
|
||||
String value();
|
||||
|
||||
/**
|
||||
* Sets the value of the argument.
|
||||
* The value should be checked with {@link #isValid(String)}
|
||||
* before setting it; invalid values will throw an exception
|
||||
* when the connection is established - for example,
|
||||
* on {@link LaunchingConnector#launch}
|
||||
*/
|
||||
void setValue(String value);
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if the value is valid to be
|
||||
* used in {@link #setValue(String)}
|
||||
*/
|
||||
boolean isValid(String value);
|
||||
|
||||
/**
|
||||
* Indicates whether the argument must be specified. If true,
|
||||
* {@link #setValue} must be used to set a non-null value before
|
||||
* using this argument in establishing a connection.
|
||||
*
|
||||
* @return <code>true</code> if the argument must be specified;
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
boolean mustSpecify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specification for and value of a Connector argument,
|
||||
* whose value is Boolean. Boolean values are represented
|
||||
* by the localized versions of the strings "true" and "false".
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface BooleanArgument extends Argument {
|
||||
/**
|
||||
* Sets the value of the argument.
|
||||
*/
|
||||
void setValue(boolean value);
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if value is a string
|
||||
* representation of a boolean value.
|
||||
* @see #stringValueOf(boolean)
|
||||
*/
|
||||
boolean isValid(String value);
|
||||
|
||||
/**
|
||||
* Return the string representation of the <code>value</code>
|
||||
* parameter.
|
||||
* Does not set or examine the current value of <code>this</code>
|
||||
* instance.
|
||||
* @return the localized String representation of the
|
||||
* boolean value.
|
||||
*/
|
||||
String stringValueOf(boolean value);
|
||||
|
||||
/**
|
||||
* Return the value of the argument as a boolean. Since
|
||||
* the argument may not have been set or may have an invalid
|
||||
* value {@link #isValid(String)} should be called on
|
||||
* {@link #value()} to check its validity. If it is invalid
|
||||
* the boolean returned by this method is undefined.
|
||||
* @return the value of the argument as a boolean.
|
||||
*/
|
||||
boolean booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specification for and value of a Connector argument,
|
||||
* whose value is an integer. Integer values are represented
|
||||
* by their corresponding strings.
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface IntegerArgument extends Argument {
|
||||
/**
|
||||
* Sets the value of the argument.
|
||||
* The value should be checked with {@link #isValid(int)}
|
||||
* before setting it; invalid values will throw an exception
|
||||
* when the connection is established - for example,
|
||||
* on {@link LaunchingConnector#launch}
|
||||
*/
|
||||
void setValue(int value);
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if value represents an int that is
|
||||
* <code>{@link #min()} <= value <= {@link #max()}</code>
|
||||
*/
|
||||
boolean isValid(String value);
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if
|
||||
* <code>{@link #min()} <= value <= {@link #max()}</code>
|
||||
*/
|
||||
boolean isValid(int value);
|
||||
|
||||
/**
|
||||
* Return the string representation of the <code>value</code>
|
||||
* parameter.
|
||||
* Does not set or examine the current value of <code>this</code>
|
||||
* instance.
|
||||
* @return the String representation of the
|
||||
* int value.
|
||||
*/
|
||||
String stringValueOf(int value);
|
||||
|
||||
/**
|
||||
* Return the value of the argument as a int. Since
|
||||
* the argument may not have been set or may have an invalid
|
||||
* value {@link #isValid(String)} should be called on
|
||||
* {@link #value()} to check its validity. If it is invalid
|
||||
* the int returned by this method is undefined.
|
||||
* @return the value of the argument as a int.
|
||||
*/
|
||||
int intValue();
|
||||
|
||||
/**
|
||||
* The upper bound for the value.
|
||||
* @return the maximum allowed value for this argument.
|
||||
*/
|
||||
int max();
|
||||
|
||||
/**
|
||||
* The lower bound for the value.
|
||||
* @return the minimum allowed value for this argument.
|
||||
*/
|
||||
int min();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specification for and value of a Connector argument,
|
||||
* whose value is a String.
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface StringArgument extends Argument {
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> always
|
||||
*/
|
||||
boolean isValid(String value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specification for and value of a Connector argument,
|
||||
* whose value is a String selected from a list of choices.
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface SelectedArgument extends Argument {
|
||||
/**
|
||||
* Return the possible values for the argument
|
||||
* @return {@link List} of {@link String}
|
||||
*/
|
||||
List<String> choices();
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if value is one of {@link #choices()}.
|
||||
*/
|
||||
boolean isValid(String value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Thrown to indicate an invalid argument or
|
||||
* inconsistent passed to a {@link Connector}.
|
||||
*
|
||||
* @author Gordon Hirsch
|
||||
* @since 1.3
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class IllegalConnectorArgumentsException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -3042212603611350941L;
|
||||
List<String> names;
|
||||
|
||||
/**
|
||||
* Construct an <code>IllegalConnectorArgumentsException</code>
|
||||
* with the specified detail message and the name of the argument
|
||||
* which is invalid or inconsistent.
|
||||
* @param s the detailed message.
|
||||
* @param name the name of the invalid or inconsistent argument.
|
||||
*/
|
||||
public IllegalConnectorArgumentsException(String s,
|
||||
String name) {
|
||||
super(s);
|
||||
names = new ArrayList<String>(1);
|
||||
names.add(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an <code>IllegalConnectorArgumentsException</code>
|
||||
* with the specified detail message and a <code>List</code> of
|
||||
* names of arguments which are invalid or inconsistent.
|
||||
* @param s the detailed message.
|
||||
* @param names a <code>List</code> containing the names of the
|
||||
* invalid or inconsistent argument.
|
||||
*/
|
||||
public IllegalConnectorArgumentsException(String s, List<String> names) {
|
||||
super(s);
|
||||
|
||||
this.names = new ArrayList<String>(names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a <code>List</code> containing the names of the
|
||||
* invalid or inconsistent arguments.
|
||||
* @return a <code>List</code> of argument names.
|
||||
*/
|
||||
public List<String> argumentNames() {
|
||||
return Collections.unmodifiableList(names);
|
||||
}
|
||||
}
|
||||
75
jdkSrc/jdk8/com/sun/jdi/connect/LaunchingConnector.java
Normal file
75
jdkSrc/jdk8/com/sun/jdi/connect/LaunchingConnector.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A connector which can launch a target VM before connecting to it.
|
||||
*
|
||||
* @author Gordon Hirsch
|
||||
* @since 1.3
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface LaunchingConnector extends Connector {
|
||||
/**
|
||||
* Launches an application and connects to its VM. Properties
|
||||
* of the launch (possibly including options,
|
||||
* main class, and arguments) are specified in
|
||||
* <code>arguments</code>.
|
||||
* The argument map associates argument name strings to instances
|
||||
* of {@link Connector.Argument}. The default argument map for a
|
||||
* connector can be obtained through {@link Connector#defaultArguments}.
|
||||
* Argument map values can be changed, but map entries should not be
|
||||
* added or deleted.
|
||||
* <p>A target VM launched by a launching connector is not
|
||||
* guaranteed to be stable until after the {@link com.sun.jdi.event.VMStartEvent} has been
|
||||
* received.
|
||||
* <p>
|
||||
* <b>Important note:</b> If a target VM is launched through this
|
||||
* funcctions, its output and error streams must be read as it
|
||||
* executes. These streams are available through the
|
||||
* {@link java.lang.Process Process} object returned by
|
||||
* {@link com.sun.jdi.VirtualMachine#process}. If the streams are not periodically
|
||||
* read, the target VM will stop executing when the buffers for these
|
||||
* streams are filled.
|
||||
*
|
||||
* @param arguments the argument map to be used in launching the VM.
|
||||
* @return the {@link VirtualMachine} mirror of the target VM.
|
||||
* @throws java.io.IOException when unable to launch.
|
||||
* Specific exceptions are dependent on the Connector implementation
|
||||
* in use.
|
||||
* @throws IllegalConnectorArgumentsException when one of the
|
||||
* connector arguments is invalid.
|
||||
* @throws VMStartException when the VM was successfully launched, but
|
||||
* terminated with an error before a connection could be established.
|
||||
*/
|
||||
VirtualMachine launch(Map<String,? extends Connector.Argument> arguments)
|
||||
throws IOException, IllegalConnectorArgumentsException,
|
||||
VMStartException;
|
||||
}
|
||||
118
jdkSrc/jdk8/com/sun/jdi/connect/ListeningConnector.java
Normal file
118
jdkSrc/jdk8/com/sun/jdi/connect/ListeningConnector.java
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
/**
|
||||
* A connector which listens for a connection initiated by a target VM.
|
||||
*
|
||||
* @author Gordon Hirsch
|
||||
* @since 1.3
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface ListeningConnector extends Connector {
|
||||
/**
|
||||
* Indicates whether this listening connector supports multiple
|
||||
* connections for a single argument map. If so, a call to
|
||||
* {@link #startListening} may allow
|
||||
* multiple target VM to become connected.
|
||||
*
|
||||
* @return {@code true} if multiple connections are supported;
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
boolean supportsMultipleConnections();
|
||||
|
||||
/**
|
||||
* Listens for one or more connections initiated by target VMs.
|
||||
* The connector uses the given argument map
|
||||
* in determining the address at which to listen or else it generates
|
||||
* an appropriate listen address. In either case, an address string
|
||||
* is returned from this method which can be used in starting target VMs
|
||||
* to identify this connector. The format of the address string
|
||||
* is connector, transport, and, possibly, platform dependent.
|
||||
* <p>
|
||||
* The argument map associates argument name strings to instances
|
||||
* of {@link Connector.Argument}. The default argument map for a
|
||||
* connector can be obtained through {@link Connector#defaultArguments}.
|
||||
* Argument map values can be changed, but map entries should not be
|
||||
* added or deleted.
|
||||
* <p>
|
||||
* This method does not return a {@link VirtualMachine}, and, normally,
|
||||
* returns before any target VM initiates
|
||||
* a connection. The connected target is obtained through
|
||||
* {@link #accept} (using the same argument map as is passed to this
|
||||
* method).
|
||||
* <p>
|
||||
* If {@code arguments} contains addressing information and
|
||||
* only one connection will be accepted, the {@link #accept accept} method
|
||||
* can be called immediately without calling this method.
|
||||
*
|
||||
* @return the address at which the connector is listening
|
||||
* for a connection.
|
||||
* @throws java.io.IOException when unable to start listening.
|
||||
* Specific exceptions are dependent on the Connector implementation
|
||||
* in use.
|
||||
* @throws IllegalConnectorArgumentsException when one of the
|
||||
* connector arguments is invalid.
|
||||
*/
|
||||
String startListening(Map<String,? extends Connector.Argument> arguments)
|
||||
throws IOException, IllegalConnectorArgumentsException;
|
||||
|
||||
/**
|
||||
* Cancels listening for connections. The given argument map should match
|
||||
* the argument map given for a previous {@link #startListening} invocation.
|
||||
*
|
||||
* @throws java.io.IOException when unable to stop listening.
|
||||
* Specific exceptions are dependent on the Connector implementation
|
||||
* in use.
|
||||
* @throws IllegalConnectorArgumentsException when one of the
|
||||
* connector arguments is invalid.
|
||||
*/
|
||||
void stopListening(Map<String,? extends Connector.Argument> arguments)
|
||||
throws IOException, IllegalConnectorArgumentsException;
|
||||
|
||||
|
||||
/**
|
||||
* Waits for a target VM to attach to this connector.
|
||||
*
|
||||
* @throws TransportTimeoutException when the Connector encapsulates
|
||||
* a transport that supports a timeout when accepting, a
|
||||
* {@link Connector.Argument} representing a timeout has been set
|
||||
* in the argument map, and a timeout occurs whilst waiting for
|
||||
* the target VM to connect.
|
||||
* @throws java.io.IOException when unable to accept.
|
||||
* Specific exceptions are dependent on the Connector implementation
|
||||
* in use.
|
||||
* @throws IllegalConnectorArgumentsException when one of the
|
||||
* connector arguments is invalid.
|
||||
*/
|
||||
VirtualMachine accept(Map<String,? extends Connector.Argument> arguments)
|
||||
throws IOException, IllegalConnectorArgumentsException;
|
||||
|
||||
}
|
||||
53
jdkSrc/jdk8/com/sun/jdi/connect/Transport.java
Normal file
53
jdkSrc/jdk8/com/sun/jdi/connect/Transport.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
import com.sun.jdi.connect.spi.TransportService; // for javadoc
|
||||
|
||||
/**
|
||||
* A method of communication between a debugger and a target VM.
|
||||
*
|
||||
* <p> A Transport represents the transport mechanism used by a
|
||||
* {@link com.sun.jdi.connect.Connector Connector} to establish a
|
||||
* connection with a target VM. It consists of a name which is obtained
|
||||
* by invoking the {@link #name} method. Furthermore, a Transport
|
||||
* encapsulates a {@link com.sun.jdi.connect.spi.TransportService
|
||||
* TransportService} which is the underlying service used
|
||||
* to establish connections and exchange Java Debug Wire Protocol
|
||||
* (JDWP) packets with a target VM.
|
||||
*
|
||||
* @author Gordon Hirsch
|
||||
* @since 1.3
|
||||
*/
|
||||
@jdk.Exported
|
||||
public interface Transport {
|
||||
/**
|
||||
* Returns a short identifier for the transport.
|
||||
*
|
||||
* @return the name of this transport.
|
||||
*/
|
||||
String name();
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
/**
|
||||
* This exception may be thrown as a result of a timeout
|
||||
* when attaching to a target VM, or waiting to accept a
|
||||
* connection from a target VM.
|
||||
*
|
||||
* <p> When attaching to a target VM, using {@link
|
||||
* AttachingConnector#attach attach} this
|
||||
* exception may be thrown if the connector supports a timeout
|
||||
* {@link Connector.Argument connector argument}. Similiarly,
|
||||
* when waiting to accept a connection from a target VM,
|
||||
* using {@link ListeningConnector#accept accept} this
|
||||
* exception may be thrown if the connector supports a
|
||||
* timeout connector argument when accepting.
|
||||
*
|
||||
* <p> In addition, for developers creating {@link
|
||||
* com.sun.jdi.connect.spi.TransportService TransportService}
|
||||
* implementations this exception is thrown when
|
||||
* {@link com.sun.jdi.connect.spi.TransportService#attach attach}
|
||||
* times out when establishing a connection to a target VM,
|
||||
* or {@link com.sun.jdi.connect.spi.TransportService#accept
|
||||
* accept} times out while waiting for a target VM to connect. </p>
|
||||
*
|
||||
* @see AttachingConnector#attach
|
||||
* @see ListeningConnector#accept
|
||||
* @see com.sun.jdi.connect.spi.TransportService#attach
|
||||
* @see com.sun.jdi.connect.spi.TransportService#accept
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class TransportTimeoutException extends java.io.IOException {
|
||||
private static final long serialVersionUID = 4107035242623365074L;
|
||||
/**
|
||||
* Constructs a <tt>TransportTimeoutException</tt> with no detail
|
||||
* message.
|
||||
*/
|
||||
public TransportTimeoutException() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a <tt>TransportTimeoutException</tt> with the
|
||||
* specified detail message.
|
||||
*
|
||||
* @param message the detail message pertaining to this exception.
|
||||
*/
|
||||
public TransportTimeoutException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
57
jdkSrc/jdk8/com/sun/jdi/connect/VMStartException.java
Normal file
57
jdkSrc/jdk8/com/sun/jdi/connect/VMStartException.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect;
|
||||
|
||||
/**
|
||||
* A target VM was successfully launched, but terminated with an
|
||||
* error before a connection could be established. This exception
|
||||
* provides the {@link java.lang.Process} object for the launched
|
||||
* target to help in diagnosing the problem.
|
||||
*
|
||||
* @author Gordon Hirsch
|
||||
* @since 1.3
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class VMStartException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 6408644824640801020L;
|
||||
Process process;
|
||||
|
||||
public VMStartException(Process process) {
|
||||
super();
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
public VMStartException(String message,
|
||||
Process process) {
|
||||
super(message);
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
public Process process() {
|
||||
return process;
|
||||
}
|
||||
}
|
||||
39
jdkSrc/jdk8/com/sun/jdi/connect/package-info.java
Normal file
39
jdkSrc/jdk8/com/sun/jdi/connect/package-info.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This package defines connections between the virtual machine
|
||||
* using the JDI and the target virtual machine.
|
||||
* In concert with {@link com.sun.jdi.VirtualMachineManager}
|
||||
* it is the mechanism for launching, attaching, etc to
|
||||
* target virtual machines.
|
||||
* <p>
|
||||
* Methods may be added to the interfaces in the JDI packages in future
|
||||
* releases. Existing packages may be renamed if the JDI becomes a standard
|
||||
* extension.
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
package com.sun.jdi.connect;
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect.spi;
|
||||
|
||||
/**
|
||||
* This exception may be thrown as a result of an asynchronous
|
||||
* close of a {@link Connection} while an I/O operation is
|
||||
* in progress.
|
||||
*
|
||||
* <p> When a thread is blocked in {@link Connection#readPacket
|
||||
* readPacket} waiting for packet from a target VM the
|
||||
* {@link Connection} may be closed asynchronous by another
|
||||
* thread invokving the {@link Connection#close close} method.
|
||||
* When this arises the thread in readPacket will throw this
|
||||
* exception. Similiarly when a thread is blocked in
|
||||
* {@link Connection#writePacket} the Connection may be closed.
|
||||
* When this occurs the thread in writePacket will throw
|
||||
* this exception.
|
||||
*
|
||||
* @see Connection#readPacket
|
||||
* @see Connection#writePacket
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class ClosedConnectionException extends java.io.IOException {
|
||||
private static final long serialVersionUID = 3877032124297204774L;
|
||||
/**
|
||||
* Constructs a <tt>ClosedConnectionException</tt> with no detail
|
||||
* message.
|
||||
*/
|
||||
public ClosedConnectionException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a <tt>ClosedConnectionException</tt> with the
|
||||
* specified detail message.
|
||||
*
|
||||
* @param message the detail message pertaining to this exception.
|
||||
*/
|
||||
public ClosedConnectionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
201
jdkSrc/jdk8/com/sun/jdi/connect/spi/Connection.java
Normal file
201
jdkSrc/jdk8/com/sun/jdi/connect/spi/Connection.java
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect.spi;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A connection between a debugger and a target VM which it debugs.
|
||||
*
|
||||
* <p> A Connection represents a bi-directional communication channel
|
||||
* between a debugger and a target VM. A Connection is created when
|
||||
* {@link com.sun.jdi.connect.spi.TransportService TransportService}
|
||||
* establishes a connection and successfully handshakes with a target
|
||||
* VM. A TransportService implementation provides a reliable
|
||||
* JDWP packet transportation service and consequently a Connection
|
||||
* provides a reliable flow of JDWP packets between the debugger
|
||||
* and the target VM. A Connection is stream oriented, that is, the
|
||||
* JDWP packets written to a connection are read by the target VM
|
||||
* in the order in which they were written. Similiarly packets written
|
||||
* to a Connection by the target VM are read by the debugger in the
|
||||
* order in which they were written.
|
||||
*
|
||||
* <p> A connection is either open or closed. It is open upon creation,
|
||||
* and remains open until it is closed. Once closed, it remains closed,
|
||||
* and any attempt to invoke an I/O operation upon it will cause a
|
||||
* {@link ClosedConnectionException} to be thrown. A connection can
|
||||
* be tested by invoking the {@link #isOpen isOpen} method.
|
||||
*
|
||||
* <p> A Connection is safe for access by multiple concurrent threads,
|
||||
* although at most one thread may be reading and at most one thread may
|
||||
* be writing at any given time. </p>
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
public abstract class Connection {
|
||||
|
||||
/**
|
||||
* Reads a packet from the target VM.
|
||||
*
|
||||
* <p> Attempts to read a JDWP packet from the target VM.
|
||||
* A read operation may block indefinitely and only returns
|
||||
* when it reads all bytes of a packet, or in the case of a
|
||||
* transport service that is based on a stream-oriented
|
||||
* communication protocol, the end of stream is encountered.
|
||||
*
|
||||
* <p> Reading a packet does not do any integrity checking on
|
||||
* the packet aside from a check that the length of the packet
|
||||
* (as indicated by the value of the <tt>length</tt> field, the
|
||||
* first four bytes of the packet) is 11 or more bytes.
|
||||
* If the value of the <tt>length</tt> value is less then 11
|
||||
* then an <tt>IOException</tt> is thrown.
|
||||
*
|
||||
* <p> Returns a byte array of a length equal to the length
|
||||
* of the received packet, or a byte array of length 0 when an
|
||||
* end of stream is encountered. If end of stream is encountered
|
||||
* after some, but not all bytes of a packet, are read then it
|
||||
* is considered an I/O error and an <tt>IOException</tt> is
|
||||
* thrown. The first byte of the packet is stored in element
|
||||
* <tt>0</tt> of the byte array, the second in element <tt>1</tt>,
|
||||
* and so on. The bytes in the byte array are laid out as per the
|
||||
* <a href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
|
||||
* JDWP specification</a>. That is, all fields in the packet
|
||||
* are in big endian order as per the JDWP specification.
|
||||
*
|
||||
* <p> This method may be invoked at any time. If another thread has
|
||||
* already initiated a {@link #readPacket readPacket} on this
|
||||
* connection then the invocation of this method will block until the
|
||||
* first operation is complete. </p>
|
||||
*
|
||||
* @return the packet read from the target VM
|
||||
*
|
||||
* @throws ClosedConnectionException
|
||||
* If the connection is closed, or another thread closes
|
||||
* the connection while the readPacket is in progress.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* If the length of the packet (as indictaed by the first
|
||||
* 4 bytes) is less than 11 bytes, or an I/O error occurs.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract byte[] readPacket() throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a packet to the target VM.
|
||||
*
|
||||
* <p> Attempts to write, or send, a JDWP packet to the target VM.
|
||||
* A write operation only returns after writing the entire packet
|
||||
* to the target VM. Writing the entire packet does not mean
|
||||
* the entire packet has been transmitted to the target VM
|
||||
* but rather that all bytes have been written to the
|
||||
* transport service. A transport service based on a TCP/IP connection
|
||||
* may, for example, buffer some or all of the packet before
|
||||
* transmission on the network.
|
||||
*
|
||||
* <p> The byte array provided to this method should be laid out
|
||||
* as per the <a
|
||||
* href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
|
||||
* JDWP specification</a>. That is, all fields in the packet
|
||||
* are in big endian order. The first byte, that is element
|
||||
* <tt>pkt[0]</tt>, is the first byte of the <tt>length</tt> field.
|
||||
* <tt>pkt[1]</tt> is the second byte of the <tt>length</tt> field,
|
||||
* and so on.
|
||||
*
|
||||
* <p> Writing a packet does not do any integrity checking on
|
||||
* the packet aside from checking the packet length. Checking
|
||||
* the packet length requires checking that the value of the
|
||||
* <tt>length</tt> field (as indicated by the first four bytes
|
||||
* of the packet) is 11 or greater. Consequently the length of
|
||||
* the byte array provided to this method, that is
|
||||
* <tt>pkt.length</tt>, must be 11 or more, and must be equal
|
||||
* or greater than the value of the <tt>length</tt> field. If the
|
||||
* length of the byte array is greater than the value of
|
||||
* the <tt>length</tt> field then all bytes from element
|
||||
* <tt>pkt[length]</tt> onwards are ignored. In other words,
|
||||
* any additional bytes that follow the packet in the byte
|
||||
* array are ignored and will not be transmitted to the target
|
||||
* VM.
|
||||
*
|
||||
* <p> A write operation may block or may complete immediately.
|
||||
* The exact circumstances when an operation blocks depends on
|
||||
* the transport service. In the case of a TCP/IP connection to
|
||||
* the target VM, the writePacket method may block if there is
|
||||
* network congestion or there is insufficient space to buffer
|
||||
* the packet in the underlying network system.
|
||||
*
|
||||
* <p> This method may be invoked at any time. If another thread has
|
||||
* already initiated a write operation upon this Connection then
|
||||
* a subsequent invocation of this method will block until the first
|
||||
* operation is complete. </p>
|
||||
*
|
||||
* @param pkt
|
||||
* The packet to write to the target VM.
|
||||
*
|
||||
* @throws ClosedConnectionException
|
||||
* If the connection is closed, or another thread closes
|
||||
* the connection while the write operation is in progress.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* If an I/O error occurs.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the value of the <tt>length</tt> field is invalid,
|
||||
* or the byte array is of insufficient length.
|
||||
*/
|
||||
public abstract void writePacket(byte pkt[]) throws IOException;
|
||||
|
||||
/**
|
||||
* Closes this connection.
|
||||
*
|
||||
* <p> If the connection is already closed then invoking this method
|
||||
* has no effect. After a connection is closed, any further attempt
|
||||
* calls to {@link #readPacket readPacket} or {@link #writePacket
|
||||
* writePacket} will throw a {@link ClosedConnectionException}.
|
||||
*
|
||||
* <p> Any thread currently blocked in an I/O operation ({@link
|
||||
* #readPacket readPacket} or {@link #writePacket writePacket})
|
||||
* will throw a {@link ClosedConnectionException}).
|
||||
*
|
||||
* <p> This method may be invoked at any time. If some other thread has
|
||||
* already invoked it, however, then another invocation will block until
|
||||
* the first invocation is complete, after which it will return without
|
||||
* effect. </p>
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
* If an I/O error occurs
|
||||
*/
|
||||
public abstract void close() throws IOException;
|
||||
|
||||
/**
|
||||
* Tells whether or not this connection is open. </p>
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this connection is open
|
||||
*/
|
||||
public abstract boolean isOpen();
|
||||
}
|
||||
380
jdkSrc/jdk8/com/sun/jdi/connect/spi/TransportService.java
Normal file
380
jdkSrc/jdk8/com/sun/jdi/connect/spi/TransportService.java
Normal file
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.jdi.connect.spi;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.sun.jdi.connect.TransportTimeoutException;
|
||||
|
||||
/**
|
||||
* A transport service for connections between a debugger and
|
||||
* a target VM.
|
||||
*
|
||||
* <p> A transport service is a concrete subclass of this class
|
||||
* that has a zero-argument constructor and implements the abstract
|
||||
* methods specified below. It is the underlying service
|
||||
* used by a {@link com.sun.jdi.connect.Transport} for
|
||||
* connections between a debugger and a target VM.
|
||||
*
|
||||
* <p> A transport service is used to establish a connection
|
||||
* between a debugger and a target VM, and to transport Java
|
||||
* Debug Wire Protocol (JDWP) packets over an underlying
|
||||
* communication protocol. In essence a transport service
|
||||
* implementation binds JDWP (as specified in the
|
||||
* <a href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
|
||||
* JDWP specification</a>) to an underlying communication
|
||||
* protocol. A transport service implementation provides
|
||||
* a reliable JDWP packet transportation service. JDWP
|
||||
* packets are sent to and from the target VM without duplication
|
||||
* or data loss. A transport service implementation may be
|
||||
* based on an underlying communication protocol that is
|
||||
* reliable or unreliable. If the underlying communication
|
||||
* protocol is reliable then the transport service implementation
|
||||
* may be relatively simple and may only need to transport JDWP
|
||||
* packets as payloads of the underlying communication
|
||||
* protocol. In the case of an unreliable communication
|
||||
* protocol the transport service implementation may include
|
||||
* additional protocol support in order to ensure that packets
|
||||
* are not duplicated and that there is no data loss. The
|
||||
* details of such protocols are specific to the implementation
|
||||
* but may involve techniques such as the <i>positive
|
||||
* acknowledgment with retransmission</i> technique used in
|
||||
* protocols such as the Transmission Control Protocol (TCP)
|
||||
* (see <a href="http://www.ietf.org/rfc/rfc0793.txt"> RFC 793
|
||||
* </a>).
|
||||
*
|
||||
* <p> A transport service can be used to initiate a connection
|
||||
* to a target VM. This is done by invoking the {@link #attach}
|
||||
* method. Alternatively, a transport service can listen and
|
||||
* accept connections initiated by a target VM. This is done
|
||||
* by invoking the {@link #startListening(String)} method to
|
||||
* put the transport into listen mode. Then the {@link #accept}
|
||||
* method is used to accept a connection initiated by a
|
||||
* target VM.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
public abstract class TransportService {
|
||||
|
||||
/**
|
||||
* Returns a name to identify the transport service.
|
||||
*
|
||||
* @return The name of the transport service
|
||||
*/
|
||||
public abstract String name();
|
||||
|
||||
/**
|
||||
* Returns a description of the transport service.
|
||||
*
|
||||
* @return The description of the transport service
|
||||
*/
|
||||
public abstract String description();
|
||||
|
||||
/**
|
||||
* The transport service capabilities.
|
||||
*/
|
||||
@jdk.Exported
|
||||
public static abstract class Capabilities {
|
||||
|
||||
/**
|
||||
* Tells whether or not this transport service can support
|
||||
* multiple concurrent connections to a single address that
|
||||
* it is listening on.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this transport
|
||||
* service supports multiple connections.
|
||||
*/
|
||||
public abstract boolean supportsMultipleConnections();
|
||||
|
||||
|
||||
/**
|
||||
* Tell whether or not this transport service supports a timeout
|
||||
* when attaching to a target VM.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this transport
|
||||
* service supports attaching with a timeout.
|
||||
*
|
||||
* @see #attach(String,long,long)
|
||||
*/
|
||||
public abstract boolean supportsAttachTimeout();
|
||||
|
||||
/**
|
||||
* Tell whether or not this transport service supports a
|
||||
* timeout while waiting for a target VM to connect.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this transport
|
||||
* service supports timeout while waiting for
|
||||
* a target VM to connect.
|
||||
*
|
||||
* @see #accept(TransportService.ListenKey,long,long)
|
||||
*/
|
||||
public abstract boolean supportsAcceptTimeout();
|
||||
|
||||
/**
|
||||
* Tells whether or not this transport service supports a
|
||||
* timeout when handshaking with the target VM.
|
||||
*
|
||||
* @return <tt>true</tt> if, and only if, this transport
|
||||
* service supports a timeout while handshaking
|
||||
* with the target VM.
|
||||
*
|
||||
* @see #attach(String,long,long)
|
||||
* @see #accept(TransportService.ListenKey,long,long)
|
||||
*/
|
||||
public abstract boolean supportsHandshakeTimeout();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the capabilities of the transport service.
|
||||
*
|
||||
* @return the transport service capabilities
|
||||
*/
|
||||
public abstract Capabilities capabilities();
|
||||
|
||||
/**
|
||||
* Attaches to the specified address.
|
||||
*
|
||||
* <p> Attaches to the specified address and returns a connection
|
||||
* representing the bi-directional communication channel to the
|
||||
* target VM.
|
||||
*
|
||||
* <p> Attaching to the target VM involves two steps:
|
||||
* First, a connection is established to specified address. This
|
||||
* is followed by a handshake to ensure that the connection is
|
||||
* to a target VM. The handshake involves the exchange
|
||||
* of a string <i>JDWP-Handshake</i> as specified in the <a
|
||||
* href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
|
||||
* Java Debug Wire Protocol</a> specification.
|
||||
*
|
||||
* @param address
|
||||
* The address of the target VM.
|
||||
*
|
||||
* @param attachTimeout
|
||||
* If this transport service supports an attach timeout,
|
||||
* and if <tt>attachTimeout</tt> is positive, then it specifies
|
||||
* the timeout, in milliseconds (more or less), to use
|
||||
* when attaching to the target VM. If the transport service
|
||||
* does not support an attach timeout, or if <tt>attachTimeout</tt>
|
||||
* is specified as zero then attach without any timeout.
|
||||
*
|
||||
* @param handshakeTimeout
|
||||
* If this transport service supports a handshake timeout,
|
||||
* and if <tt>handshakeTimeout</tt> is positive, then it
|
||||
* specifies the timeout, in milliseconds (more or less), to
|
||||
* use when handshaking with the target VM. The exact
|
||||
* usage of the timeout are specific to the transport service.
|
||||
* A transport service may, for example, use the handshake
|
||||
* timeout as the inter-character timeout while waiting for
|
||||
* the <i>JDWP-Handshake</i> message from the target VM.
|
||||
* Alternatively, a transport service may, for example,
|
||||
* use the handshakeTimeout as a timeout for the duration of the
|
||||
* handshake exchange.
|
||||
* If the transport service does not support a handshake
|
||||
* timeout, or if <tt>handshakeTimeout</tt> is specified
|
||||
* as zero then the handshake does not timeout if there
|
||||
* isn't a response from the target VM.
|
||||
*
|
||||
* @return The Connection representing the bi-directional
|
||||
* communication channel to the target VM.
|
||||
*
|
||||
* @throws TransportTimeoutException
|
||||
* If a timeout occurs while establishing the connection.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs (including a timeout when
|
||||
* handshaking).
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the address is invalid or the value of the
|
||||
* attach timeout or handshake timeout is negative.
|
||||
*
|
||||
* @see TransportService.Capabilities#supportsAttachTimeout()
|
||||
*/
|
||||
public abstract Connection attach(String address, long attachTimeout,
|
||||
long handshakeTimeout) throws IOException;
|
||||
|
||||
/**
|
||||
* A <i>listen key</i>.
|
||||
*
|
||||
* <p> A <tt>TransportService</tt> may listen on multiple, yet
|
||||
* different, addresses at the same time. To uniquely identify
|
||||
* each <tt>listener</tt> a listen key is created each time that
|
||||
* {@link #startListening startListening} is called. The listen
|
||||
* key is used in calls to the {@link #accept accept} method
|
||||
* to accept inbound connections to that listener. A listen
|
||||
* key is valid until it is used as an argument to {@link
|
||||
* #stopListening stopListening} to stop the transport
|
||||
* service from listening on an address.
|
||||
*/
|
||||
@jdk.Exported
|
||||
public static abstract class ListenKey {
|
||||
|
||||
/**
|
||||
* Returns a string representation of the listen key.
|
||||
*/
|
||||
public abstract String address();
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens on the specified address for inbound connections.
|
||||
*
|
||||
* <p> This method starts the transport service listening on
|
||||
* the specified address so that it can subsequently accept
|
||||
* an inbound connection. It does not wait until an inbound
|
||||
* connection is established.
|
||||
*
|
||||
* @param address
|
||||
* The address to start listening for connections,
|
||||
* or <tt>null</tt> to listen on an address chosen
|
||||
* by the transport service.
|
||||
*
|
||||
* @return a listen key to be used in subsequent calls to be
|
||||
* {@link #accept accept} or {@link #stopListening
|
||||
* stopListening} methods.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the specific address is invalid
|
||||
*/
|
||||
public abstract ListenKey startListening(String address) throws IOException;
|
||||
|
||||
/**
|
||||
* Listens on an address chosen by the transport service.
|
||||
*
|
||||
* <p> This convenience method works as if by invoking {@link
|
||||
* #startListening(String) startListening(<tt>null</tt>)}. </p>
|
||||
*
|
||||
* @return a listen key to be used in subsequent calls to be
|
||||
* {@link #accept accept} or {@link #stopListening
|
||||
* stopListening} methods.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs.
|
||||
*/
|
||||
public abstract ListenKey startListening() throws IOException;
|
||||
|
||||
/**
|
||||
* Stop listening for inbound connections.
|
||||
*
|
||||
* <p> Invoking this method while another thread is blocked
|
||||
* in {@link #accept accept}, with the same listen key,
|
||||
* waiting to accept a connection will cause that thread to
|
||||
* throw an IOException. If the thread blocked in accept
|
||||
* has already accepted a connection from a target VM and
|
||||
* is in the process of handshaking with the target VM then
|
||||
* invoking this method will not cause the thread to throw
|
||||
* an exception.
|
||||
*
|
||||
* @param listenKey
|
||||
* The listen key obtained from a previous call to {@link
|
||||
* #startListening(String)} or {@link #startListening()}.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the listen key is invalid
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs.
|
||||
*/
|
||||
public abstract void stopListening(ListenKey listenKey) throws IOException;
|
||||
|
||||
/**
|
||||
* Accept a connection from a target VM.
|
||||
*
|
||||
* <p> Waits (indefinitely or with timeout) to accept a connection
|
||||
* from a target VM. Returns a connection representing the
|
||||
* bi-directional communication channel to the target VM.
|
||||
*
|
||||
* <p> Accepting a connection from a target VM involves two
|
||||
* steps. First, the transport service waits to accept
|
||||
* the connection from the target VM. Once the connection is
|
||||
* established a handshake is performed to ensure that the
|
||||
* connection is indeed to a target VM. The handshake involves
|
||||
* the exchange of a string <i>JDWP-Handshake</i> as specified
|
||||
* in the <a
|
||||
* href="../../../../../../../../../technotes/guides/jpda/jdwp-spec.html">
|
||||
* Java Debug Wire Protocol</a> specification.
|
||||
*
|
||||
* @param listenKey
|
||||
* A listen key obtained from a previous call to {@link
|
||||
* #startListening(String)} or {@link #startListening()}.
|
||||
*
|
||||
* @param acceptTimeout
|
||||
* if this transport service supports an accept timeout, and
|
||||
* if <tt>acceptTimeout</tt> is positive then block for up to
|
||||
* <tt>acceptTimeout</tt> milliseconds, more or less, while waiting
|
||||
* for the target VM to connect.
|
||||
* If the transport service does not support an accept timeout
|
||||
* or if <tt>acceptTimeout</tt> is zero then block indefinitely
|
||||
* for a target VM to connect.
|
||||
*
|
||||
* @param handshakeTimeout
|
||||
* If this transport service supports a handshake timeout,
|
||||
* and if <tt>handshakeTimeout</tt> is positive, then it
|
||||
* specifies the timeout, in milliseconds (more or less), to
|
||||
* use when handshaking with the target VM. The exact
|
||||
* usage of the timeout is specific to the transport service.
|
||||
* A transport service may, for example, use the handshake
|
||||
* timeout as the inter-character timeout while waiting for
|
||||
* the <i>JDWP-Handshake</i> message from the target VM.
|
||||
* Alternatively, a transport service may, for example,
|
||||
* use the timeout as a timeout for the duration of the
|
||||
* handshake exchange.
|
||||
* If the transport service does not support a handshake
|
||||
* timeout, of if <tt>handshakeTimeout</tt> is specified
|
||||
* as zero then the handshake does not timeout if there
|
||||
* isn't a response from the target VM.
|
||||
*
|
||||
* @return The Connection representing the bi-directional
|
||||
* communication channel to the target VM.
|
||||
*
|
||||
* @throws TransportTimeoutException
|
||||
* If a timeout occurs while waiting for a target VM
|
||||
* to connect.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an I/O error occurs (including a timeout when
|
||||
* handshaking).
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* If the value of the acceptTimeout argument, or
|
||||
* handshakeTimeout is negative, or an invalid listen key
|
||||
* is provided.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If {@link #stopListening stopListening} has already been
|
||||
* called with this listen key and the transport service
|
||||
* is no longer listening for inbound connections.
|
||||
*
|
||||
* @see TransportService.Capabilities#supportsAcceptTimeout()
|
||||
*/
|
||||
public abstract Connection accept(ListenKey listenKey, long acceptTimeout,
|
||||
long handshakeTimeout) throws IOException;
|
||||
|
||||
}
|
||||
33
jdkSrc/jdk8/com/sun/jdi/connect/spi/package-info.java
Normal file
33
jdkSrc/jdk8/com/sun/jdi/connect/spi/package-info.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This package comprises the interfaces and classes used to
|
||||
* develop new {@link com.sun.jdi.connect.spi.TransportService}
|
||||
* implementations.
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
package com.sun.jdi.connect.spi;
|
||||
Reference in New Issue
Block a user