changeset 1315:77b2c066084c jdk8-b19

Merge
author lana
date Fri, 23 Dec 2011 16:39:22 -0800
parents 3c71fcc22b99 1ae5988e201b
children ffd294128a48 67512b631961
files src/share/classes/com/sun/tools/javac/main/JavacOption.java src/share/classes/com/sun/tools/javac/main/OptionName.java src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
diffstat 31 files changed, 1237 insertions(+), 1355 deletions(-) [+]
line wrap: on
line diff
--- a/make/jprt.properties	Thu Dec 22 19:00:58 2011 -0800
+++ b/make/jprt.properties	Fri Dec 23 16:39:22 2011 -0800
@@ -25,23 +25,38 @@
 
 # Properties for jprt
 
-# The release to build
+# Locked down to jdk8
 jprt.tools.default.release=jdk8
 
 # The different build flavors we want, we override here so we just get these 2
 jprt.build.flavors=product,fastdebug
 
 # Standard list of jprt build targets for this source tree
-jprt.build.targets= 						\
-    solaris_sparc_5.10-{product|fastdebug}, 			\
-    solaris_sparcv9_5.10-{product|fastdebug}, 			\
-    solaris_i586_5.10-{product|fastdebug}, 			\
-    solaris_x64_5.10-{product|fastdebug}, 			\
-    linux_i586_2.6-{product|fastdebug}, 			\
-    linux_x64_2.6-{product|fastdebug}, 				\
-    windows_i586_5.1-{product|fastdebug}, 			\
+jprt.build.targets=                                             \
+    solaris_sparc_5.10-{product|fastdebug},                     \
+    solaris_sparcv9_5.10-{product|fastdebug},                   \
+    solaris_i586_5.10-{product|fastdebug},                      \
+    solaris_x64_5.10-{product|fastdebug},                       \
+    linux_i586_2.6-{product|fastdebug},                         \
+    linux_x64_2.6-{product|fastdebug},                          \
+    windows_i586_5.1-{product|fastdebug},                       \
     windows_x64_5.2-{product|fastdebug}
 
+# Test target list (no fastdebug & limited c2 testing)
+jprt.my.test.target.set= 					\
+    solaris_sparc_5.10-product-c1-TESTNAME,                     \
+    solaris_sparcv9_5.10-product-c2-TESTNAME,                   \
+    solaris_i586_5.10-product-c1-TESTNAME,                      \
+    solaris_x64_5.10-product-c2-TESTNAME,                       \
+    linux_i586_2.6-product-{c1|c2}-TESTNAME,                    \
+    linux_x64_2.6-product-c2-TESTNAME,                          \
+    windows_i586_5.1-product-c1-TESTNAME,                       \
+    windows_x64_5.2-product-c2-TESTNAME
+
+# Default test targets
+jprt.make.rule.test.targets=					\
+    ${jprt.my.test.target.set:TESTNAME=jtreg}
+
 # Directories to be excluded from the source bundles
 jprt.bundle.exclude.src.dirs=build dist webrev
 
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Fri Dec 23 16:39:22 2011 -0800
@@ -216,6 +216,7 @@
 doclet.Same_package_name_used=Package name format used twice: {0}
 doclet.Serialization.Excluded_Class=Non-transient field {1} uses excluded class {0}.
 doclet.Serialization.Nonexcluded_Class=Non-transient field {1} uses hidden, non-included class {0}.
+doclet.exception_encountered=Exception encountered while processing {1}\n{0}
 doclet.usage=Provided by Standard doclet:\n\
   -d <directory>                    Destination directory for output files\n\
   -use                              Create class and package usage pages\n\
--- a/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Fri Dec 23 16:39:22 2011 -0800
@@ -25,18 +25,15 @@
 
 package com.sun.tools.javac.api;
 
-import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.nio.charset.Charset;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Locale;
 import java.util.Set;
 import javax.lang.model.SourceVersion;
@@ -44,17 +41,15 @@
 
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.main.JavacOption.OptionKind;
-import com.sun.tools.javac.main.JavacOption;
 import com.sun.tools.javac.main.Main;
-import com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper;
-import com.sun.tools.javac.main.RecognizedOptions;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
 import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Log.PrefixKind;
 import com.sun.tools.javac.util.Options;
