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();
}
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);
}
}
}
Aggregations