protected Connector findConnector(String connectorName) { // List connectors = // com.sun.jdi.Bootstrap.virtualMachineManager().allConnectors(); List connectors = org.eclipse.jdi.Bootstrap.virtualMachineManager().allConnectors(); // // debug: code to list available connectors // Iterator iter2 = connectors.iterator(); // while (iter2.hasNext()) { // Connector connector = (Connector)iter2.next(); // System.out.println("connector name is " + connector.name()); // } for (Object c : connectors) { Connector connector = (Connector) c; // System.out.println(connector.name()); // } // Iterator iter = connectors.iterator(); // while (iter.hasNext()) { // Connector connector = (Connector)iter.next(); if (connector.name().equals(connectorName)) { return connector; } } Base.showError( "Compiler Error", "findConnector() failed to find " + connectorName + " inside Runner", null); return null; // Not reachable }
private Connector findConnector(String name) { for (Connector connector : Bootstrap.virtualMachineManager().allConnectors()) { if (connector.name().equals(name)) { return connector; } } return null; }
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(); }
/* * Find Connector by name */ private static Connector findConnector(String name) { List connectors = Bootstrap.virtualMachineManager().allConnectors(); Iterator iter = connectors.iterator(); while (iter.hasNext()) { Connector connector = (Connector) iter.next(); if (connector.name().equals(name)) { return connector; } } return null; }
private Map<String, com.sun.jdi.connect.Connector.Argument> parseConnectorArgs( Connector connector, String argString) { Map<String, com.sun.jdi.connect.Connector.Argument> arguments = connector.defaultArguments(); /* * We are parsing strings of the form: * name1=value1,[name2=value2,...] * However, the value1...valuen substrings may contain * embedded comma(s), so make provision for quoting inside * the value substrings. (Bug ID 4285874) */ String regexPattern = "(quote=[^,]+,)|" + // special case for quote=., "(\\w+=)" + // name= "(((\"[^\"]*\")|" + // ( "l , ue" "('[^']*')|" + // 'l , ue' "([^,'\"]+))+,)"; // v a l u e )+ , Pattern p = Pattern.compile(regexPattern); Matcher m = p.matcher(argString); while (m.find()) { int startPosition = m.start(); int endPosition = m.end(); if (startPosition > 0) { /* * It is an error if parsing skips over any part of argString. */ throw new IllegalArgumentException( MessageOutput.format("Illegal connector argument", argString)); } String token = argString.substring(startPosition, endPosition); int index = token.indexOf('='); String name = token.substring(0, index); String value = token.substring(index + 1, token.length() - 1); // Remove comma delimiter /* * for values enclosed in quotes (single and/or double quotes) * strip off enclosing quote chars * needed for quote enclosed delimited substrings */ if (name.equals("options")) { StringBuilder sb = new StringBuilder(); for (String s : splitStringAtNonEnclosedWhiteSpace(value)) { while (isEnclosed(s, "\"") || isEnclosed(s, "'")) { s = s.substring(1, s.length() - 1); } sb.append(s); sb.append(" "); } value = sb.toString(); } Connector.Argument argument = arguments.get(name); if (argument == null) { throw new IllegalArgumentException( MessageOutput.format( "Argument is not defined for connector:", new Object[] {name, connector.name()})); } argument.setValue(value); argString = argString.substring(endPosition); // Remove what was just parsed... m = p.matcher(argString); // and parse again on what is left. } if ((!argString.equals(",")) && (argString.length() > 0)) { /* * It is an error if any part of argString is left over, * unless it was empty to begin with. */ throw new IllegalArgumentException( MessageOutput.format("Illegal connector argument", argString)); } return arguments; }