-import com.sun.tools.javac.util.Pair;
 
 /**
  * TODO: describe com.sun.tools.javac.api.Tool
@@ -67,23 +62,10 @@
  * @author Peter von der Ah\u00e9
  */
 public final class JavacTool implements JavaCompiler {
-    private final List<Pair<String,String>> options
-        = new ArrayList<Pair<String,String>>();
-    private final Context dummyContext = new Context();
-
-    private final PrintWriter silent = new PrintWriter(new OutputStream(){
-        public void write(int b) {}
-    });
-
-    private final Main sharedCompiler = new Main("javac", silent);
-    {
-        sharedCompiler.setOptions(Options.instance(dummyContext));
-    }
-
     /**
-     * Constructor used by service provider mechanism.  The correct way to
-     * obtain an instance of this class is using create or the service provider
-     * mechanism.
+     * Constructor used by service provider mechanism.  The recommended way to
+     * obtain an instance of this class is by using {@link #create} or the
+     * service provider mechanism.
      * @see javax.tools.JavaCompilerTool
      * @see javax.tools.ToolProvider
      * @see #create
@@ -99,49 +81,6 @@
         return new JavacTool();
     }
 
-    private String argsToString(Object... args) {
-        String newArgs = null;
-        if (args.length > 0) {
-            StringBuilder sb = new StringBuilder();
-            String separator = "";
-            for (Object arg : args) {
-                sb.append(separator).append(arg.toString());
-                separator = File.pathSeparator;
-            }
-            newArgs = sb.toString();
-        }
-        return newArgs;
-    }
-
-    private void setOption1(String name, OptionKind kind, Object... args) {
-        String arg = argsToString(args);
-        JavacOption option = sharedCompiler.getOption(name);
-        if (option == null || !match(kind, option.getKind()))
-            throw new IllegalArgumentException(name);
-        if ((args.length != 0) != option.hasArg())
-            throw new IllegalArgumentException(name);
-        if (option.hasArg()) {
-            if (option.process(null, name, arg)) // FIXME
-                throw new IllegalArgumentException(name);
-        } else {
-            if (option.process(null, name)) // FIXME
-                throw new IllegalArgumentException(name);
-        }
-        options.add(new Pair<String,String>(name,arg));
-    }
-
-    public void setOption(String name, Object... args) {
-        setOption1(name, OptionKind.NORMAL, args);
-    }
-
-    public void setExtendedOption(String name, Object... args)  {
-        setOption1(name, OptionKind.EXTENDED, args);
-    }
-
-    private static boolean match(OptionKind clientKind, OptionKind optionKind) {
-        return (clientKind == (optionKind == OptionKind.HIDDEN ? OptionKind.EXTENDED : optionKind));
-    }
-
     public JavacFileManager getStandardFileManager(
         DiagnosticListener<? super JavaFileObject> diagnosticListener,
         Locale locale,
@@ -209,7 +148,9 @@
             if (fileManager == null)
                 fileManager = getStandardFileManager(diagnosticListener, null, null);
             fileManager = ccw.wrap(fileManager);
+
             context.put(JavaFileManager.class, fileManager);
+
             processOptions(context, fileManager, options);
             Main compiler = new Main("javacTask", context.get(Log.outKey));
             return new JavacTaskImpl(compiler, options, context, classes, compilationUnits);
@@ -225,11 +166,28 @@
         if (options == null)
             return;
 
-        Options optionTable = Options.instance(context);
+        final Options optionTable = Options.instance(context);
         Log log = Log.instance(context);
 
-        JavacOption[] recognizedOptions =
-            RecognizedOptions.getJavacToolOptions(new GrumpyHelper(log));
+        Option[] recognizedOptions =
+                Option.getJavacToolOptions().toArray(new Option[0]);
+        OptionHelper optionHelper = new GrumpyHelper(log) {
+            @Override
+            public String get(Option option) {
+                return optionTable.get(option.getText());
+            }
+
+            @Override
+            public void put(String name, String value) {
+                optionTable.put(name, value);
+            }
+
+            @Override
+            public void remove(String name) {
+                optionTable.remove(name);
+            }
+        };
+
         Iterator<String> flags = options.iterator();
         while (flags.hasNext()) {
             String flag = flags.next();
@@ -247,19 +205,19 @@
                 }
             }
 
-            JavacOption option = recognizedOptions[j];
+            Option option = recognizedOptions[j];
             if (option.hasArg()) {
                 if (!flags.hasNext()) {
                     String msg = log.localize(PrefixKind.JAVAC, "err.req.arg", flag);
                     throw new IllegalArgumentException(msg);
                 }
                 String operand = flags.next();
-                if (option.process(optionTable, flag, operand))
+                if (option.process(optionHelper, flag, operand))
                     // should not happen as the GrumpyHelper will throw exceptions
                     // in case of errors
                     throw new IllegalArgumentException(flag + " " + operand);
             } else {
-                if (option.process(optionTable, flag))
+                if (option.process(optionHelper, flag))
                     // should not happen as the GrumpyHelper will throw exceptions
                     // in case of errors
                     throw new IllegalArgumentException(flag);
@@ -283,9 +241,8 @@
     }
 
     public int isSupportedOption(String option) {
-        JavacOption[] recognizedOptions =
-            RecognizedOptions.getJavacToolOptions(new GrumpyHelper(null));
-        for (JavacOption o : recognizedOptions) {
+        Set<Option> recognizedOptions = Option.getJavacToolOptions();
+        for (Option o : recognizedOptions) {
             if (o.matches(option))
                 return o.hasArg() ? 1 : 0;
         }
--- a/src/share/classes/com/sun/tools/javac/code/Source.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Fri Dec 23 16:39:22 2011 -0800
@@ -32,7 +32,7 @@
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.jvm.Target;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** The source language version accepted.
  *
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Dec 23 16:39:22 2011 -0800
@@ -48,7 +48,6 @@
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.code.TypeTags.WILDCARD;
 
-import static com.sun.tools.javac.main.OptionName.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** Type checking helper class for the attribution phase.
@@ -110,7 +109,7 @@
         allowAnnotations = source.allowAnnotations();
         allowCovariantReturns = source.allowCovariantReturns();
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
-        complexInference = options.isSet(COMPLEXINFERENCE);
+        complexInference = options.isSet("complexinference");
         skipAnnotations = options.isSet("skipAnnotations");
         warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
         suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
@@ -2482,7 +2481,7 @@
                     warnDeprecated(pos, s);
                 }
             });
-        };
+        }
     }
 
     void checkSunAPI(final DiagnosticPosition pos, final Symbol s) {
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java	Fri Dec 23 16:39:22 2011 -0800
@@ -34,7 +34,7 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.jvm.*;
-import com.sun.tools.javac.main.RecognizedOptions.PkgInfo;
+import com.sun.tools.javac.main.Option.PkgInfo;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Dec 23 16:39:22 2011 -0800
@@ -29,7 +29,7 @@
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.jvm.*;
-import com.sun.tools.javac.main.RecognizedOptions.PkgInfo;
+import com.sun.tools.javac.main.Option.PkgInfo;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
--- a/src/share/classes/com/sun/tools/javac/file/Locations.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/file/Locations.java	Fri Dec 23 16:39:22 2011 -0800
@@ -47,14 +47,14 @@
 import javax.tools.StandardLocation;
 
 import com.sun.tools.javac.code.Lint;
-import com.sun.tools.javac.main.OptionName;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Options;
 
 import javax.tools.JavaFileManager;
 import static javax.tools.StandardLocation.*;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** This class converts command line arguments, environment variables
  *  and system properties (in File.pathSeparator-separated String form)
@@ -318,23 +318,23 @@
      */
     protected abstract class LocationHandler {
         final Location location;
-        final Set<OptionName> options;
+        final Set<Option> options;
 
         /**
          * Create a handler. The location and options provide a way to map
          * from a location or an option to the corresponding handler.
          * @see #initHandlers
          */
-        protected LocationHandler(Location location, OptionName... options) {
+        protected LocationHandler(Location location, Option... options) {
             this.location = location;
             this.options = options.length == 0 ?
-                EnumSet.noneOf(OptionName.class):
+                EnumSet.noneOf(Option.class):
                 EnumSet.copyOf(Arrays.asList(options));
         }
 
         // TODO: TEMPORARY, while Options still used for command line options
         void update(Options optionTable) {
-            for (OptionName o: options) {
+            for (Option o: options) {
                 String v = optionTable.get(o);
                 if (v != null) {
                     handleOption(o, v);
@@ -343,7 +343,7 @@
         }
 
         /** @see JavaFileManager#handleOption. */
-        abstract boolean handleOption(OptionName option, String value);
+        abstract boolean handleOption(Option option, String value);
         /** @see JavaFileManager#getLocation. */
         abstract Collection<File> getLocation();
         /** @see JavaFileManager#setLocation. */
@@ -359,12 +359,12 @@
     private class OutputLocationHandler extends LocationHandler {
         private File outputDir;
 
-        OutputLocationHandler(Location location, OptionName... options) {
+        OutputLocationHandler(Location location, Option... options) {
             super(location, options);
         }
 
         @Override
-        boolean handleOption(OptionName option, String value) {
+        boolean handleOption(Option option, String value) {
             if (!options.contains(option))
                 return false;
 
@@ -410,12 +410,12 @@
     private class SimpleLocationHandler extends LocationHandler {
         protected Collection<File> searchPath;
 
-        SimpleLocationHandler(Location location, OptionName... options) {
+        SimpleLocationHandler(Location location, Option... options) {
             super(location, options);
         }
 
         @Override
-        boolean handleOption(OptionName option, String value) {
+        boolean handleOption(Option option, String value) {
             if (!options.contains(option))
                 return false;
             searchPath = value == null ? null :
@@ -452,7 +452,7 @@
     private class ClassPathLocationHandler extends SimpleLocationHandler {
         ClassPathLocationHandler() {
             super(StandardLocation.CLASS_PATH,
-                    OptionName.CLASSPATH, OptionName.CP);
+                    Option.CLASSPATH, Option.CP);
         }
 
         @Override
@@ -500,7 +500,7 @@
      */
     private class BootClassPathLocationHandler extends LocationHandler {
         private Collection<File> searchPath;
-        final Map<OptionName, String> optionValues = new EnumMap<OptionName,String>(OptionName.class);
+        final Map<Option, String> optionValues = new EnumMap<Option,String>(Option.class);
 
         /**
          * rt.jar as found on the default bootclasspath.
@@ -515,11 +515,11 @@
 
         BootClassPathLocationHandler() {
             super(StandardLocation.PLATFORM_CLASS_PATH,
-                    OptionName.BOOTCLASSPATH, OptionName.XBOOTCLASSPATH,
-                    OptionName.XBOOTCLASSPATH_PREPEND,
-                    OptionName.XBOOTCLASSPATH_APPEND,
-                    OptionName.ENDORSEDDIRS, OptionName.DJAVA_ENDORSED_DIRS,
-                    OptionName.EXTDIRS, OptionName.DJAVA_EXT_DIRS);
+                    Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
+                    Option.XBOOTCLASSPATH_PREPEND,
+                    Option.XBOOTCLASSPATH_APPEND,
+                    Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
+                    Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
         }
 
         boolean isDefault() {
@@ -533,7 +533,7 @@
         }
 
         @Override
-        boolean handleOption(OptionName option, String value) {
+        boolean handleOption(Option option, String value) {
             if (!options.contains(option))
                 return false;
 
@@ -549,14 +549,14 @@
         // where
             // TODO: would be better if option aliasing was handled at a higher
             // level
-            private OptionName canonicalize(OptionName option) {
+            private Option canonicalize(Option option) {
                 switch (option) {
                     case XBOOTCLASSPATH:
-                        return OptionName.BOOTCLASSPATH;
+                        return Option.BOOTCLASSPATH;
                     case DJAVA_ENDORSED_DIRS:
-                        return OptionName.ENDORSEDDIRS;
+                        return Option.ENDORSEDDIRS;
                     case DJAVA_EXT_DIRS:
-                        return OptionName.EXTDIRS;
+                        return Option.EXTDIRS;
                     default:
                         return option;
                 }
@@ -636,29 +636,29 @@
     }
 
     Map<Location, LocationHandler> handlersForLocation;
-    Map<OptionName, LocationHandler> handlersForOption;
+    Map<Option, LocationHandler> handlersForOption;
 
     void initHandlers() {
         handlersForLocation = new HashMap<Location, LocationHandler>();
-        handlersForOption = new EnumMap<OptionName, LocationHandler>(OptionName.class);
+        handlersForOption = new EnumMap<Option, LocationHandler>(Option.class);
 
         LocationHandler[] handlers = {
             new BootClassPathLocationHandler(),
             new ClassPathLocationHandler(),
-            new SimpleLocationHandler(StandardLocation.SOURCE_PATH, OptionName.SOURCEPATH),
-            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, OptionName.PROCESSORPATH),
-            new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), OptionName.D),
-            new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), OptionName.S)
+            new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
+            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
+            new OutputLocationHandler((StandardLocation.CLASS_OUTPUT), Option.D),
+            new OutputLocationHandler((StandardLocation.SOURCE_OUTPUT), Option.S)
         };
 
         for (LocationHandler h: handlers) {
             handlersForLocation.put(h.location, h);
-            for (OptionName o: h.options)
+            for (Option o: h.options)
                 handlersForOption.put(o, h);
         }
     }
 
-    boolean handleOption(OptionName option, String value) {
+    boolean handleOption(Option option, String value) {
         LocationHandler h = handlersForOption.get(option);
         return (h == null ? false : h.handleOption(option, value));
     }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Dec 23 16:39:22 2011 -0800
@@ -59,7 +59,7 @@
 import static com.sun.tools.javac.jvm.ClassFile.*;
 import static com.sun.tools.javac.jvm.ClassFile.Version.*;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** This class provides operations to read a classfile into an internal
  *  representation. The internal representation is anchored in a
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Dec 23 16:39:22 2011 -0800
@@ -45,7 +45,7 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.jvm.UninitializedType.*;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
 
 
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Dec 23 16:39:22 2011 -0800
@@ -45,7 +45,7 @@
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
 import static com.sun.tools.javac.jvm.CRTFlags.*;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK;
 
--- a/src/share/classes/com/sun/tools/javac/jvm/Target.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java	Fri Dec 23 16:39:22 2011 -0800
@@ -31,7 +31,7 @@
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.util.*;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** The classfile version target.
  *
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Dec 23 16:39:22 2011 -0800
@@ -62,7 +62,7 @@
 import com.sun.tools.javac.util.Log.WriterKind;
 
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
 import static com.sun.tools.javac.util.ListBuffer.lb;
 
@@ -817,8 +817,8 @@
 
         // forcibly set the equivalent of -Xlint:-options, so that no further
         // warnings about command line options are generated from this point on
-        options.put(XLINT_CUSTOM + "-" + LintCategory.OPTIONS.option, "true");
-        options.remove(XLINT_CUSTOM + LintCategory.OPTIONS.option);
+        options.put(XLINT_CUSTOM.text + "-" + LintCategory.OPTIONS.option, "true");
+        options.remove(XLINT_CUSTOM.text + LintCategory.OPTIONS.option);
 
         start_msec = now();
 
--- a/src/share/classes/com/sun/tools/javac/main/JavacOption.java	Thu Dec 22 19:00:58 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,299 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.main;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Log.PrefixKind;
-import com.sun.tools.javac.util.Log.WriterKind;
-import com.sun.tools.javac.util.Options;
-
-/**
- * TODO: describe com.sun.tools.javac.main.JavacOption
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own
- * risk.  This code and its internal interfaces are subject to change
- * or deletion without notice.</b></p>
- */
-public interface JavacOption {
-
-    OptionKind getKind();
-
-    /** Does this option take a (separate) operand?
-     *  @return true if this option takes a separate operand
-     */
-    boolean hasArg();
-
-    /** Does argument string match option pattern?
-     *  @param arg   the command line argument string
-     *  @return true if {@code arg} matches this option
-     */
-    boolean matches(String arg);
-
-    /** Process an option with an argument.
-     *  @param options the accumulated set of analyzed options
-     *  @param option  the option to be processed
-     *  @param arg     the arg for the option to be processed
-     *  @return true if an error was detected
-     */
-    boolean process(Options options, String option, String arg);
-
-    /** Process the option with no argument.
-     *  @param options the accumulated set of analyzed options
-     *  @param option  the option to be processed
-     *  @return true if an error was detected
-     */
-    boolean process(Options options, String option);
-
-    OptionName getName();
-
-    enum OptionKind {
-        NORMAL,
-        EXTENDED,
-        HIDDEN,
-    }
-
-    enum ChoiceKind {
-        ONEOF,
-        ANYOF
-    }
-
-    /** This class represents an option recognized by the main program
-     */
-    static class Option implements JavacOption {
-
-        /** Option string.
-         */
-        OptionName name;
-
-        /** Documentation key for arguments.
-         */
-        String argsNameKey;
-
-        /** Documentation key for description.
-         */
-        String descrKey;
-
-        /** Suffix option (-foo=bar or -foo:bar)
-         */
-        boolean hasSuffix;
-
-        /** The kind of choices for this option, if any.
-         */
-        ChoiceKind choiceKind;
-
-        /** The choices for this option, if any, and whether or not the choices
-         *  are hidden
-         */
-        Map<String,Boolean> choices;
-
-        Option(OptionName name, String argsNameKey, String descrKey) {
-            this.name = name;
-            this.argsNameKey = argsNameKey;
-            this.descrKey = descrKey;
-            char lastChar = name.optionName.charAt(name.optionName.length()-1);
-            hasSuffix = lastChar == ':' || lastChar == '=';
-        }
-
-        Option(OptionName name, String descrKey) {
-            this(name, null, descrKey);
-        }
-
-        Option(OptionName name, String descrKey, ChoiceKind choiceKind, String... choices) {
-            this(name, descrKey, choiceKind, createChoices(choices));
-        }
-
-        private static Map<String,Boolean> createChoices(String... choices) {
-            Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
-            for (String c: choices)
-                map.put(c, false);
-            return map;
-        }
-
-        Option(OptionName name, String descrKey, ChoiceKind choiceKind,
-                Map<String,Boolean> choices) {
-            this(name, null, descrKey);
-            if (choiceKind == null || choices == null)
-                throw new NullPointerException();
-            this.choiceKind = choiceKind;
-            this.choices = choices;
-        }
-
-        @Override
-        public String toString() {
-            return name.optionName;
-        }
-
-        public boolean hasArg() {
-            return argsNameKey != null && !hasSuffix;
-        }
-
-        public boolean matches(String option) {
-            if (!hasSuffix)
-                return option.equals(name.optionName);
-
-            if (!option.startsWith(name.optionName))
-                return false;
-
-            if (choices != null) {
-                String arg = option.substring(name.optionName.length());
-                if (choiceKind == ChoiceKind.ONEOF)
-                    return choices.keySet().contains(arg);
-                else {
-                    for (String a: arg.split(",+")) {
-                        if (!choices.keySet().contains(a))
-                            return false;
-                    }
-                }
-            }
-
-            return true;
-        }
-
-        /** Print a line of documentation describing this option, if standard.
-         * @param out the stream to which to write the documentation
-         */
-        void help(Log log) {
-            log.printRawLines(WriterKind.NOTICE,
-                    String.format("  %-26s %s",
-                        helpSynopsis(log),
-                        log.localize(PrefixKind.JAVAC, descrKey)));
-        }
-
-        String helpSynopsis(Log log) {
-            StringBuilder sb = new StringBuilder();
-            sb.append(name);
-            if (argsNameKey == null) {
-                if (choices != null) {
-                    String sep = "{";
-                    for (Map.Entry<String,Boolean> e: choices.entrySet()) {
-                        if (!e.getValue()) {
-                            sb.append(sep);
-                            sb.append(e.getKey());
-                            sep = ",";
-                        }
-                    }
-                    sb.append("}");
-                }
-            } else {
-                if (!hasSuffix)
-                    sb.append(" ");
-                sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
-            }
-
-            return sb.toString();
-        }
-
-        /** Print a line of documentation describing this option, if non-standard.
-         *  @param out the stream to which to write the documentation
-         */
-        void xhelp(Log log) {}
-
-        /** Process the option (with arg). Return true if error detected.
-         */
-        public boolean process(Options options, String option, String arg) {
-            if (options != null) {
-                if (choices != null) {
-                    if (choiceKind == ChoiceKind.ONEOF) {
-                        // some clients like to see just one of option+choice set
-                        for (String s: choices.keySet())
-                            options.remove(option + s);
-                        String opt = option + arg;
-                        options.put(opt, opt);
-                        // some clients like to see option (without trailing ":")
-                        // set to arg
-                        String nm = option.substring(0, option.length() - 1);
-                        options.put(nm, arg);
-                    } else {
-                        // set option+word for each word in arg
-                        for (String a: arg.split(",+")) {
-                            String opt = option + a;
-                            options.put(opt, opt);
-                        }
-                    }
-                }
-                options.put(option, arg);
-            }
-            return false;
-        }
-
-        /** Process the option (without arg). Return true if error detected.
-         */
-        public boolean process(Options options, String option) {
-            if (hasSuffix)
-                return process(options, name.optionName, option.substring(name.optionName.length()));
-            else
-                return process(options, option, option);
-        }
-
-        public OptionKind getKind() { return OptionKind.NORMAL; }
-
-        public OptionName getName() { return name; }
-    };
-
-    /** A nonstandard or extended (-X) option
-     */
-    static class XOption extends Option {
-        XOption(OptionName name, String argsNameKey, String descrKey) {
-            super(name, argsNameKey, descrKey);
-        }
-        XOption(OptionName name, String descrKey) {
-            this(name, null, descrKey);
-        }
-        XOption(OptionName name, String descrKey, ChoiceKind kind, String... choices) {
-            super(name, descrKey, kind, choices);
-        }
-        XOption(OptionName name, String descrKey, ChoiceKind kind, Map<String,Boolean> choices) {
-            super(name, descrKey, kind, choices);
-        }
-        @Override
-        void help(Log log) {}
-        @Override
-        void xhelp(Log log) { super.help(log); }
-        @Override
-        public OptionKind getKind() { return OptionKind.EXTENDED; }
-    };
-
-    /** A hidden (implementor) option
-     */
-    static class HiddenOption extends Option {
-        HiddenOption(OptionName name) {
-            super(name, null, null);
-        }
-        HiddenOption(OptionName name, String argsNameKey) {
-            super(name, argsNameKey, null);
-        }
-        @Override
-        void help(Log log) {}
-        @Override
-        void xhelp(Log log) {}
-        @Override
-        public OptionKind getKind() { return OptionKind.HIDDEN; }
-    };
-
-}
--- a/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Fri Dec 23 16:39:22 2011 -0800
@@ -42,14 +42,12 @@
 import com.sun.tools.javac.file.CacheFSInfo;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.main.JavacOption.Option;
-import com.sun.tools.javac.main.RecognizedOptions.OptionHelper;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.Log.WriterKind;
 import com.sun.tools.javac.util.Log.PrefixKind;
 import com.sun.tools.javac.processing.AnnotationProcessingError;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** This class provides a commandline interface to the GJC compiler.
  *
@@ -99,42 +97,51 @@
         public final int exitCode;
     }
 
-    private Option[] recognizedOptions = RecognizedOptions.getJavaCompilerOptions(new OptionHelper() {
+    private Option[] recognizedOptions =
+            Option.getJavaCompilerOptions().toArray(new Option[0]);
 
-        public void setOut(PrintWriter out) {
-            Main.this.out = out;
-            Main.this.log.setWriters(out);
+    private OptionHelper optionHelper = new OptionHelper() {
+        @Override
+        public String get(Option option) {
+            return options.get(option);
         }
 
+        @Override
+        public void put(String name, String value) {
+            options.put(name, value);
+        }
+
+        @Override
+        public void remove(String name) {
+            options.remove(name);
+        }
+
+        @Override
+        public Log getLog() {
+            return log;
+        }
+
+        @Override
+        public String getOwnName() {
+            return ownName;
+        }
+
+        @Override
         public void error(String key, Object... args) {
             Main.this.error(key, args);
         }
 
-        public void printVersion() {
-            log.printLines(PrefixKind.JAVAC, "version", ownName,  JavaCompiler.version());
-        }
-
-        public void printFullVersion() {
-            log.printLines(PrefixKind.JAVAC, "fullVersion", ownName,  JavaCompiler.fullVersion());
-        }
-
-        public void printHelp() {
-            help();
-        }
-
-        public void printXhelp() {
-            xhelp();
-        }
-
+        @Override
         public void addFile(File f) {
             filenames.add(f);
         }
 
+        @Override
         public void addClassName(String s) {
             classnames.append(s);
         }
 
-    });
+    };
 
     /**
      * Construct a compiler instance.
@@ -161,26 +168,6 @@
      */
     public ListBuffer<String> classnames = null; // XXX sb protected
 
-    /** Print a string that explains usage.
-     */
-    void help() {
-        log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName);
-        for (int i=0; i<recognizedOptions.length; i++) {
-            recognizedOptions[i].help(log);
-        }
-        log.printNewline();
-    }
-
-    /** Print a string that explains usage for X options.
-     */
-    void xhelp() {
-        for (int i=0; i<recognizedOptions.length; i++) {
-            recognizedOptions[i].xhelp(log);
-        }
-        log.printNewline();
-        log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
-    }
-
     /** Report a usage error.
      */
     void error(String key, Object... args) {
@@ -253,10 +240,10 @@
                 }
                 String operand = flags[ac];
                 ac++;
-                if (option.process(options, flag, operand))
+                if (option.process(optionHelper, flag, operand))
                     return null;
             } else {
-                if (option.process(options, flag))
+                if (option.process(optionHelper, flag))
                     return null;
             }
         }
@@ -317,8 +304,8 @@
         return filenames;
     }
     // where
-        private boolean checkDirectory(OptionName optName) {
-            String value = options.get(optName);
+        private boolean checkDirectory(Option option) {
+            String value = options.get(option);
             if (value == null)
                 return true;
             File file = new File(value);
@@ -375,7 +362,7 @@
          */
         try {
             if (args.length == 0 && fileObjects.isEmpty()) {
-                help();
+                Option.HELP.process(optionHelper, "-help");
                 return Result.CMDERR;
             }
 
@@ -407,8 +394,7 @@
             boolean forceStdOut = options.isSet("stdout");
             if (forceStdOut) {
                 log.flush();
-                out = new PrintWriter(System.out, true);
-                log.setWriters(out);
+                log.setWriters(new PrintWriter(System.out, true));
             }
 
             // allow System property in following line as a Mustang legacy
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/main/Option.java	Fri Dec 23 16:39:22 2011 -0800
@@ -0,0 +1,710 @@
+/*
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.main;
+
+import java.util.Collections;
+import com.sun.tools.javac.util.Log.PrefixKind;
+import com.sun.tools.javac.util.Log.WriterKind;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.jvm.Target;
+import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.EnumSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.lang.model.SourceVersion;
+
+import static com.sun.tools.javac.main.Option.ChoiceKind.*;
+import static com.sun.tools.javac.main.Option.OptionKind.*;
+import static com.sun.tools.javac.main.Option.OptionGroup.*;
+
+/**
+ * Options for javac. The specific Option to handle a command-line option
+ * is identified by searching the members of this enum in order, looking
+ * the first {@link #matches match}. The action for an Option is performed
+ * by calling {@link #process process}, and by providing a suitable
+ * {@link OptionHelper} to provide access the compiler state.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own
+ * risk.  This code and its internal interfaces are subject to change
+ * or deletion without notice.</b></p>
+ */
+public enum Option {
+    G("-g", "opt.g", STANDARD, BASIC),
+
+    G_NONE("-g:none", "opt.g.none", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-g:", "none");
+            return false;
+        }
+    },
+
+    G_CUSTOM("-g:",  "opt.g.lines.vars.source",
+            STANDARD, BASIC, ANYOF, "lines", "vars", "source"),
+
+    XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
+
+    XLINT_CUSTOM("-Xlint:", "opt.Xlint.suboptlist",
+            EXTENDED,   BASIC, ANYOF, getXLintChoices()),
+
+    // -nowarn is retained for command-line backward compatibility
+    NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-Xlint:none", option);
+            return false;
+        }
+    },
+
+    VERBOSE("-verbose", "opt.verbose", STANDARD, BASIC),
+
+    // -deprecation is retained for command-line backward compatibility
+    DEPRECATION("-deprecation", "opt.deprecation", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-Xlint:deprecation", option);
+            return false;
+        }
+    },
+
+    CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
+
+    CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            return super.process(helper, "-classpath", arg);
+        }
+    },
+
+    SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
+
+    BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            helper.remove("-Xbootclasspath/p:");
+            helper.remove("-Xbootclasspath/a:");
+            return super.process(helper, option, arg);
+        }
+    },
+
+    XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:", "opt.arg.path", "opt.Xbootclasspath.p", EXTENDED, FILEMANAGER),
+
+    XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:", "opt.arg.path", "opt.Xbootclasspath.a", EXTENDED, FILEMANAGER),
+
+    XBOOTCLASSPATH("-Xbootclasspath:", "opt.arg.path", "opt.bootclasspath", EXTENDED, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            helper.remove("-Xbootclasspath/p:");
+            helper.remove("-Xbootclasspath/a:");
+            return super.process(helper, "-bootclasspath", arg);
+        }
+    },
+
+    EXTDIRS("-extdirs", "opt.arg.dirs", "opt.extdirs", STANDARD, FILEMANAGER),
+
+    DJAVA_EXT_DIRS("-Djava.ext.dirs=", "opt.arg.dirs", "opt.extdirs", EXTENDED, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            return super.process(helper, "-extdirs", arg);
+        }
+    },
+
+    ENDORSEDDIRS("-endorseddirs", "opt.arg.dirs", "opt.endorseddirs", STANDARD, FILEMANAGER),
+
+    DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs=", "opt.arg.dirs", "opt.endorseddirs", EXTENDED, FILEMANAGER) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            return super.process(helper, "-endorseddirs", arg);
+        }
+    },
+
+    PROC("-proc:", "opt.proc.none.only", STANDARD, BASIC,  ONEOF, "none", "only"),
+
+    PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
+
+    PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
+
+    D("-d", "opt.arg.directory", "opt.d", STANDARD, FILEMANAGER),
+
+    S("-s", "opt.arg.directory", "opt.sourceDest", STANDARD, FILEMANAGER),
+
+    IMPLICIT("-implicit:", "opt.implicit", STANDARD, BASIC, ONEOF, "none", "class"),
+
+    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);
+        }
+
+    },
+
+    SOURCE("-source", "opt.arg.release", "opt.source", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String operand) {
+            Source source = Source.lookup(operand);
+            if (source == null) {
+                helper.error("err.invalid.source", operand);
+                return true;
+            }
+            return super.process(helper, option, operand);
+        }
+    },
+
+    TARGET("-target", "opt.arg.release", "opt.target", STANDARD, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String operand) {
+            Target target = Target.lookup(operand);
+            if (target == null) {
+                helper.error("err.invalid.target", operand);
+                return true;
+            }
+            return super.process(helper, option, operand);
+        }
+    },
+
+    VERSION("-version", "opt.version", STANDARD, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            String ownName = helper.getOwnName();
+            log.printLines(PrefixKind.JAVAC, "version", ownName,  JavaCompiler.version());
+            return super.process(helper, option);
+        }
+    },
+
+    FULLVERSION("-fullversion", null, HIDDEN, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            String ownName = helper.getOwnName();
+            log.printLines(PrefixKind.JAVAC, "fullVersion", ownName,  JavaCompiler.fullVersion());
+            return super.process(helper, option);
+        }
+    },
+
+    DIAGS("-XDdiags=", null, HIDDEN, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            option = option.substring(option.indexOf('=') + 1);
+            String diagsOption = option.contains("%") ?
+                "-XDdiagsFormat=" :
+                "-XDdiags=";
+            diagsOption += option;
+            if (XD.matches(diagsOption))
+                return XD.process(helper, diagsOption);
+            else
+                return false;
+        }
+    },
+
+    HELP("-help", "opt.help", STANDARD, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            String ownName = helper.getOwnName();
+            log.printLines(PrefixKind.JAVAC, "msg.usage.header", ownName);
+            for (Option o: getJavaCompilerOptions()) {
+                o.help(log, OptionKind.STANDARD);
+            }
+            log.printNewline();
+            return super.process(helper, option);
+        }
+    },
+
+    A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC) {
+        { hasSuffix = true; }
+
+        @Override
+        public boolean matches(String arg) {
+            return arg.startsWith("-A");
+        }
+
+        @Override
+        public boolean hasArg() {
+            return false;
+        }
+        // Mapping for processor options created in
+        // JavacProcessingEnvironment
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            int argLength = option.length();
+            if (argLength == 2) {
+                helper.error("err.empty.A.argument");
+                return true;
+            }
+            int sepIndex = option.indexOf('=');
+            String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
+            if (!JavacProcessingEnvironment.isValidOptionName(key)) {
+                helper.error("err.invalid.A.key", option);
+                return true;
+            }
+            return process(helper, option, option);
+        }
+    },
+
+    X("-X", "opt.X", STANDARD, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            Log log = helper.getLog();
+            for (Option o: getJavaCompilerOptions()) {
+                o.help(log, OptionKind.EXTENDED);
+            }
+            log.printNewline();
+            log.printLines(PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
+            return super.process(helper, option);
+        }
+    },
+
+    // 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
+                ("the -J flag should be caught by the launcher.");
+        }
+    },
+
+    // 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) {
+            Type.moreInfo = true;
+            return super.process(helper, option);
+        }
+    },
+
+    // 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),
+
+    // dump stack on error
+    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
+        public boolean process(OptionHelper helper, String option) {
+            helper.put("-Xlint:unchecked", option);
+            return false;
+        }
+    },
+
+    XMAXERRS("-Xmaxerrs", "opt.arg.number", "opt.maxerrs", EXTENDED, BASIC),
+
+    XMAXWARNS("-Xmaxwarns", "opt.arg.number", "opt.maxwarns", EXTENDED, BASIC),
+
+    XSTDOUT("-Xstdout", "opt.arg.file", "opt.Xstdout", EXTENDED, INFO) {
+        @Override
+        public boolean process(OptionHelper helper, String option, String arg) {
+            try {
+                Log log = helper.getLog();
+                // TODO: this file should be closed at the end of compilation
+                log.setWriters(new PrintWriter(new FileWriter(arg), true));
+            } catch (java.io.IOException e) {
+                helper.error("err.error.writing.file", arg, e);
+                return true;
+            }
+            return super.process(helper, option, arg);
+        }
+    },
+
+    XPRINT("-Xprint", "opt.print", EXTENDED, BASIC),
+
+    XPRINTROUNDS("-XprintRounds", "opt.printRounds", EXTENDED, BASIC),
+
+    XPRINTPROCESSORINFO("-XprintProcessorInfo", "opt.printProcessorInfo", EXTENDED, BASIC),
+
+    XPREFER("-Xprefer:", "opt.prefer", EXTENDED, BASIC, ONEOF, "source", "newer"),
+
+    XPKGINFO("-Xpkginfo:", "opt.pkginfo", EXTENDED, BASIC, ONEOF, "always", "legacy", "nonempty"),
+
+    /* -O is a no-op, accepted for backward compatibility. */
+    O("-O", null, HIDDEN, BASIC),
+
+    /* -Xjcov produces tables to support the code coverage tool jcov. */
+    XJCOV("-Xjcov", null, HIDDEN, BASIC),
+
+    /* This is a back door to the compiler's option table.
+     * -XDx=y sets the option x to the value y.
+     * -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);
+            helper.put(key, value);
+            return false;
+        }
+    },
+
+    // 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.");
+        }
+    },
+
+    /*
+     * TODO: With apt, the matches method accepts anything if
+     * -XclassAsDecls is used; code elsewhere does the lookup to
+     * see if the class name is both legal and found.
+     *
+     * In apt, the process method adds the candidate class file
+     * 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 (!f.exists()) {
+                    helper.error("err.file.not.found", f);
+                    return true;
+                }
+                if (!f.isFile()) {
+                    helper.error("err.file.not.file", f);
+                    return true;
+                }
+                helper.addFile(f);
+            }
+            else
+                helper.addClassName(s);
+            return false;
+        }
+    };
+
+    /** The kind of an Option. This is used by the -help and -X options. */
+    public enum OptionKind {
+        /** A standard option, documented by -help. */
+        STANDARD,
+        /** An extended option, documented by -X. */
+        EXTENDED,
+        /** A hidden option, not documented. */
+        HIDDEN,
+    }
+
+    /** The group for an Option. This determines the situations in which the
+     *  option is applicable. */
+    enum OptionGroup {
+        /** A basic option, available for use on the command line or via the
+         *  Compiler API. */
+        BASIC,
+        /** An option for javac's standard JavaFileManager. Other file managers
+         *  may or may not support these options. */
+        FILEMANAGER,
+        /** A command-line option that requests information, such as -help. */
+        INFO,
+        /** A command-line "option" representing a file or class name. */
+        OPERAND
+    }
+
+    /** The kind of choice for "choice" options. */
+    enum ChoiceKind {
+        /** The expected value is exactly one of the set of choices. */
+        ONEOF,
+        /** The expected value is one of more of the set of choices. */
+        ANYOF
+    }
+
+    public final String text;
+
+    final OptionKind kind;
+
+    final OptionGroup group;
+
+    /** Documentation key for arguments.
+     */
+    final String argsNameKey;
+
+    /** Documentation key for description.
+     */
+    final String descrKey;
+
+    /** Suffix option (-foo=bar or -foo:bar)
+     */
+    boolean hasSuffix;
+
+    /** The kind of choices for this option, if any.
+     */
+    final ChoiceKind choiceKind;
+
+    /** The choices for this option, if any, and whether or not the choices
+     *  are hidden
+     */
+    final Map<String,Boolean> choices;
+
+
+    Option(String text, String descrKey,
+            OptionKind kind, OptionGroup group) {
+        this(text, null, descrKey, kind, group, null, null);
+    }
+
+    Option(String text, String argsNameKey, String descrKey,
+            OptionKind kind, OptionGroup group) {
+        this(text, argsNameKey, descrKey, kind, group, null, null);
+    }
+
+    Option(String text, String descrKey,
+            OptionKind kind, OptionGroup group,
+            ChoiceKind choiceKind, Map<String,Boolean> choices) {
+        this(text, null, descrKey, kind, group, choiceKind, choices);
+    }
+
+    Option(String text, String descrKey,
+            OptionKind kind, OptionGroup group,
+            ChoiceKind choiceKind, String... choices) {
+        this(text, null, descrKey, kind, group, choiceKind, createChoices(choices));
+    }
+    // where
+        private static Map<String,Boolean> createChoices(String... choices) {
+            Map<String,Boolean> map = new LinkedHashMap<String,Boolean>();
+            for (String c: choices)
+                map.put(c, false);
+            return map;
+        }
+
+    private Option(String text, String argsNameKey, String descrKey,
+            OptionKind kind, OptionGroup group,
+            ChoiceKind choiceKind, Map<String,Boolean> choices) {
+        this.text = text;
+        this.argsNameKey = argsNameKey;
+        this.descrKey = descrKey;
+        this.kind = kind;
+        this.group = group;
+        this.choiceKind = choiceKind;
+        this.choices = choices;
+        char lastChar = text.charAt(text.length()-1);
+        hasSuffix = lastChar == ':' || lastChar == '=';
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public OptionKind getKind() {
+        return kind;
+    }
+
+    public boolean hasArg() {
+        return argsNameKey != null && !hasSuffix;
+    }
+
+    public boolean matches(String option) {
+        if (!hasSuffix)
+            return option.equals(text);
+
+        if (!option.startsWith(text))
+            return false;
+
+        if (choices != null) {
+            String arg = option.substring(text.length());
+            if (choiceKind == ChoiceKind.ONEOF)
+                return choices.keySet().contains(arg);
+            else {
+                for (String a: arg.split(",+")) {
+                    if (!choices.keySet().contains(a))
+                        return false;
+                }
+            }
+        }
+
+        return true;
+    }
+
+    public boolean process(OptionHelper helper, String option, String arg) {
+        if (choices != null) {
+            if (choiceKind == ChoiceKind.ONEOF) {
+                // some clients like to see just one of option+choice set
+                for (String s: choices.keySet())
+                    helper.remove(option + s);
+                String opt = option + arg;
+                helper.put(opt, opt);
+                // some clients like to see option (without trailing ":")
+                // set to arg
+                String nm = option.substring(0, option.length() - 1);
+                helper.put(nm, arg);
+            } else {
+                // set option+word for each word in arg
+                for (String a: arg.split(",+")) {
+                    String opt = option + a;
+                    helper.put(opt, opt);
+                }
+            }
+        }
+        helper.put(option, arg);
+        return false;
+    }
+
+    public boolean process(OptionHelper helper, String option) {
+        if (hasSuffix)
+            return process(helper, text, option.substring(text.length()));
+        else
+            return process(helper, option, option);
+    }
+
+    void help(Log log, OptionKind kind) {
+        if (this.kind != kind)
+            return;
+
+        log.printRawLines(WriterKind.NOTICE,
+                String.format("  %-26s %s",
+                    helpSynopsis(log),
+                    log.localize(PrefixKind.JAVAC, descrKey)));
+
+    }
+
+    private String helpSynopsis(Log log) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(text);
+        if (argsNameKey == null) {
+            if (choices != null) {
+                String sep = "{";
+                for (Map.Entry<String,Boolean> e: choices.entrySet()) {
+                    if (!e.getValue()) {
+                        sb.append(sep);
+                        sb.append(e.getKey());
+                        sep = ",";
+                    }
+                }
+                sb.append("}");
+            }
+        } else {
+            if (!hasSuffix)
+                sb.append(" ");
+            sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
+
+        }
+
+        return sb.toString();
+    }
+
+    // For -XpkgInfo:value
+    public enum PkgInfo {
+        ALWAYS, LEGACY, NONEMPTY;
+        public static PkgInfo get(Options options) {
+            String v = options.get(XPKGINFO);
+            return (v == null
+                    ? PkgInfo.LEGACY
+                    : PkgInfo.valueOf(v.toUpperCase()));
+        }
+    }
+
+    private static Map<String,Boolean> getXLintChoices() {
+        Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
+        choices.put("all", false);
+        for (Lint.LintCategory c : Lint.LintCategory.values())
+            choices.put(c.option, c.hidden);
+        for (Lint.LintCategory c : Lint.LintCategory.values())
+            choices.put("-" + c.option, c.hidden);
+        choices.put("none", false);
+        return choices;
+    }
+
+    static Set<Option> getJavaCompilerOptions() {
+        return EnumSet.allOf(Option.class);
+    }
+
+    public static Set<Option> getJavacFileManagerOptions() {
+        return getOptions(EnumSet.of(FILEMANAGER));
+    }
+
+    public static Set<Option> getJavacToolOptions() {
+        return getOptions(EnumSet.of(BASIC));
+    }
+
+    static Set<Option> getOptions(Set<OptionGroup> desired) {
+        Set<Option> options = EnumSet.noneOf(Option.class);
+        for (Option option : Option.values())
+            if (desired.contains(option.group))
+                options.add(option);
+        return Collections.unmodifiableSet(options);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/main/OptionHelper.java	Fri Dec 23 16:39:22 2011 -0800
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.main;
+
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Log.PrefixKind;
+import java.io.File;
+
+/**
+ * Helper object to be used by {@link Option#process}, providing access to
+ * the compilation environment.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own
+ * risk.  This code and its internal interfaces are subject to change
+ * or deletion without notice.</b></p>
+ */
+
+public abstract class OptionHelper {
+
+    /** Get the current value of an option. */
+    public abstract String get(Option option);
+
+    /** Set the value of an option. */
+    public abstract void put(String name, String value);
+
+    /** Remove any prior value for an option. */
+    public abstract void remove(String name);
+
+    /** Get access to the Log for the compilation. */
+    public abstract Log getLog();
+
+    /** Get the name of the tool, such as "javac", to be used in info like -help. */
+    public abstract String getOwnName();
+
+    /** Report an error. */
+    abstract void error(String key, Object... args);
+
+    /** Record a file to be compiled. */
+    abstract void addFile(File f);
+
+    /** Record the name of a class for annotation processing. */
+    abstract void addClassName(String s);
+
+    /** An implementation of OptionHelper that mostly throws exceptions. */
+    public static class GrumpyHelper extends OptionHelper {
+        private final Log log;
+
+        public GrumpyHelper(Log log) {
+            this.log = log;
+        }
+
+        @Override
+        public Log getLog() {
+            return log;
+        }
+
+        @Override
+        public String getOwnName() {
+            throw new IllegalStateException();
+        }
+
+        @Override
+        public String get(Option option) {
+            throw new IllegalArgumentException();
+        }
+
+        @Override
+        public void put(String name, String value) {
+            throw new IllegalArgumentException();
+        }
+
+        @Override
+        public void remove(String name) {
+            throw new IllegalArgumentException();
+        }
+
+        @Override
+        void error(String key, Object... args) {
+            throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
+        }
+
+        @Override
+        public void addFile(File f) {
+            throw new IllegalArgumentException(f.getPath());
+        }
+
+        @Override
+        public void addClassName(String s) {
+            throw new IllegalArgumentException(s);
+        }
+    }
+
+}
--- a/src/share/classes/com/sun/tools/javac/main/OptionName.java	Thu Dec 22 19:00:58 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.main;
-
-
-/**
- * TODO: describe com.sun.tools.javac.main.OptionName
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own
- * risk.  This code and its internal interfaces are subject to change
- * or deletion without notice.</b></p>
- */
-public enum OptionName {
-    G("-g"),
-    G_NONE("-g:none"),
-    G_CUSTOM("-g:"),
-    XLINT("-Xlint"),
-    XLINT_CUSTOM("-Xlint:"),
-    DIAGS("-XDdiags="),
-    NOWARN("-nowarn"),
-    VERBOSE("-verbose"),
-    DEPRECATION("-deprecation"),
-    CLASSPATH("-classpath"),
-    CP("-cp"),
-    SOURCEPATH("-sourcepath"),
-    BOOTCLASSPATH("-bootclasspath"),
-    XBOOTCLASSPATH_PREPEND("-Xbootclasspath/p:"),
-    XBOOTCLASSPATH_APPEND("-Xbootclasspath/a:"),
-    XBOOTCLASSPATH("-Xbootclasspath:"),
-    EXTDIRS("-extdirs"),
-    DJAVA_EXT_DIRS("-Djava.ext.dirs="),
-    ENDORSEDDIRS("-endorseddirs"),
-    DJAVA_ENDORSED_DIRS("-Djava.endorsed.dirs="),
-    PROC("-proc:"),
-    PROCESSOR("-processor"),
-    PROCESSORPATH("-processorpath"),
-    D("-d"),
-    S("-s"),
-    IMPLICIT("-implicit:"),
-    ENCODING("-encoding"),
-    SOURCE("-source"),
-    TARGET("-target"),
-    VERSION("-version"),
-    FULLVERSION("-fullversion"),
-    HELP("-help"),
-    A("-A"),
-    X("-X"),
-    J("-J"),
-    MOREINFO("-moreinfo"),
-    WERROR("-Werror"),
-    COMPLEXINFERENCE("-complexinference"),
-    PROMPT("-prompt"),
-    DOE("-doe"),
-    PRINTSOURCE("-printsource"),
-    WARNUNCHECKED("-warnunchecked"),
-    XMAXERRS("-Xmaxerrs"),
-    XMAXWARNS("-Xmaxwarns"),
-    XSTDOUT("-Xstdout"),
-    XPKGINFO("-Xpkginfo:"),
-    XPRINT("-Xprint"),
-    XPRINTROUNDS("-XprintRounds"),
-    XPRINTPROCESSORINFO("-XprintProcessorInfo"),
-    XPREFER("-Xprefer:"),
-    O("-O"),
-    XJCOV("-Xjcov"),
-    XD("-XD"),
-    AT("@"),
-    SOURCEFILE("sourcefile");
-
-    public final String optionName;
-
-    OptionName(String optionName) {
-        this.optionName = optionName;
-    }
-
-    @Override
-    public String toString() {
-        return optionName;
-    }
-
-}
--- a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Thu Dec 22 19:00:58 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,651 +0,0 @@
-/*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.javac.main;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.util.EnumSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import javax.lang.model.SourceVersion;
-
-import com.sun.tools.javac.code.Lint;
-import com.sun.tools.javac.code.Source;
-import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.main.JavacOption.HiddenOption;
-import com.sun.tools.javac.main.JavacOption.Option;
-import com.sun.tools.javac.main.JavacOption.XOption;
-import com.sun.tools.javac.processing.JavacProcessingEnvironment;
-import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Log.PrefixKind;
-import com.sun.tools.javac.util.Options;
-
-import static com.sun.tools.javac.main.OptionName.*;
-
-/**
- * TODO: describe com.sun.tools.javac.main.RecognizedOptions
- *
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own
- * risk.  This code and its internal interfaces are subject to change
- * or deletion without notice.</b></p>
- */
-public class RecognizedOptions {
-
-    private RecognizedOptions() {}
-
-    public interface OptionHelper {
-
-        void setOut(PrintWriter out);
-
-        void error(String key, Object... args);
-
-        void printVersion();
-
-        void printFullVersion();
-
-        void printHelp();
-
-        void printXhelp();
-
-        void addFile(File f);
-
-        void addClassName(String s);
-
-    }
-
-    public static class GrumpyHelper implements OptionHelper {
-        private Log log;
-
-        public GrumpyHelper(Log log) {
-            this.log = log;
-        }
-
-        public void setOut(PrintWriter out) {
-            throw new IllegalArgumentException();
-        }
-
-        public void error(String key, Object... args) {
-            throw new IllegalArgumentException(log.localize(PrefixKind.JAVAC, key, args));
-        }
-
-        public void printVersion() {
-            throw new IllegalArgumentException();
-        }
-
-        public void printFullVersion() {
-            throw new IllegalArgumentException();
-        }
-
-        public void printHelp() {
-            throw new IllegalArgumentException();
-        }
-
-        public void printXhelp() {
-            throw new IllegalArgumentException();
-        }
-
-        public void addFile(File f) {
-            throw new IllegalArgumentException(f.getPath());
-        }
-
-        public void addClassName(String s) {
-            throw new IllegalArgumentException(s);
-        }
-
-    }
-
-    static Set<OptionName> javacOptions = EnumSet.of(
-        G,
-        G_NONE,
-        G_CUSTOM,
-        XLINT,
-        XLINT_CUSTOM,
-        NOWARN,
-        VERBOSE,
-        DEPRECATION,
-        CLASSPATH,
-        CP,
-        SOURCEPATH,
-        BOOTCLASSPATH,
-        XBOOTCLASSPATH_PREPEND,
-        XBOOTCLASSPATH_APPEND,
-        XBOOTCLASSPATH,
-        EXTDIRS,
-        DJAVA_EXT_DIRS,
-        ENDORSEDDIRS,
-        DJAVA_ENDORSED_DIRS,
-        PROC,
-        PROCESSOR,
-        PROCESSORPATH,
-        D,
-        S,
-        IMPLICIT,
-        ENCODING,
-        SOURCE,
-        TARGET,
-        VERSION,
-        FULLVERSION,
-        DIAGS,
-        HELP,
-        A,
-        X,
-        J,
-        MOREINFO,
-        WERROR,
-        // COMPLEXINFERENCE,
-        PROMPT,
-        DOE,
-        PRINTSOURCE,
-        WARNUNCHECKED,
-        XMAXERRS,
-        XMAXWARNS,
-        XSTDOUT,
-        XPKGINFO,
-        XPRINT,
-        XPRINTROUNDS,
-        XPRINTPROCESSORINFO,
-        XPREFER,
-        O,
-        XJCOV,
-        XD,
-        AT,
-        SOURCEFILE);
-
-    static Set<OptionName> javacFileManagerOptions = EnumSet.of(
-        CLASSPATH,
-        CP,
-        SOURCEPATH,
-        BOOTCLASSPATH,
-        XBOOTCLASSPATH_PREPEND,
-        XBOOTCLASSPATH_APPEND,
-        XBOOTCLASSPATH,
-        EXTDIRS,
-        DJAVA_EXT_DIRS,
-        ENDORSEDDIRS,
-        DJAVA_ENDORSED_DIRS,
-        PROCESSORPATH,
-        D,
-        S,
-        ENCODING,
-        SOURCE);
-
-    static Set<OptionName> javacToolOptions = EnumSet.of(
-        G,
-        G_NONE,
-        G_CUSTOM,
-        XLINT,
-        XLINT_CUSTOM,
-        NOWARN,
-        VERBOSE,
-        DEPRECATION,
-        PROC,
-        PROCESSOR,
-        IMPLICIT,
-        SOURCE,
-        TARGET,
-        // VERSION,
-        // FULLVERSION,
-        // HELP,
-        A,
-        // X,
-        // J,
-        MOREINFO,
-        WERROR,
-        // COMPLEXINFERENCE,
-        PROMPT,
-        DOE,
-        PRINTSOURCE,
-        WARNUNCHECKED,
-        XMAXERRS,
-        XMAXWARNS,
-        // XSTDOUT,
-        XPKGINFO,
-        XPRINT,
-        XPRINTROUNDS,
-        XPRINTPROCESSORINFO,
-        XPREFER,
-        O,
-        XJCOV,
-        XD);
-
-    static Option[] getJavaCompilerOptions(OptionHelper helper) {
-        return getOptions(helper, javacOptions);
-    }
-
-    public static Option[] getJavacFileManagerOptions(OptionHelper helper) {
-        return getOptions(helper, javacFileManagerOptions);
-    }
-
-    public static Option[] getJavacToolOptions(OptionHelper helper) {
-        return getOptions(helper, javacToolOptions);
-    }
-
-    static Option[] getOptions(OptionHelper helper, Set<OptionName> desired) {
-        ListBuffer<Option> options = new ListBuffer<Option>();
-        for (Option option : getAll(helper))
-            if (desired.contains(option.getName()))
-                options.append(option);
-        return options.toArray(new Option[options.length()]);
-    }
-
-    /**
-     * Get all the recognized options.
-     * @param helper an {@code OptionHelper} to help when processing options
-     * @return an array of options
-     */
-    public static Option[] getAll(final OptionHelper helper) {
-        return new Option[] {
-        new Option(G,                                           "opt.g"),
-        new Option(G_NONE,                                      "opt.g.none") {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-g:", "none");
-                return false;
-            }
-        },
-
-        new Option(G_CUSTOM,                                    "opt.g.lines.vars.source",
-                Option.ChoiceKind.ANYOF, "lines", "vars", "source"),
-
-        new XOption(XLINT,                                      "opt.Xlint"),
-        new XOption(XLINT_CUSTOM,                               "opt.Xlint.suboptlist",
-                Option.ChoiceKind.ANYOF, getXLintChoices()),
-
-        // -nowarn is retained for command-line backward compatibility
-        new Option(NOWARN,                                      "opt.nowarn") {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-Xlint:none", option);
-                return false;
-            }
-        },
-
-        new Option(VERBOSE,                                     "opt.verbose"),
-
-        // -deprecation is retained for command-line backward compatibility
-        new Option(DEPRECATION,                                 "opt.deprecation") {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-Xlint:deprecation", option);
-                return false;
-            }
-        },
-
-        new Option(CLASSPATH,              "opt.arg.path",      "opt.classpath"),
-        new Option(CP,                     "opt.arg.path",      "opt.classpath") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                return super.process(options, "-classpath", arg);
-            }
-        },
-        new Option(SOURCEPATH,             "opt.arg.path",      "opt.sourcepath"),
-        new Option(BOOTCLASSPATH,          "opt.arg.path",      "opt.bootclasspath") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                options.remove("-Xbootclasspath/p:");
-                options.remove("-Xbootclasspath/a:");
-                return super.process(options, option, arg);
-            }
-        },
-        new XOption(XBOOTCLASSPATH_PREPEND,"opt.arg.path", "opt.Xbootclasspath.p"),
-        new XOption(XBOOTCLASSPATH_APPEND, "opt.arg.path", "opt.Xbootclasspath.a"),
-        new XOption(XBOOTCLASSPATH,        "opt.arg.path", "opt.bootclasspath") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                options.remove("-Xbootclasspath/p:");
-                options.remove("-Xbootclasspath/a:");
-                return super.process(options, "-bootclasspath", arg);
-            }
-        },
-        new Option(EXTDIRS,                "opt.arg.dirs",      "opt.extdirs"),
-        new XOption(DJAVA_EXT_DIRS,        "opt.arg.dirs",      "opt.extdirs") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                return super.process(options, "-extdirs", arg);
-            }
-        },
-        new Option(ENDORSEDDIRS,            "opt.arg.dirs",     "opt.endorseddirs"),
-        new XOption(DJAVA_ENDORSED_DIRS,    "opt.arg.dirs",     "opt.endorseddirs") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                return super.process(options, "-endorseddirs", arg);
-            }
-        },
-        new Option(PROC,                                 "opt.proc.none.only",
-                Option.ChoiceKind.ONEOF, "none", "only"),
-        new Option(PROCESSOR,           "opt.arg.class.list",   "opt.processor"),
-        new Option(PROCESSORPATH,       "opt.arg.path",         "opt.processorpath"),
-        new Option(D,                   "opt.arg.directory",    "opt.d"),
-        new Option(S,                   "opt.arg.directory",    "opt.sourceDest"),
-        new Option(IMPLICIT,                                    "opt.implicit",
-                Option.ChoiceKind.ONEOF, "none", "class"),
-        new Option(ENCODING,            "opt.arg.encoding",     "opt.encoding"),
-        new Option(SOURCE,              "opt.arg.release",      "opt.source") {
-            @Override
-            public boolean process(Options options, String option, String operand) {
-                Source source = Source.lookup(operand);
-                if (source == null) {
-                    helper.error("err.invalid.source", operand);
-                    return true;
-                }
-                return super.process(options, option, operand);
-            }
-        },
-        new Option(TARGET,              "opt.arg.release",      "opt.target") {
-            @Override
-            public boolean process(Options options, String option, String operand) {
-                Target target = Target.lookup(operand);
-                if (target == null) {
-                    helper.error("err.invalid.target", operand);
-                    return true;
-                }
-                return super.process(options, option, operand);
-            }
-        },
-        new Option(VERSION,                                     "opt.version") {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printVersion();
-                return super.process(options, option);
-            }
-        },
-        new HiddenOption(FULLVERSION) {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printFullVersion();
-                return super.process(options, option);
-            }
-        },
-        new HiddenOption(DIAGS) {
-            @Override
-            public boolean process(Options options, String option) {
-                Option xd = getOptions(helper, EnumSet.of(XD))[0];
-                option = option.substring(option.indexOf('=') + 1);
-                String diagsOption = option.contains("%") ?
-                    "-XDdiagsFormat=" :
-                    "-XDdiags=";
-                diagsOption += option;
-                if (xd.matches(diagsOption))
-                    return xd.process(options, diagsOption);
-                else
-                    return false;
-            }
-        },
-        new Option(HELP,                                        "opt.help") {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printHelp();
-                return super.process(options, option);
-            }
-        },
-        new Option(A,                "opt.arg.key.equals.value","opt.A") {
-            @Override
-            String helpSynopsis(Log log) {
-                hasSuffix = true;
-                return super.helpSynopsis(log);
-            }
-
-            @Override
-            public boolean matches(String arg) {
-                return arg.startsWith("-A");
-            }
-
-            @Override
-            public boolean hasArg() {
-                return false;
-            }
-            // Mapping for processor options created in
-            // JavacProcessingEnvironment
-            @Override
-            public boolean process(Options options, String option) {
-                int argLength = option.length();
-                if (argLength == 2) {
-                    helper.error("err.empty.A.argument");
-                    return true;
-                }
-                int sepIndex = option.indexOf('=');
-                String key = option.substring(2, (sepIndex != -1 ? sepIndex : argLength) );
-                if (!JavacProcessingEnvironment.isValidOptionName(key)) {
-                    helper.error("err.invalid.A.key", option);
-                    return true;
-                }
-                return process(options, option, option);
-            }
-        },
-        new Option(X,                                           "opt.X") {
-            @Override
-            public boolean process(Options options, String option) {
-                helper.printXhelp();
-                return super.process(options, option);
-            }
-        },
-
-        // This option exists only for the purpose of documenting itself.
-        // It's actually implemented by the launcher.
-        new Option(J,                   "opt.arg.flag",         "opt.J") {
-            @Override
-            String helpSynopsis(Log log) {
-                hasSuffix = true;
-                return super.helpSynopsis(log);
-            }
-            @Override
-            public boolean process(Options options, String option) {
-                throw new AssertionError
-                    ("the -J flag should be caught by the launcher.");
-            }
-        },
-
-        // stop after parsing and attributing.
-        // new HiddenOption("-attrparseonly"),
-
-        // new Option("-moreinfo",                                      "opt.moreinfo") {
-        new HiddenOption(MOREINFO) {
-            @Override
-            public boolean process(Options options, String option) {
-                Type.moreInfo = true;
-                return super.process(options, option);
-            }
-        },
-
-        // treat warnings as errors
-        new Option(WERROR,                                      "opt.Werror"),
-
-        // use complex inference from context in the position of a method call argument
-        new HiddenOption(COMPLEXINFERENCE),
-
-        // 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"),
-        new HiddenOption(PROMPT),
-
-        // dump stack on error
-        new HiddenOption(DOE),
-
-        // output source after type erasure
-        // new Option("-s",                                     "opt.s"),
-        new HiddenOption(PRINTSOURCE),
-
-        // output shrouded class files
-        // new Option("-scramble",                              "opt.scramble"),
-        // new Option("-scrambleall",                           "opt.scrambleall"),
-
-        // display warnings for generic unchecked operations
-        new HiddenOption(WARNUNCHECKED) {
-            @Override
-            public boolean process(Options options, String option) {
-                options.put("-Xlint:unchecked", option);
-                return false;
-            }
-        },
-
-        new XOption(XMAXERRS,           "opt.arg.number",       "opt.maxerrs"),
-        new XOption(XMAXWARNS,          "opt.arg.number",       "opt.maxwarns"),
-        new XOption(XSTDOUT,            "opt.arg.file",         "opt.Xstdout") {
-            @Override
-            public boolean process(Options options, String option, String arg) {
-                try {
-                    helper.setOut(new PrintWriter(new FileWriter(arg), true));
-                } catch (java.io.IOException e) {
-                    helper.error("err.error.writing.file", arg, e);
-                    return true;
-                }
-                return super.process(options, option, arg);
-            }
-        },
-
-        new XOption(XPRINT,                                     "opt.print"),
-
-        new XOption(XPRINTROUNDS,                               "opt.printRounds"),
-
-        new XOption(XPRINTPROCESSORINFO,                        "opt.printProcessorInfo"),
-
-        new XOption(XPREFER,                                    "opt.prefer",
-                Option.ChoiceKind.ONEOF, "source", "newer"),
-
-        new XOption(XPKGINFO,                                   "opt.pkginfo",
-                Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),
-
-        /* -O is a no-op, accepted for backward compatibility. */
-        new HiddenOption(O),
-
-        /* -Xjcov produces tables to support the code coverage tool jcov. */
-        new HiddenOption(XJCOV),
-
-        /* This is a back door to the compiler's option table.
-         * -XDx=y sets the option x to the value y.
-         * -XDx sets the option x to the value x.
-         */
-        new HiddenOption(XD) {
-            String s;
-            @Override
-            public boolean matches(String s) {
-                this.s = s;
-                return s.startsWith(name.optionName);
-            }
-            @Override
-            public boolean process(Options options, String option) {
-                s = s.substring(name.optionName.length());
-                int eq = s.indexOf('=');
-                String key = (eq < 0) ? s : s.substring(0, eq);
-                String value = (eq < 0) ? s : s.substring(eq+1);
-                options.put(key, value);
-                return false;
-            }
-        },
-
-        // This option exists only for the purpose of documenting itself.
-        // It's actually implemented by the CommandLine class.
-        new Option(AT,                   "opt.arg.file",         "opt.AT") {
-            @Override
-            String helpSynopsis(Log log) {
-                hasSuffix = true;
-                return super.helpSynopsis(log);
-            }
-            @Override
-            public boolean process(Options options, String option) {
-                throw new AssertionError
-                    ("the @ flag should be caught by CommandLine.");
-            }
-        },
-
-        /*
-         * TODO: With apt, the matches method accepts anything if
-         * -XclassAsDecls is used; code elsewhere does the lookup to
-         * see if the class name is both legal and found.
-         *
-         * In apt, the process method adds the candidate class file
-         * name to a separate list.
-         */
-        new HiddenOption(SOURCEFILE) {
-            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(Options options, String option) {
-                if (s.endsWith(".java") ) {
-                    File f = new File(s);
-                    if (!f.exists()) {
-                        helper.error("err.file.not.found", f);
-                        return true;
-                    }
-                    if (!f.isFile()) {
-                        helper.error("err.file.not.file", f);
-                        return true;
-                    }
-                    helper.addFile(f);
-                }
-                else
-                    helper.addClassName(s);
-                return false;
-            }
-        },
-    };
-    }
-
-    public enum PkgInfo {
-        ALWAYS, LEGACY, NONEMPTY;
-        public static PkgInfo get(Options options) {
-            String v = options.get(XPKGINFO);
-            return (v == null
-                    ? PkgInfo.LEGACY
-                    : PkgInfo.valueOf(v.toUpperCase()));
-        }
-    }
-
-    private static Map<String,Boolean> getXLintChoices() {
-        Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
-        choices.put("all", false);
-        for (Lint.LintCategory c : Lint.LintCategory.values())
-            choices.put(c.option, c.hidden);
-        for (Lint.LintCategory c : Lint.LintCategory.values())
-            choices.put("-" + c.option, c.hidden);
-        choices.put("none", false);
-        return choices;
-    }
-
-}
--- a/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Fri Dec 23 16:39:22 2011 -0800
@@ -63,7 +63,7 @@
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 
 // NOTE the imports carefully for this compilation unit.
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Dec 23 16:39:22 2011 -0800
@@ -787,7 +787,7 @@
             top++;
             topOp = token;
             nextToken();
