Java 类com.sun.jdi.Bootstrap 实例源码

项目: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    文件:ListeningDICookie.java   
private static ListeningConnector findListeningConnector (String s) {
    Iterator iter = Bootstrap.virtualMachineManager ().
        listeningConnectors ().iterator ();
    while (iter.hasNext ()) {
        ListeningConnector ac = (ListeningConnector) iter.next ();
        if (ac.transport() != null && ac.transport ().name ().toLowerCase ().indexOf (s) > -1)
            return ac;
    }
    return null;
}
项目:OpenJSharp    文件: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);
}
项目:MaxSim    文件:SADebugServerAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByServerMethod =
                        vmImplClass.getMethod(
                               "createVirtualMachineForServer",
                               new Class[] {
                                   VirtualMachineManager.class,
                                   String.class,
                                   Integer.TYPE
                               });
    return (VirtualMachine) connectByServerMethod.invoke(null,
                               new Object[] {
                                   Bootstrap.virtualMachineManager(),
                                   debugServerName,
                                   new Integer(0)
                               });
}
项目:MaxSim    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:jdk8u-jdk    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:openjdk-jdk10    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目: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    文件:DebugSessionFactory.java   
public static IDebugSession getDebugSession(String projectName, String mainClass) throws Exception {
    setupProject(projectName);
    return debugSessionMap.computeIfAbsent(projectName, (name) -> {
        String projectRoot = new File(rootPath, name).getAbsolutePath();
        try {
            final IDebugSession debugSession = DebugUtility.launch(Bootstrap.virtualMachineManager(), mainClass, "", "",
                    null, new File(projectRoot, "bin").getAbsolutePath(), null, null);
            debugSession.getEventHub().events().subscribe(debugEvent -> {
                if (debugEvent.event instanceof VMDisconnectEvent) {
                    try {
                        debugSession.getEventHub().close();
                    } catch (Exception e) {
                        // do nothing.
                    }
                }
            });
            return debugSession;
        } catch (Exception ex) {
            return null;
        }
    });
}
项目: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    文件:SADebugServerAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByServerMethod =
                        vmImplClass.getMethod(
                               "createVirtualMachineForServer",
                               new Class[] {
                                   VirtualMachineManager.class,
                                   String.class,
                                   Integer.TYPE
                               });
    return (VirtualMachine) connectByServerMethod.invoke(null,
                               new Object[] {
                                   Bootstrap.virtualMachineManager(),
                                   debugServerName,
                                   new Integer(0)
                               });
}
项目:openjdk9    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:openjdk9    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目: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    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SADebugServerAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByServerMethod =
                        vmImplClass.getMethod(
                               "createVirtualMachineForServer",
                               new Class[] {
                                   VirtualMachineManager.class,
                                   String.class,
                                   Integer.TYPE
                               });
    return (VirtualMachine) connectByServerMethod.invoke(null,
                               new Object[] {
                                   Bootstrap.virtualMachineManager(),
                                   debugServerName,
                                   new Integer(0)
                               });
}
项目:lookaside_java-1.8.0-openjdk    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:lookaside_java-1.8.0-openjdk    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:infobip-open-jdk-8    文件:SADebugServerAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByServerMethod =
                        vmImplClass.getMethod(
                               "createVirtualMachineForServer",
                               new Class[] {
                                   VirtualMachineManager.class,
                                   String.class,
                                   Integer.TYPE
                               });
    return (VirtualMachine) connectByServerMethod.invoke(null,
                               new Object[] {
                                   Bootstrap.virtualMachineManager(),
                                   debugServerName,
                                   new Integer(0)
                               });
}
项目:infobip-open-jdk-8    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:infobip-open-jdk-8    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:jdk8u-dev-jdk    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:jdk7-jdk    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:openjdk-source-code-learn    文件:SADebugServerAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByServerMethod =
                        vmImplClass.getMethod(
                               "createVirtualMachineForServer",
                               new Class[] {
                                   VirtualMachineManager.class,
                                   String.class,
                                   Integer.TYPE
                               });
    return (VirtualMachine) connectByServerMethod.invoke(null,
                               new Object[] {
                                   Bootstrap.virtualMachineManager(),
                                   debugServerName,
                                   new Integer(0)
                               });
}
项目:openjdk-source-code-learn    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:openjdk-source-code-learn    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:OLD-OpenJDK8    文件:SADebugServerAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByServerMethod =
                        vmImplClass.getMethod(
                               "createVirtualMachineForServer",
                               new Class[] {
                                   VirtualMachineManager.class,
                                   String.class,
                                   Integer.TYPE
                               });
    return (VirtualMachine) connectByServerMethod.invoke(null,
                               new Object[] {
                                   Bootstrap.virtualMachineManager(),
                                   debugServerName,
                                   new Integer(0)
                               });
}
项目:OLD-OpenJDK8    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:OLD-OpenJDK8    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:JAVA_UNIT    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:openjdk-icedtea7    文件:SADebugServerAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String debugServerName)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByServerMethod =
                        vmImplClass.getMethod(
                               "createVirtualMachineForServer",
                               new Class[] {
                                   VirtualMachineManager.class,
                                   String.class,
                                   Integer.TYPE
                               });
    return (VirtualMachine) connectByServerMethod.invoke(null,
                               new Object[] {
                                   Bootstrap.virtualMachineManager(),
                                   debugServerName,
                                   new Integer(0)
                               });
}
项目:openjdk-icedtea7    文件:SACoreAttachingConnector.java   
private VirtualMachine createVirtualMachine(Class vmImplClass,
                                            String javaExec, String corefile)
    throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
                             "createVirtualMachineForCorefile",
                              new Class[] {
                                  VirtualMachineManager.class,
                                  String.class, String.class,
                                  Integer.TYPE
                              });
    return (VirtualMachine) connectByCoreMethod.invoke(null,
                              new Object[] {
                                  Bootstrap.virtualMachineManager(),
                                  javaExec,
                                  corefile,
                                  new Integer(0)
                              });
}
项目:openjdk-icedtea7    文件:AcceptTimeout.java   
public static void main(String args[]) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc: connectors) {
        Map<String,Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout");

        /*
         * If the Connector has a argument named "timeout" then we set the timeout to 1 second
         * and start it listening on its default address. It should throw TranpsortTimeoutException.
         */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);

            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
