src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java
Print this page
rev 5151 : 7154809: JDI: update JDI/JDB debugee commandline option parsing (allow
nested comma delimited options)
Summary: update debugee commandline parsing to allow for delimited suboptions
Reviewed-by:
@@ -111,10 +111,25 @@
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
+ /*
+ * unquote values for options (single and/or double quotes)
+ * needed for quote enclosed delimited substrings
+ */
+ if (name.equals("options")) {
+ StringBuilder sb = new StringBuilder();
+ for (String s : value.split("\\s+")) {
+ 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:",
@@ -134,10 +149,20 @@
(MessageOutput.format("Illegal connector argument", argString));
}
return arguments;
}
+ private static boolean isEnclosed(String value, String enclosingChar) {
+ if (value.indexOf(enclosingChar) == 0) {
+ int lastIndex = value.lastIndexOf(enclosingChar);
+ if (lastIndex > 0 && lastIndex == value.length() - 1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
VMConnection(String connectSpec, int traceFlags) {
String nameString;
String argString;
int index = connectSpec.indexOf(':');
if (index == -1) {