-            odStack[top] = (topOp.kind == INSTANCEOF) ? parseType() : term3NoParams();
+            odStack[top] = (topOp.kind == INSTANCEOF) ? parseType() : term3();
             while (top > 0 && prec(topOp.kind) >= prec(token.kind)) {
                 odStack[top-1] = makeOp(topOp.pos, topOp.kind, odStack[top-1],
                                         odStack[top]);
@@ -931,7 +931,7 @@
                     mode = EXPR;
                     t = literal(names.hyphen, pos);
                 } else {
-                    t = term3NoParams();
+                    t = term3();
                     return F.at(pos).Unary(unoptag(tk), t);
                 }
             } else return illegal();
@@ -947,8 +947,8 @@
                     break;
                 } else {
                     nextToken();
-                    mode = EXPR | TYPE;
-                    t = term3NoParams();
+                    mode = EXPR | TYPE | NOPARAMS;
+                    t = term3();
                     if ((mode & TYPE) != 0 && token.kind == LT) {
                         // Could be a cast to a parameterized type
                         JCTree.Tag op = JCTree.Tag.LT;
@@ -1011,7 +1011,7 @@
                 lastmode = mode;
                 mode = EXPR;
                 if ((lastmode & EXPR) == 0) {
-                    JCExpression t1 = term3NoParams();
+                    JCExpression t1 = term3();
                     return F.at(pos).TypeCast(t, t1);
                 } else if ((lastmode & TYPE) != 0) {
                     switch (token.kind) {
@@ -1024,7 +1024,7 @@
                         case NEW: case IDENTIFIER: case ASSERT: case ENUM:
                     case BYTE: case SHORT: case CHAR: case INT:
                     case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
-                        JCExpression t1 = term3NoParams();
+                        JCExpression t1 = term3();
                         return F.at(pos).TypeCast(t, t1);
                     }
                 }
@@ -1143,49 +1143,35 @@
                         // typeArgs saved for next loop iteration.
                         t = toP(F.at(pos).Select(t, ident()));
                         break;
-//                    case LT:
-//                        if ((mode & (TYPE | NOPARAMS)) == 0) {
-//                            //could be an unbound method reference whose qualifier
-//                            //is a generic type i.e. A<S>#m
-//                            mode = EXPR | TYPE;
-//                            JCTree.Tag op = JCTree.Tag.LT;
-//                            int pos1 = token.pos;
-//                            nextToken();
-//                            mode |= EXPR | TYPE | TYPEARG;
-//                            JCExpression t1 = term3();
-//                            if ((mode & TYPE) != 0 &&
-//                                (token.kind == COMMA || token.kind == GT)) {
-//                                mode = TYPE;
-//                                ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
-//                                args.append(t1);
-//                                while (token.kind == COMMA) {
-//                                    nextToken();
-//                                    args.append(typeArgument());
-//                                }
-//                                accept(GT);
-//                                t = toP(F.at(pos1).TypeApply(t, args.toList()));
-//                                checkGenerics();
-//                                while (token.kind == DOT) {
-//                                    nextToken();
-//                                    mode = TYPE;
-//                                    t = toP(F.at(token.pos).Select(t, ident()));
-//                                    t = typeArgumentsOpt(t);
-//                                }
-//                                if (token.kind != HASH) {
-//                                    //method reference expected here
-//                                    t = illegal();
-//                                }
-//                                mode = EXPR;
-//                                break;
-//                            } else if ((mode & EXPR) != 0) {
-//                                //rollback - it was a binary expression
-//                                mode = EXPR;
-//                                JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
-//                                t = F.at(pos1).Binary(op, t, e);
-//                                t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
-//                            }
-//                        }
-//                        break loop;
+                    case LT:
+                        if ((mode & TYPE) == 0 && isUnboundMemberRef()) {
+                            //this is an unbound method reference whose qualifier
+                            //is a generic type i.e. A<S>#m
+                            int pos1 = token.pos;
+                            accept(LT);
+                            ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
+                            args.append(typeArgument());
+                            while (token.kind == COMMA) {
+                                nextToken();
+                                args.append(typeArgument());
+                            }
+                            accept(GT);
+                            t = toP(F.at(pos1).TypeApply(t, args.toList()));
+                            checkGenerics();
+                            while (token.kind == DOT) {
+                                nextToken();
+                                mode = TYPE;
+                                t = toP(F.at(token.pos).Select(t, ident()));
+                                t = typeArgumentsOpt(t);
+                            }
+                            if (token.kind != HASH) {
+                                //method reference expected here
+                                t = illegal();
+                            }
+                            mode = EXPR;
+                            return term3Rest(t, typeArgs);
+                        }
+                        break loop;
                     default:
                         break loop;
                     }
@@ -1225,15 +1211,6 @@
         return term3Rest(t, typeArgs);
     }
 