项目:proactive-component-monitoring    文件:TestHeartbeat.java   
@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);
}
项目:incubator-netbeans    文件:LaunchingDICookie.java   
private static LaunchingConnector findLaunchingConnector () {
    Iterator<LaunchingConnector> iter = Bootstrap.virtualMachineManager ().
        launchingConnectors ().iterator ();
    while (iter.hasNext ()) {
        LaunchingConnector lc = iter.next ();
        if (lc.name ().indexOf ("RawCommandLineLaunch") > -1)
            return lc;
    }
    return null;
}
项目:OpenJSharp    文件:Trace.java   
/**
 * Find a com.sun.jdi.CommandLineLaunch connector
 */
LaunchingConnector findLaunchingConnector() {
    List<Connector> connectors = Bootstrap.virtualMachineManager().allConnectors();
    for (Connector connector : connectors) {
        if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) {
            return (LaunchingConnector)connector;
        }
    }
    throw new Error("No launching connector");
}
项目:MaxSim    文件:FieldMonitor.java   
/**
 * Find a com.sun.jdi.CommandLineLaunch connector
 */
static LaunchingConnector findLaunchingConnector() {
  List <Connector> connectors = Bootstrap.virtualMachineManager().allConnectors();
  Iterator <Connector> iter = connectors.iterator();
  while (iter.hasNext()) {
    Connector connector = iter.next();
    if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) {
      return (LaunchingConnector)connector;
    }
  }
  throw new Error("No launching connector");
}
项目:jdk8u-jdk    文件:Trace.java   
/**
 * Find a com.sun.jdi.CommandLineLaunch connector
 */
LaunchingConnector findLaunchingConnector() {
    List<Connector> connectors = Bootstrap.virtualMachineManager().allConnectors();
    for (Connector connector : connectors) {
        if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) {
            return (LaunchingConnector)connector;
        }
    }
    throw new Error("No launching connector");
}
项目:jdk8u-jdk    文件: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);
}
项目:jdk8u-jdk    文件:ListConnectors.java   
public void list() {
    List<Connector> l = Bootstrap.virtualMachineManager().allConnectors();

    for(Connector c: l) {
        System.out.println(c.name());
    }
}