Java 类com.sun.jdi.connect.IllegalConnectorArgumentsException 实例源码

项目:HotswapAgent    文件:JDIRedefiner.java   
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);
    }
}
项目:incubator-netbeans    文件:LineBreakpointTest.java   
private void doTestBreakpointComplete (
    int line, 
    String condition, 
    int conditionResult
) throws IOException, IllegalConnectorArgumentsException,
DebuggerStartException {
    try {
        LineBreakpoint lb = doTestBreakpoint (
            line, 
            condition, 
            conditionResult
        );
        if ( condition == null || 
             conditionResult == JPDABreakpointEvent.CONDITION_TRUE
        ) {
            support.doContinue();
            support.waitState (JPDADebugger.STATE_DISCONNECTED);
        }
        DebuggerManager.getDebuggerManager ().removeBreakpoint (lb);
    } finally {
        if (support != null) support.doFinish();
    }
}
项目:OpenJSharp    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:jdk8u-jdk    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:openjdk-jdk10    文件:RawCommandLineLauncher.java   
public VirtualMachine
    launch(Map<String, ? extends Connector.Argument> arguments)
    throws IOException, IllegalConnectorArgumentsException,
           VMStartException
{
    String command = argument(ARG_COMMAND, arguments).value();
    String address = argument(ARG_ADDRESS, arguments).value();
    String quote = argument(ARG_QUOTE, arguments).value();

    if (quote.length() > 1) {
        throw new IllegalConnectorArgumentsException("Invalid length",
                                                     ARG_QUOTE);
    }

    TransportService.ListenKey listener = transportService.startListening(address);

    try {
        return launch(tokenizeCommand(command, quote.charAt(0)),
                      address, listener, transportService);
    } finally {
        transportService.stopListening(listener);
    }
}
项目:openjdk-jdk10    文件:SocketListeningConnector.java   
public String
    startListening(Map<String,? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    String port = argument(ARG_PORT, args).value();
    String localaddr = argument(ARG_LOCALADDR, args).value();

    // default to system chosen port
    if (port.length() == 0) {
        port = "0";
    }

    if (localaddr.length() > 0) {
       localaddr = localaddr + ":" + port;
    } else {
       localaddr = port;
    }

    return super.startListening(localaddr, args);
}
项目:openjdk-jdk10    文件:ProcessAttachTest.java   
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();
}
项目:java-debug    文件:DebugUtility.java   
/**
 * Launch a debuggee in suspend mode.
 * @see {@link #launch(VirtualMachineManager, String, String, String, String, String)}
 */
