Search in sources :

Example 1 with Connection

use of com.sun.jdi.connect.spi.Connection in project jdk8u_jdk by JetBrains.

the class SimpleLaunchingConnector method launch.

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);
}
Also used : IllegalConnectorArgumentsException(com.sun.jdi.connect.IllegalConnectorArgumentsException) TransportService(com.sun.jdi.connect.spi.TransportService) Connection(com.sun.jdi.connect.spi.Connection)

Aggregations

IllegalConnectorArgumentsException (com.sun.jdi.connect.IllegalConnectorArgumentsException)1 Connection (com.sun.jdi.connect.spi.Connection)1 TransportService (com.sun.jdi.connect.spi.TransportService)1