Java Code Examples for com.sun.jdi.connect.spi.TransportService#ListenKey

The following examples show how to use com.sun.jdi.connect.spi.TransportService#ListenKey . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleLaunchingConnector.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 2
Source File: SimpleLaunchingConnector.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 3
Source File: SimpleLaunchingConnector.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 4
Source File: SimpleLaunchingConnector.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 5
Source File: SocketListeningConnector.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void updateArgumentMapIfRequired(
    Map<String, ? extends Connector.Argument> args, TransportService.ListenKey listener) {
    if (isWildcardPort(args)) {
        String[] address = listener.address().split(":");
        if (address.length > 1) {
            args.get(ARG_PORT).setValue(address[1]);
        }
    }
}
 
Example 6
Source File: SimpleLaunchingConnector.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 7
Source File: SimpleLaunchingConnector.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 8
Source File: SimpleLaunchingConnector.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 9
Source File: SimpleLaunchingConnector.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 10
Source File: SocketListeningConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void updateArgumentMapIfRequired(
    Map<String, ? extends Connector.Argument> args, TransportService.ListenKey listener) {
    if (isWildcardPort(args)) {
        String[] address = listener.address().split(":");
        if (address.length > 1) {
            args.get(ARG_PORT).setValue(address[1]);
        }
    }
}
 
Example 11
Source File: SimpleLaunchingConnector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 12
Source File: SimpleLaunchingConnector.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 13
Source File: SocketListeningConnector.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void updateArgumentMapIfRequired(
    Map<String, ? extends Connector.Argument> args, TransportService.ListenKey listener) {
    if (isWildcardPort(args)) {
        String[] address = listener.address().split(":");
        if (address.length > 1) {
            args.get(ARG_PORT).setValue(address[1]);
        }
    }
}
 
Example 14
Source File: SimpleLaunchingConnector.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 15
Source File: SimpleLaunchingConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
 
Example 16
Source File: SocketListeningConnector.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void updateArgumentMapIfRequired(
    Map<String, ? extends Connector.Argument> args, TransportService.ListenKey listener) {
    if (isWildcardPort(args)) {
        String[] address = listener.address().split(":");
        if (address.length > 1) {
            args.get(ARG_PORT).setValue(address[1]);
        }
    }
}
 
Example 17
Source File: SimpleLaunchingConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}