public static IDebugSession launch(VirtualMachineManager vmManager,
        String mainClass,
        String programArguments,
        String vmArguments,
        List<String> modulePaths,
        List<String> classPaths,
        String cwd,
        String[] envVars)
        throws IOException, IllegalConnectorArgumentsException, VMStartException {
    return DebugUtility.launch(vmManager,
            mainClass,
            programArguments,
            vmArguments,
            String.join(File.pathSeparator, modulePaths),
            String.join(File.pathSeparator, classPaths),
            cwd,
            envVars);
}
项目:acdebugger    文件:PermissionDebugger.java   
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;
}
项目:openjdk9    文件:ProcessAttachTest.java   
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();
}
项目:jdk8u_jdk    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:lookaside_java-1.8.0-openjdk    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:tracing-framework    文件:JDWPAgent.java   
/** Try to get an instrumentation instance using JDWP */
public static synchronized JDWPAgent get() throws IOException, IllegalConnectorArgumentsException {
    // There can be only one
    if (instance != null) {
        return instance;
    }

    // Get the JDWP port
    Properties props = sun.misc.VMSupport.getAgentProperties();
    String jdwp_address = props.getProperty("sun.jdwp.listenerAddress");

    // If no JDWP address, then the debug argument isn't included
    if (jdwp_address == null) {
        System.err.println("Could not acquire JDWP address to attach dynamic instrumentation. "
                + "Ensure JVM runs with argument -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0");
        return null;
    }

    // Extract the port and return the instance;
    System.out.println("JDWPAgent started with address " + jdwp_address);
    String jdwp_port = jdwp_address.substring(jdwp_address.lastIndexOf(':') + 1);
    instance = new JDWPAgent(jdwp_port);
    return instance;
}
项目:tracing-framework    文件:TestJDWPAgentDebug.java   
@Test
public void testBadModification2() throws ClassNotFoundException, AgentLoadException, AgentInitializationException, IOException, AttachNotSupportedException, UnmodifiableClassException, IllegalConnectorArgumentsException {
    // Rewrite method
    DynamicModification badModification = new DynamicModification() {
        public Collection<String> affects() {
            return Lists.newArrayList(TestJDWPAgentDebug.class.getName());
        }
        public void apply(ClassPool arg0) throws NotFoundException, CannotCompileException {
            CtClass cls = arg0.getCtClass(TestJDWPAgentDebug.class.getName());
            cls.getMethods()[0].insertBefore("definitely not code...");
        }
    };
    JDWPAgent dynamic = JDWPAgent.get();
    // Modification should just be ignored since it throws a notfoundexception
    try {
        dynamic.install(badModification);
        fail();
    } catch (CannotCompileException e) {
    }
}
项目:infobip-open-jdk-8    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:jdk8u-dev-jdk    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:jdk7-jdk    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:openjdk-source-code-learn    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:OLD-OpenJDK8    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:openjdk-jdk7u-jdk    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:openjdk-icedtea7    文件:ChildSession.java   
static private VirtualMachine generalGetVM(OutputListener diagnostics,
                                           LaunchingConnector connector,
                                           Map<String, Connector.Argument> arguments) {
    VirtualMachine vm = null;
    try {
        diagnostics.putString("Starting child.");
        vm = connector.launch(arguments);
    } catch (IOException ioe) {
        diagnostics.putString("Unable to start child: " + ioe.getMessage());
    } catch (IllegalConnectorArgumentsException icae) {
        diagnostics.putString("Unable to start child: " + icae.getMessage());
    } catch (VMStartException vmse) {
        diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
        dumpFailedLaunchInfo(diagnostics, vmse.process());
    }
    return vm;
}
项目:HotswapAgent    文件:HotSwapperJpda.java   
/**
 * 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);
}
项目:incubator-netbeans    文件:AttachingDICookie.java   
/**
 * Creates a new instance of VirtualMachine for this DebuggerInfo Cookie.
 *
 * @return a new instance of VirtualMachine for this DebuggerInfo Cookie
 * @throws java.io.IOException when unable to attach.
 * @throws IllegalConnectorArgumentsException when some connector argument is invalid.
 */
