当前位置: 首页>>代码示例>>Java>>正文


Java AttachingConnector.defaultArguments方法代码示例

本文整理汇总了Java中com.sun.jdi.connect.AttachingConnector.defaultArguments方法的典型用法代码示例。如果您正苦于以下问题:Java AttachingConnector.defaultArguments方法的具体用法?Java AttachingConnector.defaultArguments怎么用?Java AttachingConnector.defaultArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jdi.connect.AttachingConnector的用法示例。


在下文中一共展示了AttachingConnector.defaultArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connect

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
private VirtualMachine connect(int port) throws IOException {
	VirtualMachineManager manager = Bootstrap.virtualMachineManager();
	
	// Find appropiate connector
	List<AttachingConnector> connectors = manager.attachingConnectors();
	AttachingConnector chosenConnector = null;
	for (AttachingConnector c : connectors) {
		if (c.transport().name().equals(TRANSPORT_NAME)) {
			chosenConnector = c;
			break;
		}
	}
	if (chosenConnector == null) {
		throw new IllegalStateException("Could not find socket connector");
	}
	
	// Set port argument
	AttachingConnector connector = chosenConnector;
	Map<String, Argument> defaults = connector.defaultArguments();
	Argument arg = defaults.get(PORT_ARGUMENT_NAME);
	if (arg == null) {
		throw new IllegalStateException("Could not find port argument");
	}
	arg.setValue(Integer.toString(port));
	
	// Attach
	try {
		System.out.println("Connector arguments: " + defaults);
		return connector.attach(defaults);
	} catch (IllegalConnectorArgumentsException e) {
		throw new IllegalArgumentException("Illegal connector arguments", e);
	}
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:34,代码来源:JDIRedefiner.java

示例2: tryDebug

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ProcessAttachTest.java

示例3: attach

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
public PermissionDebugger attach() throws IOException, IllegalConnectorArgumentsException {
  VirtualMachineManager vmm = Bootstrap.virtualMachineManager();

  List<AttachingConnector> connectors = vmm.attachingConnectors();
  AttachingConnector connector =
      connectors
          .stream()
          .filter(c -> c.transport().name().equals(transport))
          .findFirst()
          .orElseThrow(
              () -> new IOException(String.format("Failed to find transport %s", transport)));

  Map<String, Argument> map = connector.defaultArguments();
  Argument portArg = map.get(PORT_KEY);
  portArg.setValue(port);
  map.put(PORT_KEY, portArg);
  vm = connector.attach(map);

  return this;
}
 
开发者ID:coyotesqrl,项目名称:acdebugger,代码行数:21,代码来源:PermissionDebugger.java

示例4: HotSwapperJpda

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
/**
 * Connects to the JVM.
 *
 * @param port the port number used for the connection to the JVM.
 */
public HotSwapperJpda(String port)
        throws IOException, IllegalConnectorArgumentsException {
    jvm = null;
    request = null;
    newClassFiles = null;
    trigger = new Trigger();
    AttachingConnector connector
            = (AttachingConnector) findConnector("com.sun.jdi.SocketAttach");

    Map arguments = connector.defaultArguments();
    ((Connector.Argument) arguments.get("hostname")).setValue(HOST_NAME);
    ((Connector.Argument) arguments.get("port")).setValue(port);
    jvm = connector.attach(arguments);
    EventRequestManager manager = jvm.eventRequestManager();
    request = methodEntryRequests(manager, TRIGGER_NAME);
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:22,代码来源:HotSwapperJpda.java

示例5: getArgs

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
private static Map<String,? extends Argument> getArgs (
    AttachingConnector attachingConnector,
    String hostName,
    int portNumber
) {
    Map<String,? extends Argument> args = attachingConnector.defaultArguments ();
    args.get ("hostname").setValue (hostName);
    args.get ("port").setValue ("" + portNumber);
    return args;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AttachingDICookie.java

示例6: main

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的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.");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:ProcessAttachDebugger.java

示例7: attachDebugger

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
public static VirtualMachine attachDebugger(String hostname, int port) {
    VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
    AttachingConnector atconn = null;
    for(AttachingConnector c: vmm.attachingConnectors())
        if("dt_socket".equalsIgnoreCase(c.transport().name())) {
            atconn = c;
        }
    Map<String, Connector.Argument> prm = atconn.defaultArguments();
    prm.get("hostname").setValue(hostname);
    prm.get("port").setValue(Integer.toString(port));
    VirtualMachine vm2 = null;
    try {
        vm2 = atconn.attach(prm);

        ///for(ThreadReference t: vm2.allThreads()) {
        //    log.info(t.name());
        //    if (t.name().equals("main"))
        //        t.suspend();
        //}
        vm2.resume();
    } catch(Exception e) {
        e.printStackTrace();
        //throw new RuntimeException(e);
    }

    return vm2;
}
 
开发者ID:uwdb,项目名称:pipegen,代码行数:28,代码来源:Debugger.java

示例8: connect

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
private VirtualMachine connect(AttachingConnector connector, String port)
        throws IllegalConnectorArgumentsException,
        IOException {
    Map<String, Connector.Argument> args = connector.defaultArguments();
    Connector.Argument pidArgument = args.get("port");
    if (pidArgument == null) {
        throw new IllegalStateException();
    }
    pidArgument.setValue(port);

    return connector.attach(args);
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:13,代码来源:VMAcquirer.java

示例9: main

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的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
    Process process1 = launch(address, true, "HelloWorld");

    // give first debuggee time to suspend
    Thread.currentThread().sleep(5000);

    // launch a second debuggee with the same address
    Process process2 = launch(address, false, "HelloWorld");

    // get exit status from second debuggee
    int exitCode = 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");
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:37,代码来源:ExclusiveBind.java

示例10: connect

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
private VirtualMachine connect(int port) throws IOException {
    VirtualMachineManager manager = Bootstrap.virtualMachineManager();

    // Find appropiate connector
    List<AttachingConnector> connectors = manager.attachingConnectors();
    AttachingConnector chosenConnector = null;
    for (AttachingConnector c : connectors) {
        if (c.transport().name().equals(TRANSPORT_NAME)) {
            chosenConnector = c;
            break;
        }
    }
    if (chosenConnector == null) {
        throw new IllegalStateException("Could not find socket connector");
    }

    // Set port argument
    AttachingConnector connector = chosenConnector;
    Map<String, Argument> defaults = connector.defaultArguments();
    Argument arg = defaults.get(PORT_ARGUMENT_NAME);
    if (arg == null) {
        throw new IllegalStateException("Could not find port argument");
    }
    arg.setValue(Integer.toString(port));

    // Attach
    try {
        System.out.println("Connector arguments: " + defaults);
        return connector.attach(defaults);
    } catch (IllegalConnectorArgumentsException e) {
        throw new IllegalArgumentException("Illegal connector arguments", e);
    }
}
 
开发者ID:erkieh,项目名称:proxyhotswap,代码行数:34,代码来源:JDIRedefiner.java

示例11: connectorArguments

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
/**
 * Set the socket-attaching connector's arguments.
 *
 * @param connector A socket-attaching connector
 * @return The socket-attaching connector's arguments
 */
private Map<String, Connector.Argument> connectorArguments(
        AttachingConnector connector) {
    Map<String, Connector.Argument> arguments = connector
            .defaultArguments();

    arguments.get("hostname").setValue(socketAddress.getHostName());
    arguments.get("port").setValue(
            Integer.toString(socketAddress.getPort()));

    return arguments;
}
 
开发者ID:adrianherrera,项目名称:jdivisitor,代码行数:18,代码来源:RemoteVMConnector.java

示例12: connect

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的package包/类
private VirtualMachine connect(
    AttachingConnector connector, String port)
    throws IllegalConnectorArgumentsException,
    IOException {
  Map<String, AttachingConnector.Argument> args = connector
      .defaultArguments();
  AttachingConnector.Argument pidArgument = args.get("port");
  if (pidArgument == null) {
    throw new IllegalStateException();
  }
  pidArgument.setValue(port);

  return connector.attach(args);
}
 
开发者ID:gravel-st,项目名称:gravel,代码行数:15,代码来源:VMAcquirer.java

示例13: main

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:50,代码来源:RunToExit.java

示例14: main

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:42,代码来源:ExclusiveBind.java

示例15: main

import com.sun.jdi.connect.AttachingConnector; //导入方法依赖的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.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:RunToExit.java


注:本文中的com.sun.jdi.connect.AttachingConnector.defaultArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。