本文整理汇总了Java中com.sun.jdi.connect.Connector.StringArgument方法的典型用法代码示例。如果您正苦于以下问题:Java Connector.StringArgument方法的具体用法?Java Connector.StringArgument怎么用?Java Connector.StringArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.connect.Connector
的用法示例。
在下文中一共展示了Connector.StringArgument方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryDebug
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
private static void tryDebug(long pid) throws IOException,
IllegalConnectorArgumentsException {
AttachingConnector ac = Bootstrap.virtualMachineManager().attachingConnectors()
.stream()
.filter(c -> c.name().equals("com.sun.jdi.ProcessAttach"))
.findFirst()
.orElseThrow(() -> new RuntimeException("Unable to locate ProcessAttachingConnector"));
Map<String, Connector.Argument> args = ac.defaultArguments();
Connector.StringArgument arg = (Connector.StringArgument) args
.get("pid");
arg.setValue("" + pid);
System.out.println("Debugger is attaching to: " + pid + " ...");
VirtualMachine vm = ac.attach(args);
// list all threads
System.out.println("Attached! Now listing threads ...");
vm.allThreads().stream().forEach(System.out::println);
System.out.println("Debugger done.");
vm.dispose();
}
示例2: connect
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
@BeforeClass
public static void connect() throws Exception {
SocketAttachingConnector socketConnector = null;
for (Connector connector : Bootstrap.virtualMachineManager().allConnectors()) {
if (connector instanceof SocketAttachingConnector) {
socketConnector = (SocketAttachingConnector) connector;
}
}
if (socketConnector == null) {
throw new RuntimeException("Failed to find SocketAttachingConnector");
}
Map<String, ? extends Connector.Argument> args = socketConnector.defaultArguments();
Connector.IntegerArgument port = (Connector.IntegerArgument) args.get("port");
port.setValue(PORT);
Connector.StringArgument hostname = (Connector.StringArgument) args.get("hostname");
hostname.setValue("localhost");
virtualMachine = socketConnector.attach(args);
}
示例3: main
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
public static void main(String main_args[]) throws Exception {
String pid = main_args[0];
// find ProcessAttachingConnector
List<AttachingConnector> l =
Bootstrap.virtualMachineManager().attachingConnectors();
AttachingConnector ac = null;
for (AttachingConnector c: l) {
if (c.name().equals("com.sun.jdi.ProcessAttach")) {
ac = c;
break;
}
}
if (ac == null) {
throw new RuntimeException("Unable to locate ProcessAttachingConnector");
}
Map<String,Connector.Argument> args = ac.defaultArguments();
Connector.StringArgument arg = (Connector.StringArgument)args.get("pid");
arg.setValue(pid);
System.out.println("Debugger is attaching to: " + pid + " ...");
VirtualMachine vm = ac.attach(args);
System.out.println("Attached! Now listing threads ...");
// list all threads
for (ThreadReference thr: vm.allThreads()) {
System.out.println(thr);
}
System.out.println("Debugger done.");
}
示例4: launchVM
import com.sun.jdi.connect.Connector; //导入方法依赖的package包/类
protected VirtualMachine launchVM() {
F3LaunchingConnector conn = new F3LaunchingConnector();
Map<String, Connector.Argument> args = conn.defaultArguments();
Connector.StringArgument arg = (Connector.StringArgument) args.get("main");
// dummy main class
arg.setValue("Main");
try {
return conn.launch(args);
} catch (Exception exp) {
throw new RuntimeException(exp);
}
}