-    JCExpression term3NoParams() {
-        try {
-            mode |= NOPARAMS;
-            return term3();
-        } finally {
-            mode &= ~NOPARAMS;
-        }
-    }
-
     JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
         if (typeArgs != null) illegal();
         while (true) {
@@ -1297,6 +1274,41 @@
         return toP(t);
     }
 
+    /**
+     * If we see an identifier followed by a '&lt;' it could be an unbound
+     * method reference or a binary expression. To disambiguate, look for a
+     * matching '&gt;' and see if the subsequent terminal is either '.' or '#'.
+     */
+    @SuppressWarnings("fallthrough")
+    boolean isUnboundMemberRef() {
+        int pos = 0, depth = 0;
+        for (Token t = S.token(pos) ; ; t = S.token(++pos)) {
+            switch (t.kind) {
+                case IDENTIFIER: case QUES: case EXTENDS: case SUPER:
+                case DOT: case RBRACKET: case LBRACKET: case COMMA:
+                case BYTE: case SHORT: case INT: case LONG: case FLOAT:
+                case DOUBLE: case BOOLEAN: case CHAR:
+                    break;
+                case LT:
+                    depth++; break;
+                case GTGTGT:
+                    depth--;
+                case GTGT:
+                    depth--;
+                case GT:
+                    depth--;
+                    if (depth == 0) {
+                        return
+                            S.token(pos + 1).kind == TokenKind.DOT ||
+                            S.token(pos + 1).kind == TokenKind.HASH;
+                    }
+                    break;
+                default:
+                    return false;
+            }
+        }
+    }
+
     JCExpression lambdaExpressionOrStatement(JCVariableDecl firstParam, int pos) {
         ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
         params.append(firstParam);
--- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Dec 23 16:39:22 2011 -0800
@@ -82,7 +82,7 @@
 
 import static javax.tools.StandardLocation.*;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
 
 /**
@@ -1033,12 +1033,10 @@
             Assert.checkNonNull(options);
             next.put(Options.optionsKey, options);
 
-            PrintWriter out = context.get(Log.outKey);
-            Assert.checkNonNull(out);
-            next.put(Log.outKey, out);
             Locale locale = context.get(Locale.class);
             if (locale != null)
                 next.put(Locale.class, locale);
+
             Assert.checkNonNull(messages);
             next.put(JavacMessages.messagesKey, messages);
 
@@ -1076,6 +1074,9 @@
             Assert.checkNonNull(tokens);
             next.put(Tokens.tokensKey, tokens);
 
+            // propogate the log's writers directly, instead of going through context
+            Log.instance(next).setWriters(log);
+
             JavaCompiler oldCompiler = JavaCompiler.instance(context);
             JavaCompiler nextCompiler = JavaCompiler.instance(next);
             nextCompiler.initRound(oldCompiler);
@@ -1472,14 +1473,6 @@
         return context;
     }
 
-    /**
-     * Internal use method to return the writer being used by the
-     * processing environment.
-     */
-    public PrintWriter getWriter() {
-        return context.get(Log.outKey);
-    }
-
     public String toString() {
         return "javac ProcessingEnvironment";
     }
--- a/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java	Fri Dec 23 16:39:22 2011 -0800
@@ -46,6 +46,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import javax.tools.JavaFileObject;
 import javax.tools.JavaFileObject.Kind;
 
@@ -53,9 +54,9 @@
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.file.FSInfo;
 import com.sun.tools.javac.file.Locations;
-import com.sun.tools.javac.main.JavacOption;
-import com.sun.tools.javac.main.OptionName;
-import com.sun.tools.javac.main.RecognizedOptions;
+import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
 import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
 
 /**
@@ -101,7 +102,7 @@
     protected Locations locations;
 
     protected Source getSource() {
-        String sourceName = options.get(OptionName.SOURCE);
+        String sourceName = options.get(Option.SOURCE);
         Source source = null;
         if (sourceName != null)
             source = Source.lookup(sourceName);
@@ -145,15 +146,31 @@
 
     // <editor-fold defaultstate="collapsed" desc="Option handling">
     public boolean handleOption(String current, Iterator<String> remaining) {
-        for (JavacOption o: javacFileManagerOptions) {
+        OptionHelper helper = new GrumpyHelper(log) {
+            @Override
+            public String get(Option option) {
+                return options.get(option.getText());
+            }
+
+            @Override
+            public void put(String name, String value) {
+                options.put(name, value);
+            }
+
+            @Override
+            public void remove(String name) {
+                options.remove(name);
+            }
+        };
+        for (Option o: javacFileManagerOptions) {
             if (o.matches(current))  {
                 if (o.hasArg()) {
                     if (remaining.hasNext()) {
-                        if (!o.process(options, current, remaining.next()))
+                        if (!o.process(helper, current, remaining.next()))
                             return true;
                     }
                 } else {
-                    if (!o.process(options, current))
+                    if (!o.process(helper, current))
                         return true;
                 }
                 // operand missing, or process returned false
@@ -164,12 +181,11 @@
         return false;
     }
     // where
-        private static JavacOption[] javacFileManagerOptions =
-            RecognizedOptions.getJavacFileManagerOptions(
-            new RecognizedOptions.GrumpyHelper(Log.instance(new Context())));
+        private static Set<Option> javacFileManagerOptions =
+            Option.getJavacFileManagerOptions();
 
     public int isSupportedOption(String option) {
-        for (JavacOption o : javacFileManagerOptions) {
+        for (Option o : javacFileManagerOptions) {
             if (o.matches(option))
                 return o.hasArg() ? 1 : 0;
         }
@@ -191,7 +207,7 @@
     }
 
     public String getEncodingName() {
-        String encName = options.get(OptionName.ENCODING);
+        String encName = options.get(Option.ENCODING);
         if (encName == null)
             return getDefaultEncodingName();
         else
--- a/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Fri Dec 23 16:39:22 2011 -0800
@@ -25,25 +25,23 @@
 
 package com.sun.tools.javac.util;
 
-import com.sun.tools.javac.main.Main;
 import java.io.*;
 import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
-import com.sun.tools.javac.main.OptionName;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.parser.EndPosTable;
-import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 
-import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.main.Option.*;
 
 /** A class for error logs. Reports errors and warnings, and
  *  keeps track of error numbers and positions.
@@ -137,7 +135,6 @@
 
     /** Construct a log with given I/O redirections.
      */
-    @Deprecated
     protected Log(Context context, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter) {
         super(JCDiagnostic.Factory.instance(context));
         context.put(logKey, this);
@@ -179,8 +176,8 @@
                 expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *")));
         }
 
-        private int getIntOption(Options options, OptionName optionName, int defaultValue) {
-            String s = options.get(optionName);
+        private int getIntOption(Options options, Option option, int defaultValue) {
+            String s = options.get(option);
             try {
                 if (s != null) {
                     int n = Integer.parseInt(s);
@@ -298,6 +295,12 @@
         noticeWriter = warnWriter = errWriter = pw;
     }
 
+    public void setWriters(Log other) {
+        this.noticeWriter = other.noticeWriter;
+        this.warnWriter = other.warnWriter;
+        this.errWriter = other.errWriter;
+    }
+
     /** Flush the logs
      */
     public void flush() {
--- a/src/share/classes/com/sun/tools/javac/util/Options.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/src/share/classes/com/sun/tools/javac/util/Options.java	Fri Dec 23 16:39:22 2011 -0800
@@ -26,8 +26,8 @@
 package com.sun.tools.javac.util;
 
 import java.util.*;
-import com.sun.tools.javac.main.OptionName;
-import static com.sun.tools.javac.main.OptionName.*;
+import com.sun.tools.javac.main.Option;
+import static com.sun.tools.javac.main.Option.*;
 
 /** A table of all command-line options.
  *  If an option has an argument, the option name is mapped to the argument.
@@ -71,8 +71,8 @@
     /**
      * Get the value for an option.
      */
-    public String get(OptionName name) {
-        return values.get(name.optionName);
+    public String get(Option option) {
+        return values.get(option.text);
     }
 
     /**
@@ -101,15 +101,15 @@
     /**
      * Check if the value for an option has been set.
      */
-    public boolean isSet(OptionName name) {
-        return (values.get(name.optionName) != null);
+    public boolean isSet(Option option) {
+        return (values.get(option.text) != null);
     }
 
     /**
      * Check if the value for a choice option has been set to a specific value.
      */
-    public boolean isSet(OptionName name, String value) {
-        return (values.get(name.optionName + value) != null);
+    public boolean isSet(Option option, String value) {
+        return (values.get(option.text + value) != null);
     }
 
     /**
@@ -122,23 +122,23 @@
     /**
      * Check if the value for an option has not been set.
      */
-    public boolean isUnset(OptionName name) {
-        return (values.get(name.optionName) == null);
+    public boolean isUnset(Option option) {
+        return (values.get(option.text) == null);
     }
 
     /**
      * Check if the value for a choice option has not been set to a specific value.
      */
-    public boolean isUnset(OptionName name, String value) {
-        return (values.get(name.optionName + value) == null);
+    public boolean isUnset(Option option, String value) {
+        return (values.get(option.text + value) == null);
     }
 
     public void put(String name, String value) {
         values.put(name, value);
     }
 
-    public void put(OptionName name, String value) {
-        values.put(name.optionName, value);
+    public void put(Option option, String value) {
+        values.put(option.text, value);
     }
 
     public void putAll(Options options) {
--- a/test/tools/javac/4846262/Test.sh	Thu Dec 22 19:00:58 2011 -0800
+++ b/test/tools/javac/4846262/Test.sh	Fri Dec 23 16:39:22 2011 -0800
@@ -1,7 +1,7 @@
 #!/bin/sh -f
 
 #
-# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@
 diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
 result=$?
 
-if [ $result -eq o ]
+if [ $result -eq 0 ]
 then
   echo "Passed"
 else
--- a/test/tools/javac/api/T6838467.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/test/tools/javac/api/T6838467.java	Fri Dec 23 16:39:22 2011 -0800
@@ -32,7 +32,6 @@
 import java.util.zip.*;
 import javax.tools.*;
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.main.OptionName;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Options;
 
--- a/test/tools/javac/diags/examples/UnsupportedEncoding.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/test/tools/javac/diags/examples/UnsupportedEncoding.java	Fri Dec 23 16:39:22 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,5 +23,6 @@
 
 // key: compiler.err.unsupported.encoding
 // options: -encoding UNSUPPORTED -doe
+// run: simple
 
 class UnsupportedEncoding { }
--- a/test/tools/javac/lambda/MethodReferenceParserTest.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/test/tools/javac/lambda/MethodReferenceParserTest.java	Fri Dec 23 16:39:22 2011 -0800
@@ -24,7 +24,6 @@
 /*
  * @test
  * @bug 7115052
- * @ignore 7120266
  * @summary Add parser support for method references
  */
 
@@ -45,6 +44,7 @@
     enum ReferenceKind {
         METHOD_REF("#Q##Gm"),
         CONSTRUCTOR_REF("#Q##Gnew"),
+        FALSE_REF("min < max"),
         ERR_SUPER("#Q##Gsuper"),
         ERR_METH0("#Q##Gm()"),
         ERR_METH1("#Q##Gm(X)"),
@@ -76,6 +76,21 @@
         }
     }
 
+    enum ContextKind {
+        ASSIGN("SAM s = #E;"),
+        METHOD("m(#E, i);");
+
+        String contextTemplate;
+
+        ContextKind(String contextTemplate) {
+            this.contextTemplate = contextTemplate;
+        }
+
+        String contextString(ExprKind ek, ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) {
+            return contextTemplate.replaceAll("#E", ek.expressionString(rk, qk, gk, sk));
+        }
+    }
+
     enum GenericKind {
         NONE(""),
         ONE("<X>"),
@@ -97,7 +112,10 @@
         UBOUND_SIMPLE("A"),
         UNBOUND_GENERIC1("A<X>"),
         UNBOUND_GENERIC2("A<X, Y>"),
-        UNBOUND_GENERIC3("A<? extends X, ? super Y>");
+        UNBOUND_GENERIC3("A<? extends X, ? super Y>"),
+        UNBOUND_GENERIC4("A<int[], short[][]>"),
+        NESTED_GENERIC1("A<A<X,Y>, A<X,Y>>"),
+        NESTED_GENERIC2("A<A<A<X,Y>,A<X,Y>>, A<A<X,Y>,A<X,Y>>>");
 
         String qualifier;
 
@@ -153,7 +171,9 @@
                 for (GenericKind gk : GenericKind.values()) {
                     for (SubExprKind sk : SubExprKind.values()) {
                         for (ExprKind ek : ExprKind.values()) {
-                            new MethodReferenceParserTest(rk, qk, gk, sk, ek).run(comp, fm);
+                            for (ContextKind ck : ContextKind.values()) {
+                                new MethodReferenceParserTest(rk, qk, gk, sk, ek, ck).run(comp, fm);
+                            }
                         }
                     }
                 }
@@ -167,15 +187,17 @@
     GenericKind gk;
     SubExprKind sk;
     ExprKind ek;
+    ContextKind ck;
     JavaSource source;
     DiagnosticChecker diagChecker;
 
-    MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek) {
+    MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek, ContextKind ck) {
         this.rk = rk;
         this.qk = qk;
         this.gk = gk;
         this.sk = sk;
         this.ek = ek;
+        this.ck = ck;
         this.source = new JavaSource();
         this.diagChecker = new DiagnosticChecker();
     }
@@ -183,14 +205,16 @@
     class JavaSource extends SimpleJavaFileObject {
 
         String template = "class Test {\n" +
-                          "   SAM s = #E;\n" +
+                          "   void test() {\n" +
+                          "      #C\n" +
+                          "   }" +
                           "}";
 
         String source;
 
         public JavaSource() {
             super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            source = template.replaceAll("#E", ek.expressionString(rk, qk, gk, sk));
+            source = template.replaceAll("#C", ck.contextString(ek, rk, qk, gk, sk));
         }
 
         @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java	Fri Dec 23 16:39:22 2011 -0800
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6987384
+ * @summary -XprintProcessorRoundsInfo message printed with different timing than previous
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor Test TestWithXstdout
+ * @run main TestWithXstdout
+ */
+
+import java.io.*;
+import java.nio.charset.*;
+import java.nio.file.*;
+import java.util.*;
+
+public class TestWithXstdout {
+    public static void main(String... args) throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File testClasses = new File(System.getProperty("test.classes"));
+        File stdout = new File("stdout.out");
+        run_javac("-XDrawDiagnostics",
+                "-XprintProcessorInfo",
+                "-Werror",
+                "-proc:only",
+                "-processor",  "Test",
+                "-Xstdout", stdout.getPath(),
+                "-classpath", testClasses.getPath(),
+                new File(testSrc, "Test.java").getPath());
+        boolean ok = compare(stdout, new File(testSrc, "Test.out"));
+        if (!ok)
+            throw new Exception("differences found");
+    }
+
+    static void run_javac(String... args) throws IOException, InterruptedException {
+        File javaHome = new File(System.getProperty("java.home"));
+        if (javaHome.getName().equals("jre"))
+            javaHome = javaHome.getParentFile();
+        File javac = new File(new File(javaHome, "bin"), "javac");
+
+        List<String> opts = new ArrayList<>();
+        opts.add(javac.getPath());
+
+        String toolOpts = System.getProperty("test.tool.vm.opts");
+        if (toolOpts != null && !"".equals(toolOpts.trim())) {
+            opts.addAll(Arrays.asList(toolOpts.trim().split("[\\s]+")));
+        }
+        opts.addAll(Arrays.asList(args));
+        System.out.println("exec: " + opts);
+        ProcessBuilder pb = new ProcessBuilder(opts);
+        pb.redirectErrorStream();
+        Process p = pb.start();
+        try (BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
+            String line;
+            while ((line = r.readLine()) != null)
+                System.out.println();
+        }
+        int rc = p.waitFor();
+        if (rc != 0)
+            System.out.println("javac exited, rc=" + rc);
+    }
+
+    static boolean compare(File a, File b) throws IOException {
+        List<String> aLines = Files.readAllLines(a.toPath(), Charset.defaultCharset());
+        List<String> bLines = Files.readAllLines(b.toPath(), Charset.defaultCharset());
+        System.out.println(a + ": " + aLines.size() + " lines");
+        System.out.println(b + ": " + bLines.size() + " lines");
+        return aLines.equals(bLines);
+    }
+}
--- a/test/tools/javac/util/T6597678.java	Thu Dec 22 19:00:58 2011 -0800
+++ b/test/tools/javac/util/T6597678.java	Fri Dec 23 16:39:22 2011 -0800
@@ -41,6 +41,7 @@
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JavacMessages;
+import com.sun.tools.javac.util.Log;
 
 @SupportedOptions("WriterString")
 public class T6597678 extends JavacTestingAbstractProcessor {
@@ -78,7 +79,10 @@
     @Override
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
         Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
-        PrintWriter out = ((JavacProcessingEnvironment) processingEnv).getWriter();
+        Log log = Log.instance(context);
+        PrintWriter noteOut = log.getWriter(Log.WriterKind.NOTICE);
+        PrintWriter warnOut = log.getWriter(Log.WriterKind.WARNING);
+        PrintWriter errOut  = log.getWriter(Log.WriterKind.ERROR);
         Locale locale = context.get(Locale.class);
         JavacMessages messages = context.get(JavacMessages.messagesKey);
 
@@ -86,13 +90,20 @@
         if (round == 1) {
             initialLocale = locale;
             initialMessages = messages;
-            initialWriter = out;
+            initialNoteWriter = noteOut;
+            initialWarnWriter = warnOut;
+            initialErrWriter  = errOut;
 
-            checkEqual("writerString", out.toString().intern(), options.get("WriterString").intern());
+            String writerStringOpt = options.get("WriterString").intern();
+            checkEqual("noteWriterString", noteOut.toString().intern(), writerStringOpt);
+            checkEqual("warnWriterString", warnOut.toString().intern(), writerStringOpt);
+            checkEqual("errWriterString",  errOut.toString().intern(),  writerStringOpt);
         } else {
             checkEqual("locale", locale, initialLocale);
             checkEqual("messages", messages, initialMessages);
-            checkEqual("writer", out, initialWriter);
+            checkEqual("noteWriter", noteOut, initialNoteWriter);
+            checkEqual("warnWriter", warnOut, initialWarnWriter);
+            checkEqual("errWriter",  errOut,  initialErrWriter);
         }
 
         return true;
@@ -109,5 +120,7 @@
     int round = 0;
     Locale initialLocale;
     JavacMessages initialMessages;
-    PrintWriter initialWriter;
+    PrintWriter initialNoteWriter;
+    PrintWriter initialWarnWriter;
+    PrintWriter initialErrWriter;
 }