@Override
public VirtualMachine getVirtualMachine () throws IOException,
IllegalConnectorArgumentsException {
    try {
        return attachingConnector.attach (args);
    } catch (IOException ioex) {
        String msg = "Attaching Connector = "+attachingConnector+", arguments = "+args; // NOI18N
        logger.log(Level.INFO, msg, ioex);
        throw ioex;
    }
}
项目:incubator-netbeans    文件:LineBreakpointTest.java   
private void doTestBreakpointComplete (int line) throws IOException, 
IllegalConnectorArgumentsException, DebuggerStartException {
    doTestBreakpointComplete (
        line, 
        null, 
        JPDABreakpointEvent.CONDITION_NONE
    );
}
项目:incubator-netbeans    文件:LineBreakpointTest.java   
private LineBreakpoint doTestBreakpoint (
    int         line, 
    String      condition, 
    int         conditionResult
) throws IOException, IllegalConnectorArgumentsException, 
DebuggerStartException {
    JPDASupport.removeAllBreakpoints ();
    LineBreakpoint lb = LineBreakpoint.create (TEST_APP, line);
    /*
    if (73 <= line && line <= 98) {
        lb.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$InnerStatic");
    } else if (100 <= line && line <= 115) {
        lb.setPreferredClassName("org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp$Inner");
    }
     */
    lb.setCondition (condition);
    TestBreakpointListener tbl = new TestBreakpointListener 
        (lb, conditionResult);
    lb.addJPDABreakpointListener (tbl);
    DebuggerManager.getDebuggerManager ().addBreakpoint (lb);

    support = JPDASupport.attach (
        "org.netbeans.api.debugger.jpda.testapps.LineBreakpointApp"
    );

    if ( condition == null || 
         conditionResult == JPDABreakpointEvent.CONDITION_TRUE
    ) {
        support.waitState (JPDADebugger.STATE_STOPPED);
    } else {
        support.waitState (JPDADebugger.STATE_DISCONNECTED);
    }

    tbl.checkResult ();
    return lb;
}
项目:jdk8u-jdk    文件:SimpleLaunchingConnector.java   
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
项目:openjdk-jdk10    文件:GenericListeningConnector.java   
public String startListening(String address, Map<String,? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    TransportService.ListenKey listener = listenMap.get(args);
    if (listener != null) {
       throw new IllegalConnectorArgumentsException("Already listening",
           new ArrayList<>(args.keySet()));
    }

    listener = transportService.startListening(address);
    listenMap.put(args, listener);
    return listener.address();
}
项目:openjdk-jdk10    文件:GenericListeningConnector.java   
public String
    startListening(Map<String, ? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    String address = argument(ARG_ADDRESS, args).value();
    return startListening(address, args);
}
项目:openjdk-jdk10    文件:GenericListeningConnector.java   
public void stopListening(Map<String, ? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    TransportService.ListenKey listener = listenMap.get(args);
    if (listener == null) {
       throw new IllegalConnectorArgumentsException("Not listening",
           new ArrayList<>(args.keySet()));
    }
    transportService.stopListening(listener);
    listenMap.remove(args);
}
项目:openjdk-jdk10    文件:GenericListeningConnector.java   
public VirtualMachine
    accept(Map<String, ? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    String ts = argument(ARG_TIMEOUT, args).value();
    int timeout = 0;
    if (ts.length() > 0) {
        timeout = Integer.decode(ts).intValue();
    }

    TransportService.ListenKey listener = listenMap.get(args);
    Connection connection;
    if (listener != null) {
        connection = transportService.accept(listener, timeout, 0);
    } else {
        /*
         * Keep compatibility with previous releases - if the
         * debugger hasn't called startListening then we do a
         * once-off accept
         */
         startListening(args);
         listener = listenMap.get(args);
         assert listener != null;
         connection = transportService.accept(listener, timeout, 0);
         stopListening(args);
    }
    return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
}
项目:openjdk-jdk10    文件:SocketAttachingConnector.java   
public VirtualMachine
    attach(Map<String, ? extends Connector.Argument> arguments)
    throws IOException, IllegalConnectorArgumentsException
{
    String host = argument(ARG_HOST, arguments).value();
    if (host.length() > 0) {
        host = host + ":";
    }
    String address = host + argument(ARG_PORT, arguments).value();
    return super.attach(address, arguments);
}
项目:openjdk-jdk10    文件:GenericAttachingConnector.java   
/**
 * Attach to a target VM using the specified address and Connector arguments.
 */
public VirtualMachine attach(String address, Map<String, ? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    String ts  = argument(ARG_TIMEOUT, args).value();
    int timeout = 0;
    if (ts.length() > 0) {
        timeout = Integer.decode(ts).intValue();
    }
    Connection connection = transportService.attach(address, timeout, 0);
    return Bootstrap.virtualMachineManager().createVirtualMachine(connection);
}
项目:openjdk-jdk10    文件:GenericAttachingConnector.java   
/**
 * Attach to a target VM using the specified arguments - the address
 * of the target VM is specified by the <code>address</code> connector
 * argument.
 */
