Search in sources :

Example 6 with Connector

use of com.sun.jdi.connect.Connector in project warn-report by saaavsaaa.

the class debugger method main.

public static void main(String[] args) throws Exception {
    LaunchingConnector launchingConnector = Bootstrap.virtualMachineManager().defaultConnector();
    // Get arguments of the launching connector
    Map<String, Connector.Argument> defaultArguments = launchingConnector.defaultArguments();
    Connector.Argument mainArg = defaultArguments.get("main");
    Connector.Argument suspendArg = defaultArguments.get("suspend");
    // Set class of main method
    mainArg.setValue("cn.tellwhy.DailyTest");
    suspendArg.setValue("true");
    vm = launchingConnector.launch(defaultArguments);
    process = vm.process();
    // Register ClassPrepareRequest
    eventRequestManager = vm.eventRequestManager();
    ClassPrepareRequest classPrepareRequest = eventRequestManager.createClassPrepareRequest();
    // classPrepareRequest.addClassFilter("cn.tellwhy.DailyTest");
    // classPrepareRequest.addCountFilter(1);
    // classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    classPrepareRequest.enable();
    // Enter event loop
    eventLoop();
    process.destroy();
}
Also used : SocketAttachingConnector(com.sun.tools.jdi.SocketAttachingConnector) AttachingConnector(com.sun.jdi.connect.AttachingConnector) Connector(com.sun.jdi.connect.Connector) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest)

Example 7 with Connector

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

the class AcceptTimeout method main.

public static void main(String[] args) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc : connectors) {
        Map<String, Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument) cargs.get("timeout");
        /*
             * If the Connector has a argument named "timeout" then we set the timeout to 1 second
             * and start it listening on its default address. It should throw TranpsortTimeoutException.
             */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);
            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
Also used : ListeningConnector(com.sun.jdi.connect.ListeningConnector) Connector(com.sun.jdi.connect.Connector) TransportTimeoutException(com.sun.jdi.connect.TransportTimeoutException) ListeningConnector(com.sun.jdi.connect.ListeningConnector)

Aggregations

Connector (com.sun.jdi.connect.Connector)7 AttachingConnector (com.sun.jdi.connect.AttachingConnector)5 Iterator (java.util.Iterator)3 List (java.util.List)3 LaunchingConnector (com.sun.jdi.connect.LaunchingConnector)1 ListeningConnector (com.sun.jdi.connect.ListeningConnector)1 TransportTimeoutException (com.sun.jdi.connect.TransportTimeoutException)1 ClassPrepareRequest (com.sun.jdi.request.ClassPrepareRequest)1 SocketAttachingConnector (com.sun.tools.jdi.SocketAttachingConnector)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1