本文整理汇总了Java中com.sun.jdi.VirtualMachine.resume方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachine.resume方法的具体用法?Java VirtualMachine.resume怎么用?Java VirtualMachine.resume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine.resume方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the server debuggee
Process process = launch(address, "Exit0");
// wait for the debugge to be ready
while (!ready) {
try {
Thread.sleep(1000);
} catch(Exception ee) {
throw ee;
}
}
// attach to server debuggee and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event: evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
int exitCode = process.waitFor();
// if the server debuggee ran cleanly, we assume we were clean
if (exitCode == 0 && error_seen == 0) {
System.out.println("Test passed - server debuggee cleanly terminated");
} else {
throw new RuntimeException("Test failed - server debuggee generated an error when it terminated");
}
}
示例2: main
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the first debuggee
ProcessBuilder process1 = prepareLauncher(address, true, "HelloWorld");
// start the debuggee and wait for the "ready" message
Process p = ProcessTools.startProcess(
"process1",
process1,
line -> line.equals("Listening for transport dt_socket at address: " + address),
Math.round(5000 * Utils.TIMEOUT_FACTOR),
TimeUnit.MILLISECONDS
);
// launch a second debuggee with the same address
ProcessBuilder process2 = prepareLauncher(address, false, "HelloWorld");
// get exit status from second debuggee
int exitCode = ProcessTools.startProcess("process2", process2).waitFor();
// clean-up - attach to first debuggee and resume it
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
vm.resume();
// if the second debuggee ran to completion then we've got a problem
if (exitCode == 0) {
throw new RuntimeException("Test failed - second debuggee didn't fail to bind");
} else {
System.out.println("Test passed - second debuggee correctly failed to bind");
}
}
示例3: main
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the server debuggee
Process process = launch(address, "Exit0");
// attach to server debuggee and resume it so it can exit
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
System.out.println("Connection arguments: " + conn_args);
VirtualMachine vm = null;
while (vm == null) {
try {
vm = conn.attach(conn_args);
} catch (ConnectException e) {
e.printStackTrace(System.out);
System.out.println("--- Debugee not ready. Retrying in 500ms. ---");
Thread.sleep(500);
}
}
// The first event is always a VMStartEvent, and it is always in
// an EventSet by itself. Wait for it.
EventSet evtSet = vm.eventQueue().remove();
for (Event event: evtSet) {
if (event instanceof VMStartEvent) {
break;
}
throw new RuntimeException("Test failed - debuggee did not start properly");
}
vm.eventRequestManager().deleteAllBreakpoints();
vm.resume();
int exitCode = process.waitFor();
// if the server debuggee ran cleanly, we assume we were clean
if (exitCode == 0 && error_seen == 0) {
System.out.println("Test passed - server debuggee cleanly terminated");
} else {
throw new RuntimeException("Test failed - server debuggee generated an error when it terminated, " +
"exit code was " + exitCode + ", " + error_seen + " error(s) seen in debugee output.");
}
}
示例4: main
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
String address = String.valueOf(port);
// launch the first debuggee
ProcessBuilder process1 = prepareLauncher(address, true, "HelloWorld");
// start the debuggee and wait for the "ready" message
Process p = ProcessTools.startProcess(
"process1",
process1,
line -> line.equals("Listening for transport dt_socket at address: " + address),
Utils.adjustTimeout(5000),
TimeUnit.MILLISECONDS
);
// launch a second debuggee with the same address
ProcessBuilder process2 = prepareLauncher(address, false, "HelloWorld");
// get exit status from second debuggee
int exitCode = ProcessTools.startProcess("process2", process2).waitFor();
// clean-up - attach to first debuggee and resume it
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
Map conn_args = conn.defaultArguments();
Connector.IntegerArgument port_arg =
(Connector.IntegerArgument)conn_args.get("port");
port_arg.setValue(port);
VirtualMachine vm = conn.attach(conn_args);
vm.resume();
// if the second debuggee ran to completion then we've got a problem
if (exitCode == 0) {
throw new RuntimeException("Test failed - second debuggee didn't fail to bind");
} else {
System.out.println("Test passed - second debuggee correctly failed to bind");
}
}