public VirtualMachine attach(Map<String, ? extends Connector.Argument> args)
    throws IOException, IllegalConnectorArgumentsException
{
    String address = argument(ARG_ADDRESS, args).value();
    return attach(address, args);
}
项目:openjdk-jdk10    文件:SimpleLaunchingConnector.java   
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
项目:openjdk9    文件:SimpleLaunchingConnector.java   
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
项目:google-cloud-eclipse    文件:SocketListeningMultiConnectorImpl.java   
/**
 * Listens for one or more connections initiated by target VMs.
 * 
 * @return Returns the address at which the connector is listening for a
 *         connection.
 */
@Override
public String startListening(Map<String, ? extends Connector.Argument> connectionArgs)
        throws IOException, IllegalConnectorArgumentsException {
    getConnectionArguments(connectionArgs);
    String result = null;
    try {
        result = ((SocketTransportImpl) fTransport).startListening(fPort);
    } catch (IllegalArgumentException e) {
        throw new IllegalConnectorArgumentsException(
                ConnectMessages.SocketListeningConnectorImpl_ListeningConnector_Socket_Port, "port"); //$NON-NLS-1$
    }
    return result;
}
项目:google-cloud-eclipse    文件:SocketListeningMultiConnectorImpl.java   
/**
 * Waits for a target VM to attach to this connector.
 * 
 * @return Returns a connected Virtual Machine.
 */
@Override
public VirtualMachine accept(Map<String, ? extends Connector.Argument> connectionArgs)
        throws IOException, IllegalConnectorArgumentsException {
    getConnectionArguments(connectionArgs);
    SocketConnection connection = (SocketConnection) ((SocketTransportImpl) fTransport).accept(fTimeout, 0);
    return establishedConnection(connection);
}
项目:jdk8u_jdk    文件:SimpleLaunchingConnector.java   
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
项目:lookaside_java-1.8.0-openjdk    文件:SimpleLaunchingConnector.java   
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws
                          IOException,
                          IllegalConnectorArgumentsException,
                          VMStartException {

    /*
     * Get the class name that we are to execute
     */
    String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value();
    if (className.length() == 0) {
        throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME);
    }

    /*
     * Listen on an emperical port; launch the debuggee; wait for
     * for the debuggee to connect; stop listening;
     */
    TransportService.ListenKey key = ts.startListening();

    String exe = System.getProperty("java.home") + File.separator + "bin" +
        File.separator + "java";
    String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" +
        key.address() +
        " -classpath " + System.getProperty("test.classes") +
        " " + className;
    Process process = Runtime.getRuntime().exec(cmd);
    Connection conn = ts.accept(key, 30*1000, 9*1000);
    ts.stopListening(key);

    /*
     * Debugee is connected - return the virtual machine mirror
     */
    return Bootstrap.virtualMachineManager().createVirtualMachine(conn);
}
项目:tracing-framework    文件:TestJDWPAgentDebug.java   
@Test
public void testBadModification() throws ClassNotFoundException, AgentLoadException, AgentInitializationException, IOException, AttachNotSupportedException, UnmodifiableClassException, CannotCompileException, IllegalConnectorArgumentsException {
    // Rewrite method
    DynamicModification badModification = new DynamicModification() {
        public Collection<String> affects() {
            return Lists.newArrayList(TestJDWPAgentDebug.class.getName());
        }
        public void apply(ClassPool arg0) throws NotFoundException, CannotCompileException {
            arg0.getCtClass("edu.brown.cs.systems.pivottracing.dynamicinstrumentation.NotaRealClass");
        }
    };
    JDWPAgent dynamic = JDWPAgent.get();
    // Modification should just be ignored since it throws a notfoundexception
    dynamic.install(badModification);
}