langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java
changeset 40308 274367a99f98
parent 39362 5ac5af2acb57
child 41155 93dad90c22c1
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Wed Aug 10 13:52:02 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Wed Aug 10 15:47:46 2016 -0700
@@ -232,7 +232,7 @@
         OptionHelper helper = new GrumpyHelper(log) {
             @Override
             public String get(Option option) {
-                return options.get(option.getText());
+                return options.get(option);
             }
 
             @Override
@@ -251,23 +251,15 @@
             }
         };
 
-        for (Option o: javacFileManagerOptions) {
-            if (o.matches(current))  {
-                if (o.hasArg()) {
-                    if (remaining.hasNext()) {
-                        if (!o.process(helper, current, remaining.next()))
-                            return true;
-                    }
-                } else {
-                    if (!o.process(helper, current))
-                        return true;
-                }
-                // operand missing, or process returned true
-                throw new IllegalArgumentException(current);
-            }
+        Option o = Option.lookup(current, javacFileManagerOptions);
+        if (o == null) {
+            return false;
         }
 
-        return false;
+        if (!o.handleOption(helper, current, remaining))
+            throw new IllegalArgumentException(current);
+
+        return true;
     }
     // where
         private static final Set<Option> javacFileManagerOptions =
@@ -275,11 +267,8 @@
 
     @Override @DefinedBy(Api.COMPILER)
     public int isSupportedOption(String option) {
-        for (Option o : javacFileManagerOptions) {
-            if (o.matches(option))
-                return o.hasArg() ? 1 : 0;
-        }
-        return -1;
+        Option o = Option.lookup(option, javacFileManagerOptions);
+        return (o == null) ? -1 : o.hasArg() ? 1 : 0;
     }
 
     protected String multiReleaseValue;
@@ -316,7 +305,7 @@
             try {
                 ok = ok & handleOption(e.getKey(), e.getValue());
             } catch (IllegalArgumentException ex) {
-                log.error(Errors.IllegalArgumentForOption(e.getKey().getText(), ex.getMessage()));
+                log.error(Errors.IllegalArgumentForOption(e.getKey().getPrimaryName(), ex.getMessage()));
                 ok = false;
             }
         }