--- a/langtools/src/share/classes/com/sun/tools/javac/main/Option.java Mon Dec 10 12:10:50 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Option.java Mon Dec 10 16:21:26 2012 +0000
@@ -167,7 +167,6 @@
ENCODING("-encoding", "opt.arg.encoding", "opt.encoding", STANDARD, FILEMANAGER) {
@Override
public boolean process(OptionHelper helper, String option, String operand) {
-// System.err.println("process encoding " + operand);
return super.process(helper, option, operand);
}
@@ -246,9 +245,7 @@
}
},
- A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC) {
- { hasSuffix = true; }
-
+ A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
@Override
public boolean matches(String arg) {
return arg.startsWith("-A");
@@ -293,8 +290,6 @@
// This option exists only for the purpose of documenting itself.
// It's actually implemented by the launcher.
J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO) {
- { hasSuffix = true; }
-
@Override
public boolean process(OptionHelper helper, String option) {
throw new AssertionError
@@ -302,10 +297,6 @@
}
},
- // stop after parsing and attributing.
- // new HiddenOption("-attrparseonly"),
-
- // new Option("-moreinfo", "opt.moreinfo") {
MOREINFO("-moreinfo", null, HIDDEN, BASIC) {
@Override
public boolean process(OptionHelper helper, String option) {
@@ -317,23 +308,6 @@
// treat warnings as errors
WERROR("-Werror", "opt.Werror", STANDARD, BASIC),
-// // use complex inference from context in the position of a method call argument
-// COMPLEXINFERENCE("-complexinference", null, HIDDEN, BASIC),
-
- // generare source stubs
- // new HiddenOption("-stubs"),
-
- // relax some constraints to allow compiling from stubs
- // new HiddenOption("-relax"),
-
- // output source after translating away inner classes
- // new Option("-printflat", "opt.printflat"),
- // new HiddenOption("-printflat"),
-
- // display scope search details
- // new Option("-printsearch", "opt.printsearch"),
- // new HiddenOption("-printsearch"),
-
// prompt after each error
// new Option("-prompt", "opt.prompt"),
PROMPT("-prompt", null, HIDDEN, BASIC),
@@ -342,13 +316,8 @@
DOE("-doe", null, HIDDEN, BASIC),
// output source after type erasure
- // new Option("-s", "opt.s"),
PRINTSOURCE("-printsource", null, HIDDEN, BASIC),
- // output shrouded class files
- // new Option("-scramble", "opt.scramble"),
- // new Option("-scrambleall", "opt.scrambleall"),
-
// display warnings for generic unchecked operations
WARNUNCHECKED("-warnunchecked", null, HIDDEN, BASIC) {
@Override
@@ -408,18 +377,16 @@
* -XDx sets the option x to the value x.
*/
XD("-XD", null, HIDDEN, BASIC) {
- String s;
@Override
public boolean matches(String s) {
- this.s = s;
return s.startsWith(text);
}
@Override
public boolean process(OptionHelper helper, String option) {
- s = s.substring(text.length());
- int eq = s.indexOf('=');
- String key = (eq < 0) ? s : s.substring(0, eq);
- String value = (eq < 0) ? s : s.substring(eq+1);
+ option = option.substring(text.length());
+ int eq = option.indexOf('=');
+ String key = (eq < 0) ? option : option.substring(0, eq);
+ String value = (eq < 0) ? option : option.substring(eq+1);
helper.put(key, value);
return false;
}
@@ -428,8 +395,6 @@
// This option exists only for the purpose of documenting itself.
// It's actually implemented by the CommandLine class.
AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO) {
- { hasSuffix = true; }
-
@Override
public boolean process(OptionHelper helper, String option) {
throw new AssertionError("the @ flag should be caught by CommandLine.");
@@ -445,17 +410,15 @@
* name to a separate list.
*/
SOURCEFILE("sourcefile", null, HIDDEN, INFO) {
- String s;
@Override
public boolean matches(String s) {
- this.s = s;
return s.endsWith(".java") // Java source file
|| SourceVersion.isName(s); // Legal type name
}
@Override
public boolean process(OptionHelper helper, String option) {
- if (s.endsWith(".java") ) {
- File f = new File(s);
+ if (option.endsWith(".java") ) {
+ File f = new File(option);
if (!f.exists()) {
helper.error("err.file.not.found", f);
return true;
@@ -465,9 +428,9 @@
return true;
}
helper.addFile(f);
+ } else {
+ helper.addClassName(option);
}
- else
- helper.addClassName(s);
return false;
}
};
@@ -521,7 +484,7 @@
/** Suffix option (-foo=bar or -foo:bar)
*/
- boolean hasSuffix;
+ final boolean hasSuffix;
/** The kind of choices for this option, if any.
*/
@@ -535,24 +498,30 @@
Option(String text, String descrKey,
OptionKind kind, OptionGroup group) {
- this(text, null, descrKey, kind, group, null, null);
+ this(text, null, descrKey, kind, group, null, null, false);
}
Option(String text, String argsNameKey, String descrKey,
OptionKind kind, OptionGroup group) {
- this(text, argsNameKey, descrKey, kind, group, null, null);
+ this(text, argsNameKey, descrKey, kind, group, null, null, false);
+ }
+
+ Option(String text, String argsNameKey, String descrKey,
+ OptionKind kind, OptionGroup group, boolean doHasSuffix) {
+ this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
}
Option(String text, String descrKey,
OptionKind kind, OptionGroup group,
ChoiceKind choiceKind, Map<String,Boolean> choices) {
- this(text, null, descrKey, kind, group, choiceKind, choices);
+ this(text, null, descrKey, kind, group, choiceKind, choices, false);
}
Option(String text, String descrKey,
OptionKind kind, OptionGroup group,
ChoiceKind choiceKind, String... choices) {
- this(text, null, descrKey, kind, group, choiceKind, createChoices(choices));
+ this(text, null, descrKey, kind, group, choiceKind,
+ createChoices(choices), false);
}
// where
private static Map<String,Boolean> createChoices(String... choices) {
@@ -564,7 +533,8 @@
private Option(String text, String argsNameKey, String descrKey,
OptionKind kind, OptionGroup group,
- ChoiceKind choiceKind, Map<String,Boolean> choices) {
+ ChoiceKind choiceKind, Map<String,Boolean> choices,
+ boolean doHasSuffix) {
this.text = text;
this.argsNameKey = argsNameKey;
this.descrKey = descrKey;
@@ -573,7 +543,7 @@
this.choiceKind = choiceKind;
this.choices = choices;
char lastChar = text.charAt(text.length()-1);
- hasSuffix = lastChar == ':' || lastChar == '=';
+ this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
}
public String getText() {