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


Java AttachingConnector类代码示例

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


AttachingConnector类属于com.sun.jdi.connect包,在下文中一共展示了AttachingConnector类的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: AttachingDICookie

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private AttachingDICookie (
    AttachingConnector attachingConnector,
    Map<String,? extends Argument> args
) {
    this.attachingConnector = attachingConnector;
    this.args = args;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:AttachingDICookie.java

示例6: create

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
/**
 * Creates a new instance of AttachingDICookie for given parameters.
 *
 * @param attachingConnector a connector to be used
 * @param args map of arguments
 * @return a new instance of AttachingDICookie for given parameters
 */
public static AttachingDICookie create (
    AttachingConnector attachingConnector,
    Map<String,? extends Argument> args
) {
    return new AttachingDICookie (
        attachingConnector, 
        args
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AttachingDICookie.java

示例7: 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

示例8: 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

示例9: 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

示例10: connect

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
/**
 * Call this with the localhost port to connect to.
 */
public VirtualMachine connect(int port)
        throws IOException {
    String strPort = Integer.toString(port);
    AttachingConnector connector = getConnector();
    try {
        return connect(connector, strPort);
    } catch (IllegalConnectorArgumentsException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:14,代码来源:VMAcquirer.java

示例11: getConnector

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private AttachingConnector getConnector() {
    VirtualMachineManager vmManager = Bootstrap.virtualMachineManager();
    for (Connector connector : vmManager.attachingConnectors()) {
        if ("com.sun.jdi.SocketAttach".equals(connector.name())) {
            return (AttachingConnector) connector;
        }
    }
    throw new IllegalStateException();
}
 
开发者ID:SpoonLabs,项目名称:nopol,代码行数:10,代码来源:VMAcquirer.java

示例12: connector

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private AttachingConnector connector(String connectorName) {
  for (AttachingConnector c : Bootstrap.virtualMachineManager().attachingConnectors()) {
    if (connectorName.equals(c.name())) {
      return c;
    }
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:JavaDebugger.java

示例13: makePlatformConnector

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static AttachingConnector makePlatformConnector() {
    Class connectorClass = null;
    try {
        connectorClass = Class.forName(SHAREDMEM_ATTACHING_CONN);
    } catch (ClassNotFoundException cnfe) {
    }
    if (connectorClass == null) {
        throw new RuntimeException("can not load class: " + SHAREDMEM_ATTACHING_CONN);
    }
    try {
        return (AttachingConnector) connectorClass.newInstance();
    } catch (Exception exp) {
        throw new RuntimeException(exp);
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:16,代码来源:F3SharedMemoryAttachingConnector.java

示例14: makePlatformConnector

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static AttachingConnector makePlatformConnector() {
    Class connectorClass = null;
    try {
        connectorClass = Class.forName(SOCKET_ATTACHING_CONN);
    } catch (ClassNotFoundException cnfe) {}
    if (connectorClass == null) {
        throw new RuntimeException("can not load class: " + SOCKET_ATTACHING_CONN);
    }
    try {
        return (AttachingConnector) connectorClass.newInstance();
    } catch (Exception exp) {
        throw new RuntimeException(exp);
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:15,代码来源:F3SocketAttachingConnector.java

示例15: makePlatformConnector

import com.sun.jdi.connect.AttachingConnector; //导入依赖的package包/类
private static AttachingConnector makePlatformConnector() {
    Class connectorClass = null;
    try {
        connectorClass = Class.forName(PROCESS_ATTACHING_CONN);
    } catch (ClassNotFoundException cnfe) {
    }
    if (connectorClass == null) {
        throw new RuntimeException("can not load class: " + PROCESS_ATTACHING_CONN);
    }
    try {
        return (AttachingConnector) connectorClass.newInstance();
    } catch (Exception exp) {
        throw new RuntimeException(exp);
    }
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:16,代码来源:F3ProcessAttachingConnector.java


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