1.1 --- a/src/share/classes/com/sun/tools/javac/main/Option.java Mon Dec 10 12:10:50 2012 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/main/Option.java Mon Dec 10 16:21:26 2012 +0000 1.3 @@ -167,7 +167,6 @@ 1.4 ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) { 1.5 @Override 1.6 public boolean process(OptionHelper helper, String option, String operand) { 1.7 -// System.err.println("process encoding " + operand); 1.8 return super.process(helper, option, operand); 1.9 } 1.10 1.11 @@ -246,9 +245,7 @@ 1.12 } 1.13 }, 1.14 1.15 - A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC) { 1.16 - { hasSuffix = true; } 1.17 - 1.18 + A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) { 1.19 @Override 1.20 public boolean matches(String arg) { 1.21 return arg.startsWith("-A"); 1.22 @@ -293,8 +290,6 @@ 1.23 // This option exists only for the purpose of documenting itself. 1.24 // It's actually implemented by the launcher. 1.25 J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) { 1.26 - { hasSuffix = true; } 1.27 - 1.28 @Override 1.29 public boolean process(OptionHelper helper, String option) { 1.30 throw new AssertionError 1.31 @@ -302,10 +297,6 @@ 1.32 } 1.33 }, 1.34 1.35 - // stop after parsing and attributing. 1.36 - // new HiddenOption("-attrparseonly"), 1.37 - 1.38 - // new Option("-moreinfo", "opt.moreinfo") { 1.39 MOREINFO("-moreinfo", null, HIDDEN, BASIC) { 1.40 @Override 1.41 public boolean process(OptionHelper helper, String option) { 1.42 @@ -317,23 +308,6 @@ 1.43 // treat warnings as errors 1.44 WERROR("-Werror", "opt.Werror", STANDARD, BASIC), 1.45 1.46 -// // use complex inference from context in the position of a method call argument 1.47 -// COMPLEXINFERENCE("-complexinference", null, HIDDEN, BASIC), 1.48 - 1.49 - // generare source stubs 1.50 - // new HiddenOption("-stubs"), 1.51 - 1.52 - // relax some constraints to allow compiling from stubs 1.53 - // new HiddenOption("-relax"), 1.54 - 1.55 - // output source after translating away inner classes 1.56 - // new Option("-printflat", "opt.printflat"), 1.57 - // new HiddenOption("-printflat"), 1.58 - 1.59 - // display scope search details 1.60 - // new Option("-printsearch", "opt.printsearch"), 1.61 - // new HiddenOption("-printsearch"), 1.62 - 1.63 // prompt after each error 1.64 // new Option("-prompt", "opt.prompt"), 1.65 PROMPT("-prompt", null, HIDDEN, BASIC), 1.66 @@ -342,13 +316,8 @@ 1.67 DOE("-doe", null, HIDDEN, BASIC), 1.68 1.69 // output source after type erasure 1.70 - // new Option("-s", "opt.s"), 1.71 PRINTSOURCE("-printsource", null, HIDDEN, BASIC), 1.72 1.73 - // output shrouded class files 1.74 - // new Option("-scramble", "opt.scramble"), 1.75 - // new Option("-scrambleall", "opt.scrambleall"), 1.76 - 1.77 // display warnings for generic unchecked operations 1.78 WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) { 1.79 @Override 1.80 @@ -408,18 +377,16 @@ 1.81 * -XDx sets the option x to the value x. 1.82 */ 1.83 XD("-XD", null, HIDDEN, BASIC) { 1.84 - String s; 1.85 @Override 1.86 public boolean matches(String s) { 1.87 - this.s = s; 1.88 return s.startsWith(text); 1.89 } 1.90 @Override 1.91 public boolean process(OptionHelper helper, String option) { 1.92 - s = s.substring(text.length()); 1.93 - int eq = s.indexOf('='); 1.94 - String key = (eq < 0) ? s : s.substring(0, eq); 1.95 - String value = (eq < 0) ? s : s.substring(eq+1); 1.96 + option = option.substring(text.length()); 1.97 + int eq = option.indexOf('='); 1.98 + String key = (eq < 0) ? option : option.substring(0, eq); 1.99 + String value = (eq < 0) ? option : option.substring(eq+1); 1.100 helper.put(key, value); 1.101 return false; 1.102 } 1.103 @@ -428,8 +395,6 @@ 1.104 // This option exists only for the purpose of documenting itself. 1.105 // It's actually implemented by the CommandLine class. 1.106 AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) { 1.107 - { hasSuffix = true; } 1.108 - 1.109 @Override 1.110 public boolean process(OptionHelper helper, String option) { 1.111 throw new AssertionError("the @ flag should be caught by CommandLine."); 1.112 @@ -445,17 +410,15 @@ 1.113 * name to a separate list. 1.114 */ 1.115 SOURCEFILE("sourcefile", null, HIDDEN, INFO) { 1.116 - String s; 1.117 @Override 1.118 public boolean matches(String s) { 1.119 - this.s = s; 1.120 return s.endsWith(".java") // Java source file 1.121 || SourceVersion.isName(s); // Legal type name 1.122 } 1.123 @Override 1.124 public boolean process(OptionHelper helper, String option) { 1.125 - if (s.endsWith(".java") ) { 1.126 - File f = new File(s); 1.127 + if (option.endsWith(".java") ) { 1.128 + File f = new File(option); 1.129 if (!f.exists()) { 1.130 helper.error("err.file.not.found", f); 1.131 return true; 1.132 @@ -465,9 +428,9 @@ 1.133 return true; 1.134 } 1.135 helper.addFile(f); 1.136 + } else { 1.137 + helper.addClassName(option); 1.138 } 1.139 - else 1.140 - helper.addClassName(s); 1.141 return false; 1.142 } 1.143 }; 1.144 @@ -521,7 +484,7 @@ 1.145 1.146 /** Suffix option (-foo=bar or -foo:bar) 1.147 */ 1.148 - boolean hasSuffix; 1.149 + final boolean hasSuffix; 1.150 1.151 /** The kind of choices for this option, if any. 1.152 */ 1.153 @@ -535,24 +498,30 @@ 1.154 1.155 Option(String text, String descrKey, 1.156 OptionKind kind, OptionGroup group) { 1.157 - this(text, null, descrKey, kind, group, null, null); 1.158 + this(text, null, descrKey, kind, group, null, null, false); 1.159 } 1.160 1.161 Option(String text, String argsNameKey, String descrKey, 1.162 OptionKind kind, OptionGroup group) { 1.163 - this(text, argsNameKey, descrKey, kind, group, null, null); 1.164 + this(text, argsNameKey, descrKey, kind, group, null, null, false); 1.165 + } 1.166 + 1.167 + Option(String text, String argsNameKey, String descrKey, 1.168 + OptionKind kind, OptionGroup group, boolean doHasSuffix) { 1.169 + this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix); 1.170 } 1.171 1.172 Option(String text, String descrKey, 1.173 OptionKind kind, OptionGroup group, 1.174 ChoiceKind choiceKind, Map<String,Boolean> choices) { 1.175 - this(text, null, descrKey, kind, group, choiceKind, choices); 1.176 + this(text, null, descrKey, kind, group, choiceKind, choices, false); 1.177 } 1.178 1.179 Option(String text, String descrKey, 1.180 OptionKind kind, OptionGroup group, 1.181 ChoiceKind choiceKind, String... choices) { 1.182 - this(text, null, descrKey, kind, group, choiceKind, createChoices(choices)); 1.183 + this(text, null, descrKey, kind, group, choiceKind, 1.184 + createChoices(choices), false); 1.185 } 1.186 // where 1.187 private static Map<String,Boolean> createChoices(String... choices) { 1.188 @@ -564,7 +533,8 @@ 1.189 1.190 private Option(String text, String argsNameKey, String descrKey, 1.191 OptionKind kind, OptionGroup group, 1.192 - ChoiceKind choiceKind, Map<String,Boolean> choices) { 1.193 + ChoiceKind choiceKind, Map<String,Boolean> choices, 1.194 + boolean doHasSuffix) { 1.195 this.text = text; 1.196 this.argsNameKey = argsNameKey; 1.197 this.descrKey = descrKey; 1.198 @@ -573,7 +543,7 @@ 1.199 this.choiceKind = choiceKind; 1.200 this.choices = choices; 1.201 char lastChar = text.charAt(text.length()-1); 1.202 - hasSuffix = lastChar == ':' || lastChar == '='; 1.203 + this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '='; 1.204 } 1.205 1.206 public String getText() {