Merge
authoramurillo
Fri, 19 Aug 2016 12:17:32 -0700
changeset 40687 03446004f80b
parent 40686 1b855fa5c9c5 (current diff)
parent 40469 15567343b987 (diff)
child 40688 566173fd712c
Merge
hotspot/test/runtime/modules/Visibility/XpatchVisibility.java
hotspot/test/runtime/modules/Xpatch/BasicJarBuilder.java
hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java
hotspot/test/runtime/modules/Xpatch/Xpatch2DirsMain.java
hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java
hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java
hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java
hotspot/test/runtime/modules/Xpatch/XpatchMain.java
hotspot/test/runtime/modules/Xpatch/XpatchTest.java
hotspot/test/runtime/modules/Xpatch/XpatchTestJar.java
hotspot/test/runtime/modules/Xpatch/XpatchTestJarDir.java
hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java
hotspot/test/runtime/modules/XpatchCDS.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java
langtools/test/jdk/javadoc/tool/generics/genericClass/Main.java
langtools/test/jdk/javadoc/tool/generics/genericClass/expected.out
langtools/test/jdk/javadoc/tool/generics/genericClass/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java
langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/expected.out
langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/O.java
langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/X.java
langtools/test/jdk/javadoc/tool/generics/genericInterface/Main.java
langtools/test/jdk/javadoc/tool/generics/genericInterface/expected.out
langtools/test/jdk/javadoc/tool/generics/genericInterface/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/genericMethod/Main.java
langtools/test/jdk/javadoc/tool/generics/genericMethod/expected.out
langtools/test/jdk/javadoc/tool/generics/genericMethod/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/genericSuper/Main.java
langtools/test/jdk/javadoc/tool/generics/genericSuper/expected.out
langtools/test/jdk/javadoc/tool/generics/genericSuper/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/supertypes/Main.java
langtools/test/jdk/javadoc/tool/generics/supertypes/expected.out
langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/B.java
langtools/test/jdk/javadoc/tool/generics/throwsGeneric/Main.java
langtools/test/jdk/javadoc/tool/generics/throwsGeneric/expected.out
langtools/test/jdk/javadoc/tool/generics/throwsGeneric/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/tparamCycle/Main.java
langtools/test/jdk/javadoc/tool/generics/tparamCycle/pkg1/LikeEnum.java
langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java
langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/expected.out
langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/Main.java
langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/expected.out
langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/pkg1/A.java
langtools/test/jdk/javadoc/tool/generics/wildcards/Main.java
langtools/test/jdk/javadoc/tool/generics/wildcards/expected.out
langtools/test/jdk/javadoc/tool/generics/wildcards/pkg1/A.java
langtools/test/jdk/javadoc/tool/imports/I.java
langtools/test/jdk/javadoc/tool/imports/MissingImport.java
langtools/test/jdk/javadoc/tool/lib/Tester.java
langtools/test/tools/javac/MethodParameters/Tester.java
langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java
langtools/test/tools/javac/options/modes/Tester.java
langtools/test/tools/javadoc/lib/Tester.java
langtools/test/tools/javap/output/Tester.java
--- a/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -373,3 +373,4 @@
 5bf88dce615f6804f9e101a96ffa7c9dfb4fbbbe jdk-9+128
 e8373543a3f0f60589b7d72b1f9b172721124caf jdk-9+129
 e613affb88d178dc7c589f1679db113d589bddb4 jdk-9+130
+4d2a15091124488080d65848b704e25599b2aaeb jdk-9+131
--- a/.hgtags-top-repo	Fri Aug 19 10:09:53 2016 -0400
+++ b/.hgtags-top-repo	Fri Aug 19 12:17:32 2016 -0700
@@ -373,3 +373,4 @@
 b30ae794d974d7dd3eb4e84203f70021823fa6c6 jdk-9+128
 f5902d3841b82cac6e7716a20c24e8e916fb14a8 jdk-9+129
 d94d54a3192fea79234c3ac55cd0b4052d45e954 jdk-9+130
+8728756c2f70a79a90188f4019cfd6b9a275765c jdk-9+131
--- a/common/autoconf/boot-jdk.m4	Fri Aug 19 10:09:53 2016 -0400
+++ b/common/autoconf/boot-jdk.m4	Fri Aug 19 12:17:32 2016 -0700
@@ -305,7 +305,7 @@
   BOOT_JDK_SOURCETARGET="-source 8 -target 8"
   AC_SUBST(BOOT_JDK_SOURCETARGET)
 
-  ADD_JVM_ARG_IF_OK([-Xpatch:foo=bar], dummy, [$JAVA])
+  ADD_JVM_ARG_IF_OK([--patch-module foo=bar], dummy, [$JAVA])
   AC_MSG_CHECKING([if Boot JDK supports modules])
   if test "x$JVM_ARG_OK" = "xtrue"; then
     AC_MSG_RESULT([yes])
--- a/common/autoconf/generated-configure.sh	Fri Aug 19 10:09:53 2016 -0400
+++ b/common/autoconf/generated-configure.sh	Fri Aug 19 12:17:32 2016 -0700
@@ -5095,7 +5095,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1470415803
+DATE_WHEN_GENERATED=1470863189
 
 ###############################################################################
 #
@@ -30596,13 +30596,13 @@
 
 
 
-  $ECHO "Check if jvm arg is ok: -Xpatch:foo=bar" >&5
-  $ECHO "Command: $JAVA -Xpatch:foo=bar -version" >&5
-  OUTPUT=`$JAVA -Xpatch:foo=bar -version 2>&1`
+  $ECHO "Check if jvm arg is ok: --patch-module foo=bar" >&5
+  $ECHO "Command: $JAVA --patch-module foo=bar -version" >&5
+  OUTPUT=`$JAVA --patch-module foo=bar -version 2>&1`
   FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i warn`
   FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""`
   if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-    dummy="$dummy -Xpatch:foo=bar"
+    dummy="$dummy --patch-module foo=bar"
     JVM_ARG_OK=true
   else
     $ECHO "Arg failed:" >&5
--- a/common/autoconf/spec.gmk.in	Fri Aug 19 10:09:53 2016 -0400
+++ b/common/autoconf/spec.gmk.in	Fri Aug 19 12:17:32 2016 -0700
@@ -585,7 +585,7 @@
     jdk.jdeps jdk.javadoc jdk.rmic
 ifeq ($(BOOT_JDK_MODULAR), true)
   INTERIM_OVERRIDE_MODULES_ARGS = $(foreach m, $(INTERIM_OVERRIDE_MODULES), \
-      -Xpatch:$m=$(BUILDTOOLS_OUTPUTDIR)/override_modules/$m)
+      --patch-module $m=$(BUILDTOOLS_OUTPUTDIR)/override_modules/$m)
   INTERIM_LANGTOOLS_ARGS = $(INTERIM_OVERRIDE_MODULES_ARGS)
   JAVAC_MAIN_CLASS = -m jdk.compiler/com.sun.tools.javac.Main
   JAVADOC_MAIN_CLASS = -m jdk.javadoc/jdk.javadoc.internal.tool.Main
--- a/common/conf/jib-profiles.js	Fri Aug 19 10:09:53 2016 -0400
+++ b/common/conf/jib-profiles.js	Fri Aug 19 12:17:32 2016 -0700
@@ -417,7 +417,7 @@
         jtreg: {
             server: "javare",
             revision: "4.2",
-            build_number: "b02",
+            build_number: "b03",
             checksum_file: "MD5_VALUES",
             file: "jtreg_bin-4.2.zip",
             environment_name: "JT_HOME"
--- a/corba/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/corba/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -373,3 +373,4 @@
 1f093d3f8cd99cd37c3b0af4cf5c3bffaa9c8b98 jdk-9+128
 c3e83ccab3bb1733ae903d681879a33f85ed465c jdk-9+129
 77f9692d5976ae155773dd3e07533616bb95bae1 jdk-9+130
+f7e1d5337c2e550fe553df7a3886bbed80292ecd jdk-9+131
--- a/hotspot/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -533,3 +533,4 @@
 22bf6db9767b1b3a1994cbf32eb3331f31ae2093 jdk-9+128
 e96b34b76d863ed1fa04e0eeb3f297ac17b490fd jdk-9+129
 7d54c7056328b6a2bf4877458b8f4d8cd870f93b jdk-9+130
+943bf73b49c33c2d7cbd796f6a4ae3c7a00ae932 jdk-9+131
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java	Fri Aug 19 12:17:32 2016 -0700
@@ -109,6 +109,9 @@
             if (!s.getReturnType(CLASS).equals(resultType)) {
                 return false;
             }
+            if (s.getParameterCount(false) != parameterTypes.length) {
+                return false;
+            }
             for (int i = 0; i < s.getParameterCount(false); ++i) {
                 if (!s.getParameterType(i, CLASS).equals(parameterTypes[i])) {
                     return false;
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/Services.java	Fri Aug 19 12:17:32 2016 -0700
@@ -57,7 +57,7 @@
         if (jvmci != requestorModule) {
             for (String pkg : jvmci.getPackages()) {
                 // Export all JVMCI packages dynamically instead
-                // of requiring a long list of -XaddExports
+                // of requiring a long list of --add-exports
                 // options on the JVM command line.
                 if (!jvmci.isExported(pkg, requestorModule)) {
                     jvmci.addExports(pkg, requestorModule);
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Fri Aug 19 12:17:32 2016 -0700
@@ -140,7 +140,7 @@
 PerfCounter*    ClassLoader::_isUnsyncloadClass = NULL;
 PerfCounter*    ClassLoader::_load_instance_class_failCounter = NULL;
 
-GrowableArray<ModuleClassPathList*>* ClassLoader::_xpatch_entries = NULL;
+GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL;
 GrowableArray<ModuleClassPathList*>* ClassLoader::_exploded_entries = NULL;
 ClassPathEntry* ClassLoader::_jrt_entry = NULL;
 ClassPathEntry* ClassLoader::_first_append_entry = NULL;
@@ -685,27 +685,27 @@
 }
 #endif
 
-// Construct the array of module/path pairs as specified to -Xpatch
+// Construct the array of module/path pairs as specified to --patch-module
 // for the boot loader to search ahead of the jimage, if the class being
-// loaded is defined to a module that has been specified to -Xpatch.
-void ClassLoader::setup_xpatch_entries() {
+// loaded is defined to a module that has been specified to --patch-module.
+void ClassLoader::setup_patch_mod_entries() {
   Thread* THREAD = Thread::current();
-  GrowableArray<ModuleXPatchPath*>* xpatch_args = Arguments::get_xpatchprefix();
-  int num_of_entries = xpatch_args->length();
+  GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
+  int num_of_entries = patch_mod_args->length();
 
-  assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with -Xpatch");
-  assert(!UseSharedSpaces, "UseSharedSpaces not supported with -Xpatch");
+  assert(!DumpSharedSpaces, "DumpSharedSpaces not supported with --patch-module");
+  assert(!UseSharedSpaces, "UseSharedSpaces not supported with --patch-module");
 
-  // Set up the boot loader's _xpatch_entries list
-  _xpatch_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
+  // Set up the boot loader's _patch_mod_entries list
+  _patch_mod_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
 
   for (int i = 0; i < num_of_entries; i++) {
-    const char* module_name = (xpatch_args->at(i))->module_name();
+    const char* module_name = (patch_mod_args->at(i))->module_name();
     Symbol* const module_sym = SymbolTable::lookup(module_name, (int)strlen(module_name), CHECK);
     assert(module_sym != NULL, "Failed to obtain Symbol for module name");
     ModuleClassPathList* module_cpl = new ModuleClassPathList(module_sym);
 
-    char* class_path = (xpatch_args->at(i))->path_string();
+    char* class_path = (patch_mod_args->at(i))->path_string();
     int len = (int)strlen(class_path);
     int end = 0;
     // Iterate over the module's class path entries
@@ -735,10 +735,10 @@
       }
     }
 
-    // Record the module into the list of -Xpatch entries only if
+    // Record the module into the list of --patch-module entries only if
     // valid ClassPathEntrys have been created
     if (module_cpl->module_first_entry() != NULL) {
-      _xpatch_entries->push(module_cpl);
+      _patch_mod_entries->push(module_cpl);
     }
   }
 }
@@ -1020,9 +1020,9 @@
   ClassPathEntry* e;
   tty->print("[bootclasspath= ");
 
-  // Print -Xpatch module/path specifications first
-  if (_xpatch_entries != NULL) {
-    print_module_entry_table(_xpatch_entries);
+  // Print --patch-module module/path specifications first
+  if (_patch_mod_entries != NULL) {
+    print_module_entry_table(_patch_mod_entries);
   }
 
   // [jimage | exploded modules build]
@@ -1341,7 +1341,7 @@
   return file_name;
 }
 
-// Search either the xpatch or exploded build entries for class
+// Search either the patch-module or exploded build entries for class
 ClassFileStream* ClassLoader::search_module_entries(const GrowableArray<ModuleClassPathList*>* const module_list,
                                                     const char* const class_name, const char* const file_name, TRAPS) {
   ClassFileStream* stream = NULL;
@@ -1366,7 +1366,7 @@
     int num_of_entries = module_list->length();
     const Symbol* class_module_name = mod_entry->name();
 
-    // Loop through all the modules in either the xpatch or exploded entries looking for module
+    // Loop through all the modules in either the patch-module or exploded entries looking for module
     for (int i = 0; i < num_of_entries; i++) {
       ModuleClassPathList* module_cpl = module_list->at(i);
       Symbol* module_cpl_name = module_cpl->module_name();
@@ -1378,7 +1378,7 @@
         while (e != NULL) {
           stream = e->open_stream(file_name, CHECK_NULL);
           // No context.check is required since CDS is not supported
-          // for an exploded modules build or if -Xpatch is specified.
+          // for an exploded modules build or if --patch-module is specified.
           if (NULL != stream) {
             return stream;
           }
@@ -1420,32 +1420,32 @@
 
   // If DumpSharedSpaces is true boot loader visibility boundaries are set to:
   //   - [jimage] + [_first_append_entry to _last_append_entry] (all path entries).
-  // No -Xpatch entries or exploded module builds are included since CDS
-  // is not supported if -Xpatch or exploded module builds are used.
+  // No --patch-module entries or exploded module builds are included since CDS
+  // is not supported if --patch-module or exploded module builds are used.
   //
   // If search_append_only is true, boot loader visibility boundaries are
   // set to be _first_append_entry to the end. This includes:
   //   [-Xbootclasspath/a]; [jvmti appended entries]
   //
   // If both DumpSharedSpaces and search_append_only are false, boot loader
-  // visibility boundaries are set to be the -Xpatch entries plus the base piece.
+  // visibility boundaries are set to be the --patch-module entries plus the base piece.
   // This would include:
-  //   [-Xpatch:<module>=<file>(<pathsep><file>)*]; [jimage | exploded module build]
+  //   [--patch-module=<module>=<file>(<pathsep><file>)*]; [jimage | exploded module build]
   //
   // DumpSharedSpaces and search_append_only are mutually exclusive and cannot
   // be true at the same time.
   assert(!(DumpSharedSpaces && search_append_only), "DumpSharedSpaces and search_append_only are both true");
 
-  // Load Attempt #1: -Xpatch
-  // Determine the class' defining module.  If it appears in the _xpatch_entries,
+  // Load Attempt #1: --patch-module
+  // Determine the class' defining module.  If it appears in the _patch_mod_entries,
   // attempt to load the class from those locations specific to the module.
-  // Specifications to -Xpatch can contain a partial number of classes
+  // Specifications to --patch-module can contain a partial number of classes
   // that are part of the overall module definition.  So if a particular class is not
   // found within its module specification, the search should continue to Load Attempt #2.
-  // Note: The -Xpatch entries are never searched if the boot loader's
+  // Note: The --patch-module entries are never searched if the boot loader's
   //       visibility boundary is limited to only searching the append entries.
-  if (_xpatch_entries != NULL && !search_append_only && !DumpSharedSpaces) {
-    stream = search_module_entries(_xpatch_entries, class_name, file_name, CHECK_NULL);
+  if (_patch_mod_entries != NULL && !search_append_only && !DumpSharedSpaces) {
+    stream = search_module_entries(_patch_mod_entries, class_name, file_name, CHECK_NULL);
   }
 
   // Load Attempt #2: [jimage | exploded build]
@@ -1650,11 +1650,11 @@
   // Create the moduleEntry for java.base
   create_javabase();
 
-  // Setup the list of module/path pairs for -Xpatch processing
+  // Setup the list of module/path pairs for --patch-module processing
   // This must be done after the SymbolTable is created in order
   // to use fast_compare on module names instead of a string compare.
-  if (Arguments::get_xpatchprefix() != NULL) {
-    setup_xpatch_entries();
+  if (Arguments::get_patch_mod_prefix() != NULL) {
+    setup_patch_mod_entries();
   }
 
   // Setup the initial java.base/path pair for the exploded build entries.
--- a/hotspot/src/share/vm/classfile/classLoader.hpp	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/share/vm/classfile/classLoader.hpp	Fri Aug 19 12:17:32 2016 -0700
@@ -150,7 +150,7 @@
 
 // ModuleClassPathList contains a linked list of ClassPathEntry's
 // that have been specified for a specific module.  Currently,
-// the only way to specify a module/path pair is via the -Xpatch
+// the only way to specify a module/path pair is via the --patch-module
 // command line option.
 class ModuleClassPathList : public CHeapObj<mtClass> {
 private:
@@ -213,8 +213,8 @@
   static PerfCounter* _load_instance_class_failCounter;
 
   // The boot class path consists of 3 ordered pieces:
-  //  1. the module/path pairs specified to -Xpatch
-  //    -Xpatch:<module>=<file>(<pathsep><file>)*
+  //  1. the module/path pairs specified to --patch-module
+  //    --patch-module=<module>=<file>(<pathsep><file>)*
   //  2. the base piece
   //    [jimage | build with exploded modules]
   //  3. boot loader append path
@@ -223,8 +223,8 @@
   // The boot loader must obey this order when attempting
   // to load a class.
 
-  // 1. Contains the module/path pairs specified to -Xpatch
-  static GrowableArray<ModuleClassPathList*>* _xpatch_entries;
+  // 1. Contains the module/path pairs specified to --patch-module
+  static GrowableArray<ModuleClassPathList*>* _patch_mod_entries;
 
   // 2. the base piece
   //    Contains the ClassPathEntry of the modular java runtime image.
@@ -256,11 +256,11 @@
 
   // Initialization:
   //   - setup the boot loader's system class path
-  //   - setup the boot loader's xpatch entries, if present
+  //   - setup the boot loader's patch mod entries, if present
   //   - create the ModuleEntry for java.base
   static void setup_bootstrap_search_path();
   static void setup_search_path(const char *class_path, bool setting_bootstrap);
-  static void setup_xpatch_entries();
+  static void setup_patch_mod_entries();
   static void create_javabase();
 
   static void load_zip_library();
@@ -363,7 +363,7 @@
   // Add a module's exploded directory to the boot loader's exploded module build list
   static void add_to_exploded_build_list(Symbol* module_name, TRAPS);
 
-  // Attempt load of individual class from either the xpatch or exploded modules build lists
+  // Attempt load of individual class from either the patched or exploded modules build lists
   static ClassFileStream* search_module_entries(const GrowableArray<ModuleClassPathList*>* const module_list,
                                                 const char* const class_name,
                                                 const char* const file_name, TRAPS);
--- a/hotspot/src/share/vm/memory/filemap.cpp	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/share/vm/memory/filemap.cpp	Fri Aug 19 12:17:32 2016 -0700
@@ -911,8 +911,8 @@
     return false;
   }
 
-  if (Arguments::get_xpatchprefix() != NULL) {
-    FileMapInfo::fail_continue("The shared archive file cannot be used with -Xpatch.");
+  if (Arguments::get_patch_mod_prefix() != NULL) {
+    FileMapInfo::fail_continue("The shared archive file cannot be used with --patch-module.");
     return false;
   }
 
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Fri Aug 19 12:17:32 2016 -0700
@@ -24,6 +24,8 @@
 
 #include "precompiled.hpp"
 #include "classfile/classLoaderExt.hpp"
+#include "classfile/javaClasses.inline.hpp"
+#include "classfile/stringTable.hpp"
 #include "classfile/modules.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -224,6 +226,7 @@
   return JVMTI_ERROR_NONE;
 } /* end GetNamedModule */
 
+
   //
   // Class functions
   //
@@ -3465,28 +3468,35 @@
 JvmtiEnv::GetSystemProperties(jint* count_ptr, char*** property_ptr) {
   jvmtiError err = JVMTI_ERROR_NONE;
 
-  *count_ptr = Arguments::PropertyList_count(Arguments::system_properties());
-
+  // Get the number of readable properties.
+  *count_ptr = Arguments::PropertyList_readable_count(Arguments::system_properties());
+
+  // Allocate memory to hold the exact number of readable properties.
   err = allocate(*count_ptr * sizeof(char *), (unsigned char **)property_ptr);
   if (err != JVMTI_ERROR_NONE) {
     return err;
   }
-  int i = 0 ;
-  for (SystemProperty* p = Arguments::system_properties(); p != NULL && i < *count_ptr; p = p->next(), i++) {
-    const char *key = p->key();
-    char **tmp_value = *property_ptr+i;
-    err = allocate((strlen(key)+1) * sizeof(char), (unsigned char**)tmp_value);
-    if (err == JVMTI_ERROR_NONE) {
-      strcpy(*tmp_value, key);
-    } else {
-      // clean up previously allocated memory.
-      for (int j=0; j<i; j++) {
-        Deallocate((unsigned char*)*property_ptr+j);
+  int readable_count = 0;
+  // Loop through the system properties until all the readable properties are found.
+  for (SystemProperty* p = Arguments::system_properties(); p != NULL && readable_count < *count_ptr; p = p->next()) {
+    if (p->is_readable()) {
+      const char *key = p->key();
+      char **tmp_value = *property_ptr+readable_count;
+      readable_count++;
+      err = allocate((strlen(key)+1) * sizeof(char), (unsigned char**)tmp_value);
+      if (err == JVMTI_ERROR_NONE) {
+        strcpy(*tmp_value, key);
+      } else {
+        // clean up previously allocated memory.
+        for (int j=0; j<readable_count; j++) {
+          Deallocate((unsigned char*)*property_ptr+j);
+        }
+        Deallocate((unsigned char*)property_ptr);
+        break;
       }
-      Deallocate((unsigned char*)property_ptr);
-      break;
     }
   }
+  assert(err != JVMTI_ERROR_NONE || readable_count == *count_ptr, "Bad readable property count");
   return err;
 } /* end GetSystemProperties */
 
@@ -3498,7 +3508,8 @@
   jvmtiError err = JVMTI_ERROR_NONE;
   const char *value;
 
-  value = Arguments::PropertyList_get_value(Arguments::system_properties(), property);
+  // Return JVMTI_ERROR_NOT_AVAILABLE if property is not readable or doesn't exist.
+  value = Arguments::PropertyList_get_readable_value(Arguments::system_properties(), property);
   if (value == NULL) {
     err =  JVMTI_ERROR_NOT_AVAILABLE;
   } else {
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Fri Aug 19 12:17:32 2016 -0700
@@ -110,7 +110,7 @@
 SystemProperty *Arguments::_java_class_path = NULL;
 SystemProperty *Arguments::_jdk_boot_class_path_append = NULL;
 
-GrowableArray<ModuleXPatchPath*> *Arguments::_xpatchprefix = NULL;
+GrowableArray<ModulePatchPath*> *Arguments::_patch_mod_prefix = NULL;
 PathString *Arguments::_system_boot_class_path = NULL;
 bool Arguments::_has_jimage = false;
 
@@ -161,6 +161,30 @@
   }
 }
 
+bool needs_module_property_warning = false;
+
+#define MODULE_PROPERTY_PREFIX "jdk.module"
+#define MODULE_PROPERTY_PREFIX_LEN 10
+#define MODULE_MAIN_PROPERTY "jdk.module.main"
+#define MODULE_MAIN_PROPERTY_LEN 15
+
+// Return TRUE if option matches property, or property=, or property..
+static bool matches_property_prefix(const char* option, const char* property, size_t len) {
+  return (strncmp(option, property, len) == 0) &&
+          (option[len] == '=' || option[len] == '.' || option[len] == '\0');
+}
+
+// Return true if the property is either "jdk.module" or starts with "jdk.module.",
+// but does not start with "jdk.module.main".
+// Return false if jdk.module.main because jdk.module.main and jdk.module.main.class
+// are valid non-internal system properties.
+// "property" should be passed without the leading "-D".
+bool Arguments::is_internal_module_property(const char* property) {
+  assert((strncmp(property, "-D", 2) != 0), "Unexpected leading -D");
+  return (matches_property_prefix(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) &&
+          !matches_property_prefix(property, MODULE_MAIN_PROPERTY, MODULE_MAIN_PROPERTY_LEN));
+}
+
 // Process java launcher properties.
 void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
   // See if sun.java.launcher, sun.java.launcher.is_altjvm or
@@ -197,7 +221,7 @@
   _system_boot_class_path = new PathString(NULL);
 
   PropertyList_add(&_system_properties, new SystemProperty("java.vm.specification.name",
-                                                                 "Java Virtual Machine Specification",  false));
+                                                           "Java Virtual Machine Specification",  false));
   PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(),  false));
   PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(),  false));
   PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(),  true));
@@ -1198,7 +1222,7 @@
   return PropertyList_get_value(system_properties(), key);
 }
 
-bool Arguments::add_property(const char* prop) {
+bool Arguments::add_property(const char* prop, PropertyWriteable writeable, PropertyInternal internal) {
   const char* eq = strchr(prop, '=');
   const char* key;
   const char* value = "";
@@ -1228,7 +1252,9 @@
     // private and are processed in process_sun_java_launcher_properties();
     // the sun.java.launcher property is passed on to the java application
   } else if (strcmp(key, "sun.boot.library.path") == 0) {
-    PropertyList_unique_add(&_system_properties, key, value, true);
+    // append is true, writable is true, internal is false
+    PropertyList_unique_add(&_system_properties, key, value, AppendProperty,
+                            WriteableProperty, ExternalProperty);
   } else {
     if (strcmp(key, "sun.java.command") == 0) {
       char *old_java_command = _java_command;
@@ -1248,7 +1274,7 @@
     }
 
     // Create new property and add at the end of the list
-    PropertyList_unique_add(&_system_properties, key, value);
+    PropertyList_unique_add(&_system_properties, key, value, AddProperty, writeable, internal);
   }
 
   if (key != prop) {
@@ -1260,9 +1286,9 @@
   return true;
 }
 
-// sets or adds a module name to the jdk.launcher.addmods property
+// sets or adds a module name to the jdk.module.addmods property
 bool Arguments::append_to_addmods_property(const char* module_name) {
-  const char* key = "jdk.launcher.addmods";
+  const char* key = "jdk.module.addmods";
   const char* old_value = Arguments::get_property(key);
   size_t buf_len = strlen(key) + strlen(module_name) + 2;
   if (old_value != NULL) {
@@ -1277,7 +1303,7 @@
   } else {
     jio_snprintf(new_value, buf_len, "%s=%s,%s", key, old_value, module_name);
   }
-  bool added = add_property(new_value);
+  bool added = add_property(new_value, UnwriteableProperty, InternalProperty);
   FreeHeap(new_value);
   return added;
 }
@@ -1287,14 +1313,14 @@
   assert(DumpSharedSpaces, "this function is only used with -Xshare:dump");
   const char* unsupported_properties[5] = { "jdk.module.main",
                                            "jdk.module.path",
-                                           "jdk.upgrade.module.path",
-                                           "jdk.launcher.addmods",
-                                           "jdk.launcher.limitmods" };
+                                           "jdk.module.upgrade.path",
+                                           "jdk.module.addmods",
+                                           "jdk.module.limitmods" };
   const char* unsupported_options[5] = { "-m",
-                                        "-modulepath",
-                                        "-upgrademodulepath",
-                                        "-addmods",
-                                        "-limitmods" };
+                                        "--module-path",
+                                        "--upgrade-module-path",
+                                        "--add-modules",
+                                        "--limit-modules" };
   SystemProperty* sp = system_properties();
   while (sp != NULL) {
     for (int i = 0; i < 5; i++) {
@@ -1326,7 +1352,7 @@
   // Ensure Agent_OnLoad has the correct initial values.
   // This may not be the final mode; mode may change later in onload phase.
   PropertyList_unique_add(&_system_properties, "java.vm.info",
-                          VM_Version::vm_info_string(), false);
+                          VM_Version::vm_info_string(), AddProperty, UnwriteableProperty, ExternalProperty);
 
   UseInterpreter             = true;
   UseCompiler                = true;
@@ -2516,6 +2542,41 @@
   return false;
 }
 
+unsigned int addreads_count = 0;
+unsigned int addexports_count = 0;
+unsigned int patch_mod_count = 0;
+const char* add_modules_value = NULL;
+
+bool Arguments::create_property(const char* prop_name, const char* prop_value, PropertyInternal internal) {
+  size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2;
+  char* property = AllocateHeap(prop_len, mtArguments);
+  int ret = jio_snprintf(property, prop_len, "%s=%s", prop_name, prop_value);
+  if (ret < 0 || ret >= (int)prop_len) {
+    FreeHeap(property);
+    return false;
+  }
+  bool added = add_property(property, UnwriteableProperty, internal);
+  FreeHeap(property);
+  return added;
+}
+
+bool Arguments::create_numbered_property(const char* prop_base_name, const char* prop_value, unsigned int count) {
+  // Make sure count is < 1,000. Otherwise, memory allocation will be too small.
+  if (count < 1000) {
+    size_t prop_len = strlen(prop_base_name) + strlen(prop_value) + 5;
+    char* property = AllocateHeap(prop_len, mtArguments);
+    int ret = jio_snprintf(property, prop_len, "%s.%d=%s", prop_base_name, count, prop_value);
+    if (ret < 0 || ret >= (int)prop_len) {
+      FreeHeap(property);
+      return false;
+    }
+    bool added = add_property(property, UnwriteableProperty, InternalProperty);
+    FreeHeap(property);
+    return added;
+  }
+  return false;
+}
+
 Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
                                                   julong* long_arg,
                                                   julong min_size) {
@@ -2528,7 +2589,7 @@
 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
                                    const JavaVMInitArgs *java_options_args,
                                    const JavaVMInitArgs *cmd_line_args) {
-  bool xpatch_javabase = false;
+  bool patch_mod_javabase = false;
 
   // Save default settings for some mode flags
   Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
@@ -2545,20 +2606,20 @@
 
   // Parse args structure generated from JAVA_TOOL_OPTIONS environment
   // variable (if present).
-  jint result = parse_each_vm_init_arg(java_tool_options_args, &xpatch_javabase, Flag::ENVIRON_VAR);
+  jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR);
   if (result != JNI_OK) {
     return result;
   }
 
   // Parse args structure generated from the command line flags.
-  result = parse_each_vm_init_arg(cmd_line_args, &xpatch_javabase, Flag::COMMAND_LINE);
+  result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, Flag::COMMAND_LINE);
   if (result != JNI_OK) {
     return result;
   }
 
   // Parse args structure generated from the _JAVA_OPTIONS environment
   // variable (if present) (mimics classic VM)
-  result = parse_each_vm_init_arg(java_options_args, &xpatch_javabase, Flag::ENVIRON_VAR);
+  result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR);
   if (result != JNI_OK) {
     return result;
   }
@@ -2617,7 +2678,35 @@
   return false;
 }
 
-jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_javabase, Flag::Flags origin) {
+int Arguments::process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase) {
+  // --patch-module=<module>=<file>(<pathsep><file>)*
+  assert(patch_mod_tail != NULL, "Unexpected NULL patch-module value");
+  // Find the equal sign between the module name and the path specification
+  const char* module_equal = strchr(patch_mod_tail, '=');
+  if (module_equal == NULL) {
+    jio_fprintf(defaultStream::output_stream(), "Missing '=' in --patch-module specification\n");
+    return JNI_ERR;
+  } else {
+    // Pick out the module name
+    size_t module_len = module_equal - patch_mod_tail;
+    char* module_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, module_len+1, mtArguments);
+    if (module_name != NULL) {
+      memcpy(module_name, patch_mod_tail, module_len);
+      *(module_name + module_len) = '\0';
+      // The path piece begins one past the module_equal sign
+      add_patch_mod_prefix(module_name, module_equal + 1, patch_mod_javabase);
+      FREE_C_HEAP_ARRAY(char, module_name);
+      if (!create_numbered_property("jdk.module.patch", patch_mod_tail, patch_mod_count++)) {
+        return JNI_ENOMEM;
+      }
+    } else {
+      return JNI_ENOMEM;
+    }
+  }
+  return JNI_OK;
+}
+
+jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin) {
   // For match_option to return remaining or value part of option string
   const char* tail;
 
@@ -2701,6 +2790,34 @@
 #endif // !INCLUDE_JVMTI
         add_init_library(name, options);
       }
+    } else if (match_option(option, "--add-reads=", &tail)) {
+      if (!create_numbered_property("jdk.module.addreads", tail, addreads_count++)) {
+        return JNI_ENOMEM;
+      }
+    } else if (match_option(option, "--add-exports=", &tail)) {
+      if (!create_numbered_property("jdk.module.addexports", tail, addexports_count++)) {
+        return JNI_ENOMEM;
+      }
+    } else if (match_option(option, "--add-modules=", &tail)) {
+      add_modules_value = tail;
+    } else if (match_option(option, "--limit-modules=", &tail)) {
+      if (!create_property("jdk.module.limitmods", tail, InternalProperty)) {
+        return JNI_ENOMEM;
+      }
+    } else if (match_option(option, "--module-path=", &tail)) {
+      if (!create_property("jdk.module.path", tail, ExternalProperty)) {
+        return JNI_ENOMEM;
+      }
+    } else if (match_option(option, "--upgrade-module-path=", &tail)) {
+      if (!create_property("jdk.module.upgrade.path", tail, ExternalProperty)) {
+        return JNI_ENOMEM;
+      }
+    } else if (match_option(option, "--patch-module=", &tail)) {
+      // --patch-module=<module>=<file>(<pathsep><file>)*
+      int res = process_patch_mod_option(tail, patch_mod_javabase);
+      if (res != JNI_OK) {
+        return res;
+      }
     // -agentlib and -agentpath
     } else if (match_option(option, "-agentlib:", &tail) ||
           (is_absolute_path = match_option(option, "-agentpath:", &tail))) {
@@ -2992,6 +3109,13 @@
           "-Djava.ext.dirs=%s is not supported.  Use -classpath instead.\n", value);
         return JNI_EINVAL;
       }
+      // Check for module related properties.  They must be set using the modules
+      // options. For example: use "--add-modules=java.sql", not
+      // "-Djdk.module.addmods=java.sql"
+      if (is_internal_module_property(option->optionString + 2)) {
+        needs_module_property_warning = true;
+        continue;
+      }
 
       if (!add_property(tail)) {
         return JNI_ENOMEM;
@@ -3012,33 +3136,6 @@
         return JNI_ERR;
 #endif
       }
-      if (match_option(option, "-Djdk.launcher.patch.", &tail)) {
-        // -Djdk.launcher.patch.#=<module>=<file>(<pathsep><file>)*
-        // The number, #, specified will be increasing with each -Xpatch
-        // specified on the command line.
-        // Pick up module name, following the -D property's equal sign.
-        const char* property_equal = strchr(tail, '=');
-        if (property_equal == NULL) {
-          jio_fprintf(defaultStream::output_stream(), "Missing '=' in -Xpatch specification\n");
-          return JNI_ERR;
-        } else {
-          // Find the equal sign between the module name and the path specification
-          const char* module_equal = strchr(property_equal + 1, '=');
-          if (module_equal == NULL) {
-            jio_fprintf(defaultStream::output_stream(), "Bad value for -Xpatch, no module name specified\n");
-            return JNI_ERR;
-          } else {
-            // Pick out the module name, in between the two equal signs
-            size_t module_len = module_equal - property_equal - 1;
-            char* module_name = NEW_C_HEAP_ARRAY(char, module_len+1, mtArguments);
-            memcpy(module_name, property_equal + 1, module_len);
-            *(module_name + module_len) = '\0';
-            // The path piece begins one past the module_equal sign
-            Arguments::add_xpatchprefix(module_name, module_equal + 1, xpatch_javabase);
-            FREE_C_HEAP_ARRAY(char, module_name);
-          }
-        }
-      }
     // -Xint
     } else if (match_option(option, "-Xint")) {
           set_mode_flags(_int);
@@ -3298,25 +3395,25 @@
   return JNI_OK;
 }
 
-void Arguments::add_xpatchprefix(const char* module_name, const char* path, bool* xpatch_javabase) {
-  // For java.base check for duplicate -Xpatch options being specified on the command line.
+void Arguments::add_patch_mod_prefix(const char* module_name, const char* path, bool* patch_mod_javabase) {
+  // For java.base check for duplicate --patch-module options being specified on the command line.
   // This check is only required for java.base, all other duplicate module specifications
   // will be checked during module system initialization.  The module system initialization
   // will throw an ExceptionInInitializerError if this situation occurs.
   if (strcmp(module_name, "java.base") == 0) {
-    if (*xpatch_javabase) {
-      vm_exit_during_initialization("Cannot specify java.base more than once to -Xpatch");
+    if (*patch_mod_javabase) {
+      vm_exit_during_initialization("Cannot specify java.base more than once to --patch-module");
     } else {
-      *xpatch_javabase = true;
+      *patch_mod_javabase = true;
     }
   }
 
-  // Create GrowableArray lazily, only if -Xpatch has been specified
-  if (_xpatchprefix == NULL) {
-    _xpatchprefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<ModuleXPatchPath*>(10, true);
-  }
-
-  _xpatchprefix->push(new ModuleXPatchPath(module_name, path));
+  // Create GrowableArray lazily, only if --patch-module has been specified
+  if (_patch_mod_prefix == NULL) {
+    _patch_mod_prefix = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<ModulePatchPath*>(10, true);
+  }
+
+  _patch_mod_prefix->push(new ModulePatchPath(module_name, path));
 }
 
 // Remove all empty paths from the app classpath (if IgnoreEmptyClassPaths is enabled)
@@ -3441,6 +3538,15 @@
     return JNI_ERR;
   }
 
+  // Append the value of the last --add-modules option specified on the command line.
+  // This needs to be done here, to prevent overwriting possible values written
+  // to the jdk.module.addmods property by -javaagent and other options.
+  if (add_modules_value != NULL) {
+    if (!append_to_addmods_property(add_modules_value)) {
+      return JNI_ENOMEM;
+    }
+  }
+
   // This must be done after all arguments have been processed.
   // java_compiler() true means set to "NONE" or empty.
   if (java_compiler() && !xdebug_mode()) {
@@ -3795,9 +3901,9 @@
 
 void Arguments::set_shared_spaces_flags() {
   if (DumpSharedSpaces) {
-    if (Arguments::get_xpatchprefix() != NULL) {
+    if (Arguments::get_patch_mod_prefix() != NULL) {
       vm_exit_during_initialization(
-        "Cannot use the following option when dumping the shared archive", "-Xpatch");
+        "Cannot use the following option when dumping the shared archive: --patch-module");
     }
 
     if (RequireSharedSpaces) {
@@ -4180,6 +4286,11 @@
             hotspotrc, hotspotrc);
   }
 
+  if (needs_module_property_warning) {
+    warning("Ignoring system property options whose names start with '-Djdk.module'."
+            "  They are reserved for internal use.");
+  }
+
 #if defined(_ALLBSD_SOURCE) || defined(AIX)  // UseLargePages is not yet supported on BSD and AIX.
   UNSUPPORTED_OPTION(UseLargePages);
 #endif
@@ -4404,6 +4515,18 @@
   return count;
 }
 
+// Return the number of readable properties.
+int Arguments::PropertyList_readable_count(SystemProperty* pl) {
+  int count = 0;
+  while(pl != NULL) {
+    if (pl->is_readable()) {
+      count++;
+    }
+    pl = pl->next();
+  }
+  return count;
+}
+
 const char* Arguments::PropertyList_get_value(SystemProperty *pl, const char* key) {
   assert(key != NULL, "just checking");
   SystemProperty* prop;
@@ -4413,6 +4536,27 @@
   return NULL;
 }
 
+// Return the value of the requested property provided that it is a readable property.
+const char* Arguments::PropertyList_get_readable_value(SystemProperty *pl, const char* key) {
+  assert(key != NULL, "just checking");
+  SystemProperty* prop;
+  // Return the property value if the keys match and the property is not internal or
+  // it's the special internal property "jdk.boot.class.path.append".
+  for (prop = pl; prop != NULL; prop = prop->next()) {
+    if (strcmp(key, prop->key()) == 0) {
+      if (!prop->internal()) {
+        return prop->value();
+      } else if (strcmp(key, "jdk.boot.class.path.append") == 0) {
+        return prop->value();
+      } else {
+        // Property is internal and not jdk.boot.class.path.append so return NULL.
+        return NULL;
+      }
+    }
+  }
+  return NULL;
+}
+
 const char* Arguments::PropertyList_get_key_at(SystemProperty *pl, int index) {
   int count = 0;
   const char* ret_val = NULL;
@@ -4457,11 +4601,12 @@
   }
 }
 
-void Arguments::PropertyList_add(SystemProperty** plist, const char* k, const char* v) {
+void Arguments::PropertyList_add(SystemProperty** plist, const char* k, const char* v,
+                                 bool writeable, bool internal) {
   if (plist == NULL)
     return;
 
-  SystemProperty* new_p = new SystemProperty(k, v, true);
+  SystemProperty* new_p = new SystemProperty(k, v, writeable, internal);
   PropertyList_add(plist, new_p);
 }
 
@@ -4470,7 +4615,9 @@
 }
 
 // This add maintains unique property key in the list.
-void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, jboolean append) {
+void Arguments::PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
+                                        PropertyAppendable append, PropertyWriteable writeable,
+                                        PropertyInternal internal) {
   if (plist == NULL)
     return;
 
@@ -4478,16 +4625,16 @@
   SystemProperty* prop;
   for (prop = *plist; prop != NULL; prop = prop->next()) {
     if (strcmp(k, prop->key()) == 0) {
-      if (append) {
+      if (append == AppendProperty) {
         prop->append_value(v);
       } else {
-        prop->set_writeable_value(v);
+        prop->set_value(v);
       }
       return;
     }
   }
 
-  PropertyList_add(plist, k, v);
+  PropertyList_add(plist, k, v, writeable == WriteableProperty, internal == InternalProperty);
 }
 
 // Copies src into buf, replacing "%%" with "%" and "%p" with pid
--- a/hotspot/src/share/vm/runtime/arguments.hpp	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.hpp	Fri Aug 19 12:17:32 2016 -0700
@@ -43,7 +43,7 @@
 
 // PathString is used as:
 //  - the underlying value for a SystemProperty
-//  - the path portion of an -Xpatch module/path pair
+//  - the path portion of an --patch-module module/path pair
 //  - the string that represents the system boot class path, Arguments::_system_boot_class_path.
 class PathString : public CHeapObj<mtArguments> {
  protected:
@@ -107,13 +107,13 @@
   }
 };
 
-// ModuleXPatchPath records the module/path pair as specified to -Xpatch.
-class ModuleXPatchPath : public CHeapObj<mtInternal> {
+// ModulePatchPath records the module/path pair as specified to --patch-module.
+class ModulePatchPath : public CHeapObj<mtInternal> {
 private:
   char* _module_name;
   PathString* _path;
 public:
-  ModuleXPatchPath(const char* module_name, const char* path) {
+  ModulePatchPath(const char* module_name, const char* path) {
     assert(module_name != NULL && path != NULL, "Invalid module name or path value");
     size_t len = strlen(module_name) + 1;
     _module_name = AllocateHeap(len, mtInternal);
@@ -121,7 +121,7 @@
     _path =  new PathString(path);
   }
 
-  ~ModuleXPatchPath() {
+  ~ModulePatchPath() {
     if (_module_name != NULL) {
       FreeHeap(_module_name);
       _module_name = NULL;
@@ -158,6 +158,10 @@
   SystemProperty* next() const        { return _next; }
   void set_next(SystemProperty* next) { _next = next; }
 
+  bool is_readable() const {
+    return !_internal || strcmp(_key, "jdk.boot.class.path.append") == 0;
+  }
+
   // A system property should only have its value set
   // via an external interface if it is a writeable property.
   // The internal, non-writeable property jdk.boot.class.path.append
@@ -325,6 +329,21 @@
     arg_in_range   = 0
   };
 
+  enum PropertyAppendable {
+    AppendProperty,
+    AddProperty
+  };
+
+  enum PropertyWriteable {
+    WriteableProperty,
+    UnwriteableProperty
+  };
+
+  enum PropertyInternal {
+    InternalProperty,
+    ExternalProperty
+  };
+
  private:
 
   // a pointer to the flags file name if it is specified
@@ -348,18 +367,18 @@
   static SystemProperty *_java_class_path;
   static SystemProperty *_jdk_boot_class_path_append;
 
-  // -Xpatch:module=<file>(<pathsep><file>)*
+  // --patch-module=module=<file>(<pathsep><file>)*
   // Each element contains the associated module name, path
-  // string pair as specified to -Xpatch.
-  static GrowableArray<ModuleXPatchPath*>* _xpatchprefix;
+  // string pair as specified to --patch-module.
+  static GrowableArray<ModulePatchPath*>* _patch_mod_prefix;
 
   // The constructed value of the system class path after
   // argument processing and JVMTI OnLoad additions via
   // calls to AddToBootstrapClassLoaderSearch.  This is the
   // final form before ClassLoader::setup_bootstrap_search().
-  // Note: since -Xpatch is a module name/path pair, the system
-  // boot class path string no longer contains the "prefix" to
-  // the boot class path base piece as it did when
+  // Note: since --patch-module is a module name/path pair, the
+  // system boot class path string no longer contains the "prefix"
+  // to the boot class path base piece as it did when
   // -Xbootclasspath/p was supported.
   static PathString *_system_boot_class_path;
 
@@ -462,7 +481,13 @@
   static vfprintf_hook_t  _vfprintf_hook;
 
   // System properties
-  static bool add_property(const char* prop);
+  static bool add_property(const char* prop, PropertyWriteable writeable=WriteableProperty,
+                           PropertyInternal internal=ExternalProperty);
+
+  static bool create_property(const char* prop_name, const char* prop_value, PropertyInternal internal);
+  static bool create_numbered_property(const char* prop_base_name, const char* prop_value, unsigned int count);
+
+  static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase);
 
   // Miscellaneous system property setter
   static bool append_to_addmods_property(const char* module_name);
@@ -500,7 +525,7 @@
   static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
                                  const JavaVMInitArgs *java_options_args,
                                  const JavaVMInitArgs *cmd_line_args);
-  static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_javabase, Flag::Flags origin);
+  static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin);
   static jint finalize_vm_init_args();
   static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
 
@@ -708,16 +733,20 @@
   // Property List manipulation
   static void PropertyList_add(SystemProperty *element);
   static void PropertyList_add(SystemProperty** plist, SystemProperty *element);
-  static void PropertyList_add(SystemProperty** plist, const char* k, const char* v);
-  static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v) {
-    PropertyList_unique_add(plist, k, v, false);
-  }
-  static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, jboolean append);
+  static void PropertyList_add(SystemProperty** plist, const char* k, const char* v, bool writeable, bool internal);
+
+  static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
+                                      PropertyAppendable append, PropertyWriteable writeable,
+                                      PropertyInternal internal);
   static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
+  static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
   static int  PropertyList_count(SystemProperty* pl);
+  static int  PropertyList_readable_count(SystemProperty* pl);
   static const char* PropertyList_get_key_at(SystemProperty* pl,int index);
   static char* PropertyList_get_value_at(SystemProperty* pl,int index);
 
+  static bool is_internal_module_property(const char* option);
+
   // Miscellaneous System property value getter and setters.
   static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); }
   static void set_java_home(const char *value) { _java_home->set_value(value); }
@@ -725,7 +754,7 @@
   static void set_ext_dirs(char *value)     { _ext_dirs = os::strdup_check_oom(value); }
 
   // Set up the underlying pieces of the system boot class path
-  static void add_xpatchprefix(const char *module_name, const char *path, bool* xpatch_javabase);
+  static void add_patch_mod_prefix(const char *module_name, const char *path, bool* patch_mod_javabase);
   static void set_sysclasspath(const char *value, bool has_jimage) {
     // During start up, set by os::set_boot_path()
     assert(get_sysclasspath() == NULL, "System boot class path previously set");
@@ -737,7 +766,7 @@
     _jdk_boot_class_path_append->append_value(value);
   }
 
-  static GrowableArray<ModuleXPatchPath*>* get_xpatchprefix() { return _xpatchprefix; }
+  static GrowableArray<ModulePatchPath*>* get_patch_mod_prefix() { return _patch_mod_prefix; }
   static char* get_sysclasspath() { return _system_boot_class_path->value(); }
   static char* get_jdk_boot_class_path_append() { return _jdk_boot_class_path_append->value(); }
   static bool has_jimage() { return _has_jimage; }
--- a/hotspot/src/share/vm/utilities/ostream.cpp	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/src/share/vm/utilities/ostream.cpp	Fri Aug 19 12:17:32 2016 -0700
@@ -703,13 +703,15 @@
       // System properties don't generally contain newlines, so don't bother with unparsing.
       outputStream *text = xs->text();
       for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
-        // Print in two stages to avoid problems with long
-        // keys/values.
         assert(p->key() != NULL, "p->key() is NULL");
-        text->print_raw(p->key());
-        text->put('=');
-        assert(p->value() != NULL, "p->value() is NULL");
-        text->print_raw_cr(p->value());
+        if (p->is_readable()) {
+          // Print in two stages to avoid problems with long
+          // keys/values.
+          text->print_raw(p->key());
+          text->put('=');
+          assert(p->value() != NULL, "p->value() is NULL");
+          text->print_raw_cr(p->value());
+        }
       }
       xs->tail("properties");
     }
--- a/hotspot/test/TEST.ROOT	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/TEST.ROOT	Fri Aug 19 12:17:32 2016 -0700
@@ -46,12 +46,12 @@
     vm.gc.Parallel \
     vm.gc.ConcMarkSweep
 
-# Tests using jtreg 4.2 b02 features
-requiredVersion=4.2 b02
+# Tests using jtreg 4.2 b03 features
+requiredVersion=4.2 b03
 
 # Path to libraries in the topmost test directory. This is needed so @library
 # does not need ../../ notation to reach them
 external.lib.roots = ../../
 
-# Use new form of -Xpatch
-useNewXpatch=true
+# Use new module options
+useNewOptions=true
--- a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java	Fri Aug 19 12:17:32 2016 -0700
@@ -40,7 +40,7 @@
  *                                 -XX:CompileCommand=dontinline,compiler.unsafe.UnsafeGetConstantField::checkGetAddress
  *                                 -XX:CompileCommand=dontinline,*::test*
  *                                 -XX:+UseUnalignedAccesses
- *                                 -XaddReads:java.base=ALL-UNNAMED
+ *                                 --add-reads=java.base=ALL-UNNAMED
  *                                 compiler.unsafe.UnsafeGetConstantField
  *
  * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
@@ -50,7 +50,7 @@
  *                                 -XX:CompileCommand=dontinline,*::test*
  *                                 -XX:CompileCommand=inline,*Unsafe::get*
  *                                 -XX:-UseUnalignedAccesses
- *                                 -XaddReads:java.base=ALL-UNNAMED
+ *                                 --add-reads=java.base=ALL-UNNAMED
  *                                 compiler.unsafe.UnsafeGetConstantField
  */
 
--- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java	Fri Aug 19 12:17:32 2016 -0700
@@ -88,7 +88,7 @@
                 (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio),
                 "-Xmx" + MAX_HEAP_SIZE,
                 "-Xms" + HEAP_SIZE,
-                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
+                "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:NewSize=" + NEW_SIZE,
                 "-XX:MaxNewSize=" + MAX_NEW_SIZE,
                 "-XX:" + (shrinkHeapInSteps ? '+' : '-') + "ShrinkHeapInSteps",
@@ -120,7 +120,7 @@
         Collections.addAll(vmOptions,
                 (useXminf ? "-Xminf" + minRatio / 100.0 : "-XX:MinHeapFreeRatio=" + minRatio),
                 (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio),
-                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
+                "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-version"
         );
         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()]));
--- a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java	Fri Aug 19 12:17:32 2016 -0700
@@ -74,7 +74,7 @@
 
         Collections.addAll(vmOptions,
                 "-Xbootclasspath/a:.",
-                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
+                "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:+UnlockDiagnosticVMOptions",
                 "-XX:+WhiteBoxAPI",
                 "-XX:GCLockerEdenExpansionPercent=0",
--- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java	Fri Aug 19 12:17:32 2016 -0700
@@ -132,7 +132,7 @@
         LinkedList<String> vmOptions = new LinkedList<>(options);
         Collections.addAll(vmOptions,
                 "-Xbootclasspath/a:.",
-                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
+                "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:+UnlockDiagnosticVMOptions",
                 "-XX:+WhiteBoxAPI",
                 "-XX:+UseAdaptiveSizePolicy",
--- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java	Fri Aug 19 12:17:32 2016 -0700
@@ -53,7 +53,7 @@
         "-Xlog:gc=debug",
         "-XX:+UnlockDiagnosticVMOptions",
         "-XX:+WhiteBoxAPI",
-        "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
+        "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
         "-Xbootclasspath/a:.",
     };
 
--- a/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/BadObjectClass/BootstrapRedefine.java	Fri Aug 19 12:17:32 2016 -0700
@@ -48,7 +48,7 @@
                                         "-Xmodule:java.base"),
                                         "mods/java.base");
 
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.base=mods/java.base", "-version");
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base", "-version");
         new OutputAnalyzer(pb.start())
             .shouldContain("Incompatible definition of java.lang.Object")
             .shouldHaveExitValue(1);
--- a/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/BootClassAppendProp/BootClassPathAppendProp.java	Fri Aug 19 12:17:32 2016 -0700
@@ -27,7 +27,7 @@
  * @test
  * @build BootClassPathAppendProp
  * @run main/othervm -Xbootclasspath/a:/usr/lib -showversion -Xbootclasspath/a:/i/dont/exist BootClassPathAppendProp
- * @run main/othervm -Xpatch:/not/here -Xbootclasspath/a:/i/may/exist BootClassPathAppendProp
+ * @run main/othervm --patch-module=no_module=/not/here -Xbootclasspath/a:/i/may/exist BootClassPathAppendProp
  * @run main/othervm -Djdk.boot.class.path.append=newdir BootClassPathAppendProp
  * @run main/othervm BootClassPathAppendProp
  */
--- a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java	Fri Aug 19 12:17:32 2016 -0700
@@ -56,7 +56,7 @@
     public static OutputAnalyzer runTest(String option) throws Exception {
         return new OutputAnalyzer(
             ProcessTools.createJavaProcessBuilder(
-            "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName())
+            "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName())
             .start());
     }
 }
--- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -48,7 +48,7 @@
 
     public static void main(String[] args) throws Exception {
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName());
+            "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", Crasher.class.getName());
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldNotContain("Exception in thread");
         output.shouldNotMatch("error occurred during error reporting \\(printing problematic frame\\)");
--- a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java	Fri Aug 19 12:17:32 2016 -0700
@@ -160,10 +160,10 @@
 
     // Test #3: If a class on -Xbootclasspath/a is from a package defined in boot modules,
     //          the class can be loaded from -Xbootclasspath/a when the module is excluded
-    //          using -limitmods. Verify the behavior is the same at runtime when CDS is
-    //          enabled.
+    //          using --limit-modules. Verify the behavior is the same at runtime when CDS
+    //          is enabled.
     //
-    //          The java.desktop module is excluded using -limitmods at runtime,
+    //          The java.desktop module is excluded using --limit-modules at runtime,
     //          javax.sound.sampled.MyClass is archived from -Xbootclasspath/a. It can be
     //          loaded from the archive at runtime.
     public static void testBootAppendExcludedModuleClass() throws Exception {
@@ -174,7 +174,7 @@
                 "-XX:+TraceClassLoading",
                 "-cp", appJar,
                 "-Xbootclasspath/a:" + bootAppendJar,
-                "-limitmods", "java.base",
+                "--limit-modules=java.base",
                 "-Xshare:" + mode,
                 APP_CLASS,
                 BOOT_APPEND_MODULE_CLASS_NAME);
@@ -191,8 +191,8 @@
     // Test #4: If a class on -Xbootclasspath/a has the same fully qualified
     //          name as a class defined in boot modules, the class is loaded
     //          from -Xbootclasspath/a when the boot module is excluded using
-    //          -limitmods. Verify the behavior is the same at runtime when CDS is
-    //          enabled.
+    //          --limit-modules. Verify the behavior is the same at runtime
+    //          when CDS is enabled.
     //
     //          The org.omg.CORBA.Context is a boot module class. The class
     //          on -Xbootclasspath/a that has the same fully-qualified name
@@ -206,7 +206,7 @@
                 "-XX:+TraceClassLoading",
                 "-cp", appJar,
                 "-Xbootclasspath/a:" + bootAppendJar,
-                "-limitmods", "java.base",
+                "--limit-modules=java.base",
                 "-Xshare:" + mode,
                 APP_CLASS,
                 BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME);
--- a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -89,10 +89,11 @@
         long pid = p.getPid();
         System.out.println("Attaching agent " + pid);
         ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
-            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
-            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
-            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
-            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
+            "--add-modules=jdk.hotspot.agent",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
             "SASymbolTableTestAgent",
             Long.toString(pid));
         OutputAnalyzer output = ProcessTools.executeProcess(tool);
--- a/hotspot/test/runtime/Unsafe/RangeCheck.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/Unsafe/RangeCheck.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -44,7 +44,7 @@
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                 true,
                 "-Xmx32m",
-                "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED",
+                "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED",
                 "-XX:-TransmitErrorReport",
                 "-XX:-CreateCoredumpOnCrash",
                 "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert
--- a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -98,7 +98,7 @@
             ClassFileInstaller.writeClassToDisk("GetSysPkg_package/GetSysClass", klassbuf);
 
             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:bl_dir",
-                "-XaddExports:java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator +
+                "--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED", "-cp", "." + File.pathSeparator +
                 System.getProperty("test.classes"), "GetSysPkgTest", "do_tests");
             OutputAnalyzer output = new OutputAnalyzer(pb.start());
             output.shouldHaveExitValue(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/IgnoreModulePropertiesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016, 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 8136930
+ * @summary Test that the VM ignores explicitly specified module internal properties.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ */
+
+import jdk.test.lib.*;
+
+// Test that the VM ignores module related properties such as "jdk.module.addmods"
+// and jdk.module.addreads.0" that can only be set using module options.
+public class IgnoreModulePropertiesTest {
+
+    // Test that the specified property and its value are ignored.  If the VM accepted
+    // the property and value then an exception would be thrown because the value is
+    // bogus for that property.  But, since the property is ignored no exception is
+    // thrown.
+    public static void testProperty(String prop, String value) throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+            "-D" + prop + "=" + value, "-version");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("java version ");
+        output.shouldHaveExitValue(0);
+
+        // Ensure that the property and its value aren't available.
+        if (System.getProperty(prop) != null) {
+            throw new RuntimeException(
+                "Unexpected non-null value for property " + prop);
+        }
+    }
+
+    // For options of the form "option=value", check that an exception gets thrown for
+    // the illegal value and then check that its corresponding property is handled
+    // correctly.
+    public static void testOption(String option, String value,
+                                  String prop, String result) throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+            option + "=" + value, "-version");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain(result);
+        testProperty(prop, value);
+    }
+
+    public static void main(String[] args) throws Exception {
+        testOption("--add-modules", "java.sqlx", "jdk.module.addmods", "java.lang.module.ResolutionException");
+        testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.ResolutionException");
+        testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "java.lang.RuntimeException");
+        testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", "java.lang.RuntimeException");
+        testOption("--patch-module", "=d", "jdk.module.patch.0", "IllegalArgumentException");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/ModuleOptionsTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016, 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 8136930
+ * @summary Test that the VM only recognizes the last specified --add-modules
+ *          and --list-modules options
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ */
+
+import jdk.test.lib.*;
+
+// Test that the VM behaves correctly when processing module related options.
+public class ModuleOptionsTest {
+
+    public static void main(String[] args) throws Exception {
+
+        // Test that last --add-modules is the only one recognized.  No exception
+        // should be thrown.
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+            "--add-modules=i_dont_exist", "--add-modules=java.base", "-version");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+
+        // Test that last --limit-modules is the only one recognized.  No exception
+        // should be thrown.
+        pb = ProcessTools.createJavaProcessBuilder(
+            "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version");
+        output = new OutputAnalyzer(pb.start());
+        output.shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/ModuleOptionsWarn.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2016, 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 8162415
+ * @summary Test warnings for ignored properties.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ */
+
+import jdk.test.lib.*;
+
+// Test that the VM behaves correctly when processing command line module system properties.
+public class ModuleOptionsWarn {
+
+    public static void main(String[] args) throws Exception {
+
+        // Test that a warning is issued for module related properties that get ignored.
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+PrintWarnings", "-Djdk.module.ignored", "-version");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("Ignoring system property option");
+        output.shouldHaveExitValue(0);
+
+        // Test that a warning can be suppressed for module related properties that get ignored.
+        pb = ProcessTools.createJavaProcessBuilder(
+            "-Djdk.module.ignored", "-XX:-PrintWarnings", "-version");
+        output = new OutputAnalyzer(pb.start());
+        output.shouldNotContain("Ignoring system property option");
+        output.shouldHaveExitValue(0);
+
+        // Test that a warning is not issued for properties of the form "jdk.module.main"
+        pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+PrintWarnings", "-Djdk.module.main.ignored", "-version");
+        output = new OutputAnalyzer(pb.start());
+        output.shouldNotContain("Ignoring system property option");
+        output.shouldHaveExitValue(0);
+    }
+}
--- a/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/modules/ModuleStress/ExportModuleStressTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -62,8 +62,8 @@
         compiled = CompilerUtils.compile(
             SRC_DIR.resolve("jdk.translet"),
             MODS_DIR.resolve("jdk.translet"),
-            "-XaddExports:jdk.test/test=jdk.translet",
-            "-mp", MODS_DIR.toString());
+            "--add-exports=jdk.test/test=jdk.translet",
+            "-p", MODS_DIR.toString());
         if (!compiled) {
             throw new RuntimeException("Test failed to compile module jdk.translet");
         }
@@ -71,7 +71,7 @@
         // Sanity check that the test, jdk.test/test/Main.java
         // runs without error.
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            "-mp", MODS_DIR.toString(),
+            "-p", MODS_DIR.toString(),
             "-m", "jdk.test/test.Main");
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldContain("failed: 0")
--- a/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java	Fri Aug 19 12:17:32 2016 -0700
@@ -62,8 +62,8 @@
         compiled = CompilerUtils.compile(
             SRC_DIR.resolve("jdk.translet"),
             MODS_DIR.resolve("jdk.translet"),
-            "-XaddExports:jdk.test/test=jdk.translet",
-            "-mp", MODS_DIR.toString());
+            "--add-exports=jdk.test/test=jdk.translet",
+            "-p", MODS_DIR.toString());
         if (!compiled) {
             throw new RuntimeException("Test failed to compile module jdk.translet");
         }
@@ -74,7 +74,7 @@
         // GC safepoints.
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
             "-Xlog:modules=trace",
-            "-mp", MODS_DIR.toString(),
+            "-p", MODS_DIR.toString(),
             "-m", "jdk.test/test.MainGC");
         OutputAnalyzer oa = new OutputAnalyzer(pb.start());
         oa.shouldContain("package test defined in module jdk.test, exports list being walked")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/BasicJarBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2015, 2016, 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.
+ */
+
+/*
+ * @summary Simple jar builder
+ *   Input: jarName className1 className2 ...
+ *     do not specify extensions, just the names
+ *     E.g. prot_domain ProtDomainA ProtDomainB
+ *   Output: A jar containing compiled classes, placed in a test classes folder
+ */
+
+import jdk.test.lib.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import sun.tools.jar.Main;
+
+// Using JarBuilder requires that all to-be-jarred classes should be placed
+// in the current working directory, aka "."
+public class BasicJarBuilder {
+    private static final String classDir = System.getProperty("test.classes");
+
+    public static void build(boolean classesInWorkDir, String jarName,
+        String ...classNames) throws Exception {
+
+        if (classesInWorkDir) {
+            createSimpleJar(".", classDir + File.separator + jarName + ".jar", classNames);
+        } else {
+            build(jarName, classNames);
+        }
+    }
+
+    public static void build(String jarName, String ...classNames) throws Exception {
+        createSimpleJar(classDir, classDir + File.separator + jarName + ".jar",
+            classNames);
+    }
+
+    private static void createSimpleJar(String jarclassDir, String jarName,
+        String[] classNames) throws Exception {
+        ArrayList<String> args = new ArrayList<String>();
+        args.add("cf");
+        args.add(jarName);
+        addClassArgs(args, jarclassDir, classNames);
+        createJar(args);
+    }
+
+    private static void addClassArgs(ArrayList<String> args, String jarclassDir,
+        String[] classNames) {
+
+        for (String name : classNames) {
+            args.add("-C");
+            args.add(jarclassDir);
+            args.add(name + ".class");
+        }
+    }
+
+    private static void createJar(ArrayList<String> args) {
+        Main jarTool = new Main(System.out, System.err, "jar");
+        if (!jarTool.run(args.toArray(new String[1]))) {
+            throw new RuntimeException("jar operation failed");
+        }
+    }
+
+    // Get full path to the test jar
+    public static String getTestJar(String jar) {
+        File dir = new File(System.getProperty("test.classes", "."));
+        File jarFile = new File(dir, jar);
+        if (!jarFile.exists()) {
+            throw new RuntimeException("Cannot find " + jarFile.getPath());
+        }
+        if (!jarFile.isFile()) {
+            throw new RuntimeException("Not a regular file: " + jarFile.getPath());
+        }
+        return jarFile.getPath();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModule2Dirs.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2015, 2016, 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
+ * @summary Make sure --patch-module works with multiple directories.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ * @compile PatchModule2DirsMain.java
+ * @run main PatchModule2Dirs
+ */
+
+import jdk.test.lib.*;
+import java.io.File;
+
+public class PatchModule2Dirs {
+
+    public static void main(String[] args) throws Exception {
+        String source1 = "package javax.naming.spi; "               +
+                        "public class NamingManager { "             +
+                        "    static { "                             +
+                        "        System.out.println(\"I pass one!\"); " +
+                        "    } "                                    +
+                        "}";
+        String source2 = "package java.beans; "                     +
+                        "public class Encoder { "                   +
+                        "    static { "                             +
+                        "        System.out.println(\"I pass two!\"); " +
+                        "    } "                                    +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source1, "-Xmodule:java.naming"),
+             "mods/java.naming");
+
+        ClassFileInstaller.writeClassToDisk("java/beans/Encoder",
+             InMemoryJavaCompiler.compile("java.beans.Encoder", source2, "-Xmodule:java.desktop"),
+             "mods2/java.desktop");
+
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+             "--patch-module=java.naming=mods/java.naming",
+             "--patch-module=java.desktop=mods2/java.desktop",
+             "PatchModule2DirsMain", "javax.naming.spi.NamingManager", "java.beans.Encoder");
+
+        OutputAnalyzer oa = new OutputAnalyzer(pb.start());
+        oa.shouldContain("I pass one!");
+        oa.shouldContain("I pass two!");
+        oa.shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModule2DirsMain.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+// This loads the class affected by the --patch-module option.  For the test to pass
+// it must load both classes from the --patch-module directory, not the jimage file.
+public class PatchModule2DirsMain {
+    public static void main(String[] args) throws Exception {
+        Class.forName(args[0]);
+        Class.forName(args[1]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015, 2016, 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
+ * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ * @run main PatchModuleCDS
+ */
+
+import java.io.File;
+import jdk.test.lib.*;
+
+public class PatchModuleCDS {
+
+    public static void main(String args[]) throws Throwable {
+        System.out.println("Test that --patch-module and -Xshare:dump are incompatibable");
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming", "-Xshare:dump");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        output.shouldContain("Cannot use the following option when dumping the shared archive: --patch-module");
+
+        System.out.println("Test that --patch-module and -Xshare:on are incompatibable");
+        String filename = "patch_module.jsa";
+        pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+UnlockDiagnosticVMOptions",
+            "-XX:SharedArchiveFile=" + filename,
+            "-Xshare:dump");
+        output = new OutputAnalyzer(pb.start());
+        output.shouldContain("ro space:"); // Make sure archive got created.
+
+        pb = ProcessTools.createJavaProcessBuilder(
+            "-XX:+UnlockDiagnosticVMOptions",
+            "-XX:SharedArchiveFile=" + filename,
+            "-Xshare:on",
+            "--patch-module=java.naming=mods/java.naming",
+            "-version");
+        output = new OutputAnalyzer(pb.start());
+        output.shouldContain("The shared archive file cannot be used with --patch-module");
+
+        output.shouldHaveExitValue(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleDupJavaBase.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2016, 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
+ * @summary VM exit initialization results if java.base is specificed more than once to --patch-module.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ */
+
+import jdk.test.lib.*;
+
+public class PatchModuleDupJavaBase {
+  // The VM should exit initialization if java.base is specified
+  // more than once to --patch-module.
+  public static void main(String args[]) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+      "--patch-module=java.base=javabase_dir",
+      "--patch-module=java.base=javabase_dir",
+      "-version");
+    OutputAnalyzer output = new OutputAnalyzer(pb.start());
+    output.shouldContain("Cannot specify java.base more than once to --patch-module");
+    output.shouldHaveExitValue(1);
+  }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleDupModule.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2016, 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
+ * @summary Module system initialization exception results if a module is specificed twice to --patch-module.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ */
+
+import jdk.test.lib.*;
+
+public class PatchModuleDupModule {
+
+  // The module system initialization should generate an ExceptionInInitializerError
+  // if --patch-module is specified with the same module more than once.
+
+  public static void main(String args[]) throws Exception {
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+      "--patch-module=module1=module1_dir",
+      "--patch-module=module1=module1_dir",
+      "-version");
+    OutputAnalyzer output = new OutputAnalyzer(pb.start());
+    output.shouldContain("java.lang.ExceptionInInitializerError");
+    output.shouldHaveExitValue(1);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleJavaBase.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, 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 8130399
+ * @summary Make sure --patch-module works for java.base.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ * @compile PatchModuleMain.java
+ * @run main PatchModuleJavaBase
+ */
+
+import jdk.test.lib.*;
+
+public class PatchModuleJavaBase {
+
+    public static void main(String[] args) throws Exception {
+        String source = "package java.lang; "                       +
+                        "public class NewClass { "                  +
+                        "    static { "                             +
+                        "        System.out.println(\"I pass!\"); " +
+                        "    } "                                    +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("java/lang/NewClass",
+             InMemoryJavaCompiler.compile("java.lang.NewClass", source, "-Xmodule:java.base"),
+             "mods/java.base");
+
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.base=mods/java.base",
+             "PatchModuleMain", "java.lang.NewClass");
+
+        new OutputAnalyzer(pb.start())
+            .shouldContain("I pass!")
+            .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleMain.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+// This loads the class affected by the --patch-module option.  For the test to pass
+// it must load the class from the --patch-module directory, not the jimage file.
+public class PatchModuleMain {
+    public static void main(String[] args) throws Exception {
+        Class.forName(args[0]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, 2016, 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 8130399
+ * @summary Make sure --patch-module works for modules besides java.base.
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ * @compile PatchModuleMain.java
+ * @run main PatchModuleTest
+ */
+
+import jdk.test.lib.*;
+
+public class PatchModuleTest {
+
+    public static void main(String[] args) throws Exception {
+        String source = "package javax.naming.spi; "                +
+                        "public class NamingManager { "             +
+                        "    static { "                             +
+                        "        System.out.println(\"I pass!\"); " +
+                        "    } "                                    +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
+             "mods/java.naming");
+
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming",
+             "PatchModuleMain", "javax.naming.spi.NamingManager");
+
+        new OutputAnalyzer(pb.start())
+            .shouldContain("I pass!")
+            .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJar.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, 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
+ * @summary Make sure --patch-module works when a jar file is specified for a module
+ * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ *          jdk.jartool/sun.tools.jar
+ * @build BasicJarBuilder
+ * @compile PatchModuleMain.java
+ * @run main PatchModuleTestJar
+ */
+
+import jdk.test.lib.*;
+
+public class PatchModuleTestJar {
+    private static String moduleJar;
+
+    public static void main(String[] args) throws Exception {
+
+        // Create a class file in the module java.naming. This class file
+        // will be put in the javanaming.jar file.
+        String source = "package javax.naming.spi; "                +
+                        "public class NamingManager { "             +
+                        "    static { "                             +
+                        "        System.out.println(\"I pass!\"); " +
+                        "    } "                                    +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
+             System.getProperty("test.classes"));
+
+        // Build the jar file that will be used for the module "java.naming".
+        BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager");
+        moduleJar = BasicJarBuilder.getTestJar("javanaming.jar");
+
+        // Just to make sure we are not fooled by the class file being on the
+        // class path where all the test classes are stored, write the NamingManager.class
+        // file out again with output that does not contain what OutputAnalyzer
+        // expects. This will provide confidence that the contents of the class
+        // is truly coming from the jar file and not the class file.
+        source =        "package javax.naming.spi; "                +
+                        "public class NamingManager { "             +
+                        "    static { "                             +
+                        "        System.out.println(\"Fail!\"); "   +
+                        "    } "                                    +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
+             System.getProperty("test.classes"));
+
+        // Supply --patch-module with the name of the jar file for the module java.naming.
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" + moduleJar,
+             "PatchModuleMain", "javax.naming.spi.NamingManager");
+
+        new OutputAnalyzer(pb.start())
+            .shouldContain("I pass!")
+            .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTestJarDir.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016, 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
+ * @summary Make sure --patch-module works when a jar file and a directory is specified for a module
+ * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ *          jdk.jartool/sun.tools.jar
+ * @build BasicJarBuilder
+ * @compile PatchModule2DirsMain.java
+ * @run main PatchModuleTestJarDir
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import jdk.test.lib.*;
+
+public class PatchModuleTestJarDir {
+    private static String moduleJar;
+
+    public static void main(String[] args) throws Exception {
+
+        // Create a class file in the module java.naming. This class file
+        // will be put in the javanaming.jar file.
+        String source = "package javax.naming.spi; "                    +
+                        "public class NamingManager1 { "                +
+                        "    static { "                                 +
+                        "        System.out.println(\"I pass one!\"); " +
+                        "    } "                                        +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"),
+             System.getProperty("test.classes"));
+
+        // Build the jar file that will be used for the module "java.naming".
+        BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager1");
+        moduleJar = BasicJarBuilder.getTestJar("javanaming.jar");
+
+        // Just to make sure we are not fooled by the class file being on the
+        // class path where all the test classes are stored, write the NamingManager.class
+        // file out again with output that does not contain what OutputAnalyzer
+        // expects. This will provide confidence that the contents of the class
+        // is truly coming from the jar file and not the class file.
+        source = "package javax.naming.spi; "                +
+                 "public class NamingManager1 { "            +
+                 "    static { "                             +
+                 "        System.out.println(\"Fail!\"); "   +
+                 "    } "                                    +
+                 "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"),
+             System.getProperty("test.classes"));
+
+        // Create a second class file in the module java.naming. This class file
+        // will be put in the mods/java.naming directory.
+        source = "package javax.naming.spi; "                    +
+                 "public class NamingManager2 { "                +
+                 "    static { "                                 +
+                 "        System.out.println(\"I pass two!\"); " +
+                 "    } "                                        +
+                 "}";
+
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager2",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager2", source, "-Xmodule:java.naming"),
+             (System.getProperty("test.classes") + "/mods/java.naming"));
+
+
+        // Supply --patch-module with the name of the jar file for the module java.naming.
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=" +
+                                                                           moduleJar +
+                                                                           File.pathSeparator +
+                                                                           System.getProperty("test.classes") + "/mods/java.naming",
+                                                                  "PatchModule2DirsMain",
+                                                                  "javax.naming.spi.NamingManager1",
+                                                                  "javax.naming.spi.NamingManager2");
+
+        new OutputAnalyzer(pb.start())
+            .shouldContain("I pass one!")
+            .shouldContain("I pass two!")
+            .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleTraceCL.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016, 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 8069469
+ * @summary Make sure -Xlog:classload=info works properly with "modules" jimage,
+            --patch-module, and with -Xbootclasspath/a
+ * @modules java.base/jdk.internal.misc
+ * @library /testlibrary
+ * @compile PatchModuleMain.java
+ * @run main PatchModuleTraceCL
+ */
+
+import java.io.File;
+import jdk.test.lib.*;
+
+public class PatchModuleTraceCL {
+
+    public static void main(String[] args) throws Exception {
+        String source = "package javax.naming.spi; "                +
+                        "public class NamingManager { "             +
+                        "    static { "                             +
+                        "        System.out.println(\"I pass!\"); " +
+                        "    } "                                    +
+                        "}";
+
+        // Test -Xlog:classload=info output for --patch-module
+        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
+             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
+             "mods/java.naming");
+
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--patch-module=java.naming=mods/java.naming",
+             "-Xlog:class+load=info", "PatchModuleMain", "javax.naming.spi.NamingManager");
+
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        // "modules" jimage case.
+        output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base");
+        // --patch-module case.
+        output.shouldContain("[class,load] javax.naming.spi.NamingManager source: mods/java.naming");
+        // -cp case.
+        output.shouldContain("[class,load] PatchModuleMain source: file");
+
+        // Test -Xlog:classload=info output for -Xbootclasspath/a
+        source = "package PatchModuleTraceCL_pkg; "                 +
+                 "public class ItIsI { "                          +
+                 "    static { "                                  +
+                 "        System.out.println(\"I also pass!\"); " +
+                 "    } "                                         +
+                 "}";
+
+        ClassFileInstaller.writeClassToDisk("PatchModuleTraceCL_pkg/ItIsI",
+             InMemoryJavaCompiler.compile("PatchModuleTraceCL_pkg.ItIsI", source),
+             "xbcp");
+
+        pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:xbcp",
+             "-Xlog:class+load=info", "PatchModuleMain", "PatchModuleTraceCL_pkg.ItIsI");
+        output = new OutputAnalyzer(pb.start());
+        // -Xbootclasspath/a case.
+        output.shouldContain("[class,load] PatchModuleTraceCL_pkg.ItIsI source: xbcp");
+        output.shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/modules/Visibility/PatchModuleVisibility.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2015, 2016, 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
+ * @summary Ensure that a newly introduced java.base package placed within the --patch-module
+ *          directory is considered part of the boot loader's visibility boundary
+ * @requires !(os.family == "windows")
+ * @library /testlibrary
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ * @run main/othervm PatchModuleVisibility
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+import jdk.test.lib.*;
+
+public class PatchModuleVisibility {
+
+    public static void main(String[] args) throws Throwable {
+
+      String Vis2_B_src =
+              "package p2;" +
+              "public class Vis2_B {" +
+              "    public void m() {" +
+              "        System.out.println(\"In B's m()\");" +
+              "    }" +
+              "}";
+
+      String Vis2_A_src =
+              "import p2.*;" +
+              "public class Vis2_A {" +
+              "    public static void main(String args[]) throws Exception {" +
+                      // Try loading a class within a newly introduced java.base
+                      // package.  Make sure the class can be found via --patch-module.
+              "        try {" +
+              "            p2.Vis2_B b = new p2.Vis2_B();" +
+              "            if (b.getClass().getClassLoader() != null) {" +
+              "                throw new RuntimeException(\"PatchModuleVisibility FAILED - class B " +
+                                                           "should be loaded by boot class loader\\n\");" +
+              "            }" +
+              "            b.m();" +
+              "        } catch (Throwable e) {" +
+              "            throw new RuntimeException(\"PatchModuleVisibility FAILED - test " +
+                                                       "should not throw an error or exception\\n\");" +
+              "        }" +
+              "        System.out.println(\"PatchModuleVisibility PASSED\\n\");" +
+              "    }" +
+              "}";
+
+      ClassFileInstaller.writeClassToDisk("p2/Vis2_B",
+          InMemoryJavaCompiler.compile("p2.Vis2_B", Vis2_B_src), System.getProperty("test.classes"));
+      ClassFileInstaller.writeClassToDisk("p2/Vis2_B", "mods2/java.base");
+
+      ClassFileInstaller.writeClassToDisk("Vis2_A",
+          InMemoryJavaCompiler.compile("Vis2_A", Vis2_A_src), System.getProperty("test.classes"));
+
+      // Make sure the classes are actually being loaded from mods2
+      Files.delete(Paths.get(System.getProperty("test.classes") +  File.separator +
+                                                           "p2" + File.separator + "Vis2_B.class"));
+
+      new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(
+              "--patch-module=java.base=mods2/java.base",
+              "--add-exports=java.base/p2=ALL-UNNAMED",
+              "Vis2_A")
+          .start()).shouldHaveExitValue(0);
+    }
+}
--- a/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/modules/Visibility/XbootcpNoVisibility.java	Fri Aug 19 12:17:32 2016 -0700
@@ -50,7 +50,7 @@
                         // Try loading a class within a named package in a module which has been defined
                         // to the boot loader. In this situation, the class should only be attempted
                         // to be loaded from the boot loader's module path which consists of:
-                        //   [-Xpatch]; exploded build | "modules" jimage
+                        //   [--patch-module]; exploded build | "modules" jimage
                         //
                         // Since the class is located on the boot loader's append path via
                         // -Xbootclasspath/a specification, it should not be found.
--- a/hotspot/test/runtime/modules/Visibility/XpatchVisibility.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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
- * @summary Ensure that a newly introduced java.base package placed within the -Xpatch directory
- *          is considered part of the boot loader's visibility boundary
- * @requires !(os.family == "windows")
- * @library /testlibrary
- * @modules java.base/jdk.internal.misc
- *          java.management
- * @run main/othervm XpatchVisibility
- */
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import jdk.test.lib.*;
-
-public class XpatchVisibility {
-
-    public static void main(String[] args) throws Throwable {
-
-      String Vis2_B_src =
-              "package p2;" +
-              "public class Vis2_B {" +
-              "    public void m() {" +
-              "        System.out.println(\"In B's m()\");" +
-              "    }" +
-              "}";
-
-      String Vis2_A_src =
-              "import p2.*;" +
-              "public class Vis2_A {" +
-              "    public static void main(String args[]) throws Exception {" +
-                      // Try loading a class within a newly introduced java.base
-                      // package.  Make sure the class can be found via -Xpatch.
-              "        try {" +
-              "            p2.Vis2_B b = new p2.Vis2_B();" +
-              "            if (b.getClass().getClassLoader() != null) {" +
-              "                throw new RuntimeException(\"XpatchVisibility FAILED - class B " +
-                                                           "should be loaded by boot class loader\\n\");" +
-              "            }" +
-              "            b.m();" +
-              "        } catch (Throwable e) {" +
-              "            throw new RuntimeException(\"XpatchVisibility FAILED - test " +
-                                                       "should not throw an error or exception\\n\");" +
-              "        }" +
-              "        System.out.println(\"XpatchVisibility PASSED\\n\");" +
-              "    }" +
-              "}";
-
-      ClassFileInstaller.writeClassToDisk("p2/Vis2_B",
-          InMemoryJavaCompiler.compile("p2.Vis2_B", Vis2_B_src), System.getProperty("test.classes"));
-      ClassFileInstaller.writeClassToDisk("p2/Vis2_B", "mods2/java.base");
-
-      ClassFileInstaller.writeClassToDisk("Vis2_A",
-          InMemoryJavaCompiler.compile("Vis2_A", Vis2_A_src), System.getProperty("test.classes"));
-
-      // Make sure the classes are actually being loaded from mods2
-      Files.delete(Paths.get(System.getProperty("test.classes") +  File.separator +
-                                                           "p2" + File.separator + "Vis2_B.class"));
-
-      new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(
-              "-Xpatch:java.base=mods2/java.base",
-              "-XaddExports:java.base/p2=ALL-UNNAMED",
-              "Vis2_A")
-          .start()).shouldHaveExitValue(0);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/BasicJarBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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.
- */
-
-/*
- * @summary Simple jar builder
- *   Input: jarName className1 className2 ...
- *     do not specify extensions, just the names
- *     E.g. prot_domain ProtDomainA ProtDomainB
- *   Output: A jar containing compiled classes, placed in a test classes folder
- */
-
-import jdk.test.lib.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import sun.tools.jar.Main;
-
-// Using JarBuilder requires that all to-be-jarred classes should be placed
-// in the current working directory, aka "."
-public class BasicJarBuilder {
-    private static final String classDir = System.getProperty("test.classes");
-
-    public static void build(boolean classesInWorkDir, String jarName,
-        String ...classNames) throws Exception {
-
-        if (classesInWorkDir) {
-            createSimpleJar(".", classDir + File.separator + jarName + ".jar", classNames);
-        } else {
-            build(jarName, classNames);
-        }
-    }
-
-    public static void build(String jarName, String ...classNames) throws Exception {
-        createSimpleJar(classDir, classDir + File.separator + jarName + ".jar",
-            classNames);
-    }
-
-    private static void createSimpleJar(String jarclassDir, String jarName,
-        String[] classNames) throws Exception {
-        ArrayList<String> args = new ArrayList<String>();
-        args.add("cf");
-        args.add(jarName);
-        addClassArgs(args, jarclassDir, classNames);
-        createJar(args);
-    }
-
-    private static void addClassArgs(ArrayList<String> args, String jarclassDir,
-        String[] classNames) {
-
-        for (String name : classNames) {
-            args.add("-C");
-            args.add(jarclassDir);
-            args.add(name + ".class");
-        }
-    }
-
-    private static void createJar(ArrayList<String> args) {
-        Main jarTool = new Main(System.out, System.err, "jar");
-        if (!jarTool.run(args.toArray(new String[1]))) {
-            throw new RuntimeException("jar operation failed");
-        }
-    }
-
-    // Get full path to the test jar
-    public static String getTestJar(String jar) {
-        File dir = new File(System.getProperty("test.classes", "."));
-        File jarFile = new File(dir, jar);
-        if (!jarFile.exists()) {
-            throw new RuntimeException("Cannot find " + jarFile.getPath());
-        }
-        if (!jarFile.isFile()) {
-            throw new RuntimeException("Not a regular file: " + jarFile.getPath());
-        }
-        return jarFile.getPath();
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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
- * @summary Make sure -Xpatch works with multiple directories.
- * @modules java.base/jdk.internal.misc
- * @library /testlibrary
- * @compile Xpatch2DirsMain.java
- * @run main Xpatch2Dirs
- */
-
-import jdk.test.lib.*;
-import java.io.File;
-
-public class Xpatch2Dirs {
-
-    public static void main(String[] args) throws Exception {
-        String source1 = "package javax.naming.spi; "               +
-                        "public class NamingManager { "             +
-                        "    static { "                             +
-                        "        System.out.println(\"I pass one!\"); " +
-                        "    } "                                    +
-                        "}";
-        String source2 = "package java.beans; "                     +
-                        "public class Encoder { "                   +
-                        "    static { "                             +
-                        "        System.out.println(\"I pass two!\"); " +
-                        "    } "                                    +
-                        "}";
-
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source1, "-Xmodule:java.naming"),
-             "mods/java.naming");
-
-        ClassFileInstaller.writeClassToDisk("java/beans/Encoder",
-             InMemoryJavaCompiler.compile("java.beans.Encoder", source2, "-Xmodule:java.desktop"),
-             "mods2/java.desktop");
-
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-             "-Xpatch:java.naming=mods/java.naming",
-             "-Xpatch:java.desktop=mods2/java.desktop",
-             "Xpatch2DirsMain", "javax.naming.spi.NamingManager", "java.beans.Encoder");
-
-        OutputAnalyzer oa = new OutputAnalyzer(pb.start());
-        oa.shouldContain("I pass one!");
-        oa.shouldContain("I pass two!");
-        oa.shouldHaveExitValue(0);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/Xpatch2DirsMain.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2015, 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.
- */
-
-// This loads the class affected by the -Xpatch option.  For the test to pass
-// it must load both classes from the -Xpatch directory, not the jimage file.
-public class Xpatch2DirsMain {
-    public static void main(String[] args) throws Exception {
-        Class.forName(args[0]);
-        Class.forName(args[1]);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * @summary VM exit initialization results if java.base is specificed more than once to Xpatch.
- * @modules java.base/jdk.internal.misc
- * @library /testlibrary
- */
-
-import jdk.test.lib.*;
-
-public class XpatchDupJavaBase {
-  // The VM should exit initialization if java.base is specified
-  // more than once to -Xpatch.
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-      "-Xpatch:java.base=javabase_dir",
-      "-Xpatch:java.base=javabase_dir",
-      "-version");
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("Cannot specify java.base more than once to -Xpatch");
-    output.shouldHaveExitValue(1);
-  }
-}
-
--- a/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * @summary Module system initialization exception results if a module is specificed twice to Xpatch.
- * @modules java.base/jdk.internal.misc
- * @library /testlibrary
- */
-
-import jdk.test.lib.*;
-
-public class XpatchDupModule {
-
-  // The module system initialization should generate an ExceptionInInitializerError
-  // if -Xpatch is specified with the same module more than once.
-
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-      "-Xpatch:module1=module1_dir",
-      "-Xpatch:module1=module1_dir",
-      "-version");
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("java.lang.ExceptionInInitializerError");
-    output.shouldHaveExitValue(1);
-  }
-}
-
--- a/hotspot/test/runtime/modules/Xpatch/XpatchJavaBase.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2016, 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 8130399
- * @summary Make sure -Xpatch works for java.base.
- * @modules java.base/jdk.internal.misc
- * @library /testlibrary
- * @compile XpatchMain.java
- * @run main XpatchJavaBase
- */
-
-import jdk.test.lib.*;
-
-public class XpatchJavaBase {
-
-    public static void main(String[] args) throws Exception {
-        String source = "package java.lang; "                       +
-                        "public class NewClass { "                  +
-                        "    static { "                             +
-                        "        System.out.println(\"I pass!\"); " +
-                        "    } "                                    +
-                        "}";
-
-        ClassFileInstaller.writeClassToDisk("java/lang/NewClass",
-             InMemoryJavaCompiler.compile("java.lang.NewClass", source, "-Xmodule:java.base"),
-             "mods/java.base");
-
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.base=mods/java.base",
-             "XpatchMain", "java.lang.NewClass");
-
-        new OutputAnalyzer(pb.start())
-            .shouldContain("I pass!")
-            .shouldHaveExitValue(0);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/XpatchMain.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015, 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.
- */
-
-// This loads the class affected by the -Xpatch option.  For the test to pass
-// it must load the class from the -Xpatch directory, not the jimage file.
-public class XpatchMain {
-    public static void main(String[] args) throws Exception {
-        Class.forName(args[0]);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/XpatchTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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 8130399
- * @summary Make sure -Xpatch works for modules besides java.base.
- * @modules java.base/jdk.internal.misc
- * @library /testlibrary
- * @compile XpatchMain.java
- * @run main XpatchTest
- */
-
-import jdk.test.lib.*;
-
-public class XpatchTest {
-
-    public static void main(String[] args) throws Exception {
-        String source = "package javax.naming.spi; "                +
-                        "public class NamingManager { "             +
-                        "    static { "                             +
-                        "        System.out.println(\"I pass!\"); " +
-                        "    } "                                    +
-                        "}";
-
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
-             "mods/java.naming");
-
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming",
-             "XpatchMain", "javax.naming.spi.NamingManager");
-
-        new OutputAnalyzer(pb.start())
-            .shouldContain("I pass!")
-            .shouldHaveExitValue(0);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/XpatchTestJar.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * @summary Make sure -Xpatch works when a jar file is specified for a module
- * @library /testlibrary
- * @modules java.base/jdk.internal.misc
- *          jdk.jartool/sun.tools.jar
- * @build BasicJarBuilder
- * @compile XpatchMain.java
- * @run main XpatchTestJar
- */
-
-import jdk.test.lib.*;
-
-public class XpatchTestJar {
-    private static String moduleJar;
-
-    public static void main(String[] args) throws Exception {
-
-        // Create a class file in the module java.naming. This class file
-        // will be put in the javanaming.jar file.
-        String source = "package javax.naming.spi; "                +
-                        "public class NamingManager { "             +
-                        "    static { "                             +
-                        "        System.out.println(\"I pass!\"); " +
-                        "    } "                                    +
-                        "}";
-
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
-             System.getProperty("test.classes"));
-
-        // Build the jar file that will be used for the module "java.naming".
-        BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager");
-        moduleJar = BasicJarBuilder.getTestJar("javanaming.jar");
-
-        // Just to make sure we are not fooled by the class file being on the
-        // class path where all the test classes are stored, write the NamingManager.class
-        // file out again with output that does not contain what OutputAnalyzer
-        // expects. This will provide confidence that the contents of the class
-        // is truly coming from the jar file and not the class file.
-        source =        "package javax.naming.spi; "                +
-                        "public class NamingManager { "             +
-                        "    static { "                             +
-                        "        System.out.println(\"Fail!\"); "   +
-                        "    } "                                    +
-                        "}";
-
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
-             System.getProperty("test.classes"));
-
-        // Supply -Xpatch with the name of the jar file for the module java.naming.
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=" + moduleJar,
-             "XpatchMain", "javax.naming.spi.NamingManager");
-
-        new OutputAnalyzer(pb.start())
-            .shouldContain("I pass!")
-            .shouldHaveExitValue(0);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/XpatchTestJarDir.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2016, 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
- * @summary Make sure -Xpatch works when a jar file and a directory is specified for a module
- * @library /testlibrary
- * @modules java.base/jdk.internal.misc
- *          jdk.jartool/sun.tools.jar
- * @build BasicJarBuilder
- * @compile Xpatch2DirsMain.java
- * @run main XpatchTestJarDir
- */
-
-import java.io.File;
-import java.nio.file.Files;
-import jdk.test.lib.*;
-
-public class XpatchTestJarDir {
-    private static String moduleJar;
-
-    public static void main(String[] args) throws Exception {
-
-        // Create a class file in the module java.naming. This class file
-        // will be put in the javanaming.jar file.
-        String source = "package javax.naming.spi; "                    +
-                        "public class NamingManager1 { "                +
-                        "    static { "                                 +
-                        "        System.out.println(\"I pass one!\"); " +
-                        "    } "                                        +
-                        "}";
-
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"),
-             System.getProperty("test.classes"));
-
-        // Build the jar file that will be used for the module "java.naming".
-        BasicJarBuilder.build("javanaming", "javax/naming/spi/NamingManager1");
-        moduleJar = BasicJarBuilder.getTestJar("javanaming.jar");
-
-        // Just to make sure we are not fooled by the class file being on the
-        // class path where all the test classes are stored, write the NamingManager.class
-        // file out again with output that does not contain what OutputAnalyzer
-        // expects. This will provide confidence that the contents of the class
-        // is truly coming from the jar file and not the class file.
-        source = "package javax.naming.spi; "                +
-                 "public class NamingManager1 { "            +
-                 "    static { "                             +
-                 "        System.out.println(\"Fail!\"); "   +
-                 "    } "                                    +
-                 "}";
-
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager1",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager1", source, "-Xmodule:java.naming"),
-             System.getProperty("test.classes"));
-
-        // Create a second class file in the module java.naming. This class file
-        // will be put in the mods/java.naming directory.
-        source = "package javax.naming.spi; "                    +
-                 "public class NamingManager2 { "                +
-                 "    static { "                                 +
-                 "        System.out.println(\"I pass two!\"); " +
-                 "    } "                                        +
-                 "}";
-
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager2",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager2", source, "-Xmodule:java.naming"),
-             (System.getProperty("test.classes") + "/mods/java.naming"));
-
-
-        // Supply -Xpatch with the name of the jar file for the module java.naming.
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=" +
-                                                                           moduleJar +
-                                                                           File.pathSeparator +
-                                                                           System.getProperty("test.classes") + "/mods/java.naming",
-                                                                  "Xpatch2DirsMain",
-                                                                  "javax.naming.spi.NamingManager1",
-                                                                  "javax.naming.spi.NamingManager2");
-
-        new OutputAnalyzer(pb.start())
-            .shouldContain("I pass one!")
-            .shouldContain("I pass two!")
-            .shouldHaveExitValue(0);
-    }
-}
--- a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2016, 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 8069469
- * @summary Make sure -Xlog:classload=info works properly with "modules" jimage,
-            -Xpatch, and with -Xbootclasspath/a
- * @modules java.base/jdk.internal.misc
- * @library /testlibrary
- * @compile XpatchMain.java
- * @run main XpatchTraceCL
- */
-
-import java.io.File;
-import jdk.test.lib.*;
-
-public class XpatchTraceCL {
-
-    public static void main(String[] args) throws Exception {
-        String source = "package javax.naming.spi; "                +
-                        "public class NamingManager { "             +
-                        "    static { "                             +
-                        "        System.out.println(\"I pass!\"); " +
-                        "    } "                                    +
-                        "}";
-
-        // Test -Xlog:classload=info output for -Xpatch
-        ClassFileInstaller.writeClassToDisk("javax/naming/spi/NamingManager",
-             InMemoryJavaCompiler.compile("javax.naming.spi.NamingManager", source, "-Xmodule:java.naming"),
-             "mods/java.naming");
-
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming",
-             "-Xlog:class+load=info", "XpatchMain", "javax.naming.spi.NamingManager");
-
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        // "modules" jimage case.
-        output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base");
-        // -Xpatch case.
-        output.shouldContain("[class,load] javax.naming.spi.NamingManager source: mods/java.naming");
-        // -cp case.
-        output.shouldContain("[class,load] XpatchMain source: file");
-
-        // Test -Xlog:classload=info output for -Xbootclasspath/a
-        source = "package XpatchTraceCL_pkg; "                 +
-                 "public class ItIsI { "                          +
-                 "    static { "                                  +
-                 "        System.out.println(\"I also pass!\"); " +
-                 "    } "                                         +
-                 "}";
-
-        ClassFileInstaller.writeClassToDisk("XpatchTraceCL_pkg/ItIsI",
-             InMemoryJavaCompiler.compile("XpatchTraceCL_pkg.ItIsI", source),
-             "xbcp");
-
-        pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/a:xbcp",
-             "-Xlog:class+load=info", "XpatchMain", "XpatchTraceCL_pkg.ItIsI");
-        output = new OutputAnalyzer(pb.start());
-        // -Xbootclasspath/a case.
-        output.shouldContain("[class,load] XpatchTraceCL_pkg.ItIsI source: xbcp");
-        output.shouldHaveExitValue(0);
-    }
-}
--- a/hotspot/test/runtime/modules/XpatchCDS.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, 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
- * @library /testlibrary
- * @modules java.base/jdk.internal.misc
- * @run main XpatchCDS
- */
-
-import java.io.File;
-import jdk.test.lib.*;
-
-public class XpatchCDS {
-
-    public static void main(String args[]) throws Throwable {
-        System.out.println("Test that -Xpatch and -Xshare:dump are incompatibable");
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xpatch:java.naming=mods/java.naming", "-Xshare:dump");
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Cannot use the following option when dumping the shared archive: -Xpatch");
-
-        System.out.println("Test that -Xpatch and -Xshare:on are incompatibable");
-        String filename = "Xpatch.jsa";
-        pb = ProcessTools.createJavaProcessBuilder(
-            "-XX:+UnlockDiagnosticVMOptions",
-            "-XX:SharedArchiveFile=" + filename,
-            "-Xshare:dump");
-        output = new OutputAnalyzer(pb.start());
-        output.shouldContain("ro space:"); // Make sure archive got created.
-
-        pb = ProcessTools.createJavaProcessBuilder(
-            "-XX:+UnlockDiagnosticVMOptions",
-            "-XX:SharedArchiveFile=" + filename,
-            "-Xshare:on",
-            "-Xpatch:java.naming=mods/java.naming",
-            "-version");
-        output = new OutputAnalyzer(pb.start());
-        output.shouldContain("The shared archive file cannot be used with -Xpatch");
-
-        output.shouldHaveExitValue(1);
-    }
-}
--- a/hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/runtime/modules/java.base/java/lang/reflect/ModuleHelper.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -27,7 +27,7 @@
 
 /**
  * A helper class intended to be injected into java.lang.reflect using the
- * java -Xpatch option. The helper class provides access to package private
+ * java --patch-module option. The helper class provides access to package private
  * methods in java.lang.reflect.Module.
  */
 
--- a/hotspot/test/serviceability/sa/TestInstanceKlassSize.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/serviceability/sa/TestInstanceKlassSize.java	Fri Aug 19 12:17:32 2016 -0700
@@ -113,9 +113,10 @@
                                           };
             String[] toolArgs = {
                 "-XX:+UnlockDiagnosticVMOptions",
-                "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
-                "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
-                "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+                "--add-modules=jdk.hotspot.agent",
+                "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
+                "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
+                "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
                 "TestInstanceKlassSize",
                 Long.toString(app.getPid())
             };
--- a/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java	Fri Aug 19 12:17:32 2016 -0700
@@ -107,9 +107,10 @@
         // Grab the pid from the current java process and pass it
         String[] toolArgs = {
             "-XX:+UnlockDiagnosticVMOptions",
-            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
-            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
-            "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
+            "--add-modules=jdk.hotspot.agent",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
+            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
             "TestInstanceKlassSizeForInterface",
             Long.toString(ProcessTools.getProcessId())
         };
--- a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -87,7 +87,7 @@
             String expectedFormat) throws Exception, IOException,
             InterruptedException, FileNotFoundException {
         ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(
-                "-XaddExports:java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize));
+                "--add-exports=java.management/sun.management=ALL-UNNAMED", vmArgs, "JMapHProfLargeHeapProc", String.valueOf(heapSize));
         procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
         Process largeHeapProc = procBuilder.start();
 
--- a/hotspot/test/testlibrary/ctw/Makefile	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/testlibrary/ctw/Makefile	Fri Aug 19 12:17:32 2016 -0700
@@ -58,10 +58,10 @@
 
 ctw.jar: filelist wb.jar
 	@mkdir -p $(OUTPUT_DIR)
-	$(JAVAC) -XaddExports:java.base/jdk.internal.jimage=ALL-UNNAMED \
-		-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED \
-		-XaddExports:java.base/jdk.internal.reflect=ALL-UNNAMED \
-		-sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) -cp wb.jar @filelist
+	$(JAVAC) --add-exports java.base/jdk.internal.jimage=ALL-UNNAMED \
+		 --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
+		 --add-exports java.base/jdk.internal.reflect=ALL-UNNAMED \
+		 -sourcepath $(SRC_DIR) -d $(OUTPUT_DIR) -cp wb.jar @filelist
 	$(JAR) --create --file=$@ --main-class $(MAIN_CLASS) -C $(OUTPUT_DIR) .
 
 wb.jar: wb_filelist
--- a/hotspot/test/testlibrary/jittester/Makefile	Fri Aug 19 10:09:53 2016 -0400
+++ b/hotspot/test/testlibrary/jittester/Makefile	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, 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
@@ -95,10 +95,10 @@
 	@echo 'Main-Class: jdk.test.lib.jittester.Automatic' >> $(MANIFEST)
 
 compile_testlib: INIT
-	$(JAVAC) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR)
+	$(JAVAC) -XDignore.symbol.file --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint $(TESTLIBRARY_SRC_FILES) -d $(CLASSES_DIR)
 
 COMPILE: INIT filelist compile_testlib
-	$(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file -XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) @filelist
+	$(JAVAC) -cp $(CLASSES_DIR) -XDignore.symbol.file --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -Xlint -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) @filelist
 
 filelist: $(SRC_FILES)
 		@rm -f $@
@@ -109,7 +109,7 @@
 	$(shell if [ ! -d $(CLASSES_DIR) ]; then mkdir -p $(CLASSES_DIR); fi)
 
 install: clean_testbase testgroup testroot copytestlibrary JAR cleantmp
-	$(JAVA) -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS)
+	$(JAVA) --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED -ea -jar $(DIST_JAR) $(APPLICATION_ARGS)
 
 clean_testbase:
 	@rm -rf $(TESTBASE_DIR)
--- a/jaxp/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxp/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -373,3 +373,4 @@
 8a7681a9d70640ac7fbf05c28f53c1d51d8d00a1 jdk-9+128
 74241304e87b0d463391a8ecab40979b5af86dc2 jdk-9+129
 e66cdc2de6b02443911d386fc9217b0d824d0686 jdk-9+130
+874082a9b565a7092a40bfa934a6e3e3c3455a60 jdk-9+131
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/message.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xpath/regex/message.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -37,5 +37,3 @@
 parser.quantifier.3=Invalid quantifier. A digit or '}' is expected.
 parser.quantifier.4=Invalid quantifier. A min quantity must be <= a max quantity.
 parser.quantifier.5=Invalid quantifier. A quantity value overflow.
-null
-null
--- a/jaxp/test/TEST.ROOT	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxp/test/TEST.ROOT	Fri Aug 19 12:17:32 2016 -0700
@@ -23,4 +23,7 @@
 groups=TEST.groups
 
 # Minimum jtreg version
-requiredVersion=4.2 b02
+requiredVersion=4.2 b03
+
+# Use new module options
+useNewOptions=true
--- a/jaxp/test/javax/xml/jaxp/libs/jaxp/library/BasePolicy.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/BasePolicy.java	Fri Aug 19 12:17:32 2016 -0700
@@ -37,7 +37,7 @@
         try {
             JAXPPolicyManager.teardownPolicyManager();
         } catch (Exception e) {
-            throw new RuntimeException("Failed to teardonw the policy manager", e);
+            throw new RuntimeException("Failed to teardown the policy manager", e);
         }
     }
 
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java	Fri Aug 19 12:17:32 2016 -0700
@@ -28,10 +28,8 @@
 import static jaxp.library.JAXPTestUtilities.setSystemProperty;
 
 import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.StringReader;
-import java.net.SocketTimeoutException;
-
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.URIResolver;
@@ -52,7 +50,7 @@
 
 /*
  * @test
- * @bug 8158084 8162438 8162442
+ * @bug 8158084 8162438 8162442 8163535
  * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
  * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport2
  * @run testng/othervm catalog.CatalogSupport2
@@ -97,7 +95,7 @@
     /*
        Verifies the Catalog support on SAXParser.
     */
-    @Test(dataProvider = "data_SAXC", expectedExceptions = FileNotFoundException.class)
+    @Test(dataProvider = "data_SAXC", expectedExceptions = IOException.class)
     public void testSAXC(boolean setUseCatalog, boolean useCatalog, String catalog, String
             xml, MyHandler handler, String expected) throws Exception {
         testSAX(setUseCatalog, useCatalog, catalog, xml, handler, expected);
@@ -106,7 +104,7 @@
     /*
        Verifies the Catalog support on XMLReader.
     */
-    @Test(dataProvider = "data_SAXC", expectedExceptions = FileNotFoundException.class)
+    @Test(dataProvider = "data_SAXC", expectedExceptions = IOException.class)
     public void testXMLReaderC(boolean setUseCatalog, boolean useCatalog, String catalog,
             String xml, MyHandler handler, String expected) throws Exception {
         testXMLReader(setUseCatalog, useCatalog, catalog, xml, handler, expected);
@@ -124,7 +122,7 @@
     /*
        Verifies the Catalog support on DOM parser.
     */
-    @Test(dataProvider = "data_DOMC", expectedExceptions = {FileNotFoundException.class, SocketTimeoutException.class})
+    @Test(dataProvider = "data_DOMC", expectedExceptions = IOException.class)
     public void testDOMC(boolean setUseCatalog, boolean useCatalog, String catalog,
             String xml, MyHandler handler, String expected) throws Exception {
         testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected);
@@ -141,7 +139,7 @@
         testValidation(setUseCatalog, useCatalog, catalog, xsd, resolver) ;
     }
 
-    @Test(dataProvider = "data_ValidatorC", expectedExceptions = {SAXException.class, FileNotFoundException.class})
+    @Test(dataProvider = "data_ValidatorC", expectedExceptions = {SAXException.class, IOException.class})
     public void testValidatorC(boolean setUseCatalog1, boolean setUseCatalog2, boolean useCatalog,
             Source source, LSResourceResolver resolver1, LSResourceResolver resolver2,
             String catalog1, String catalog2)
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java	Fri Aug 19 12:17:32 2016 -0700
@@ -27,10 +27,8 @@
 import static jaxp.library.JAXPTestUtilities.setSystemProperty;
 
 import java.io.File;
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.StringReader;
-import java.net.SocketTimeoutException;
-
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.URIResolver;
@@ -51,7 +49,7 @@
 
 /*
  * @test
- * @bug 8158084 8162438 8162442
+ * @bug 8158084 8162438 8162442 8163535
  * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
  * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport3
  * @run testng/othervm catalog.CatalogSupport3
@@ -93,7 +91,7 @@
     /*
        Verifies the Catalog support on SAXParser.
     */
-    @Test(dataProvider = "data_SAXC", expectedExceptions = FileNotFoundException.class)
+    @Test(dataProvider = "data_SAXC", expectedExceptions = IOException.class)
     public void testSAXC(boolean setUseCatalog, boolean useCatalog, String catalog,
             String xml, MyHandler handler, String expected) throws Exception {
         testSAX(setUseCatalog, useCatalog, catalog, xml, handler, expected);
@@ -102,7 +100,7 @@
     /*
        Verifies the Catalog support on XMLReader.
     */
-    @Test(dataProvider = "data_SAXC", expectedExceptions = FileNotFoundException.class)
+    @Test(dataProvider = "data_SAXC", expectedExceptions = IOException.class)
     public void testXMLReaderC(boolean setUseCatalog, boolean useCatalog, String catalog,
             String xml, MyHandler handler, String expected) throws Exception {
         testXMLReader(setUseCatalog, useCatalog, catalog, xml, handler, expected);
@@ -120,7 +118,7 @@
     /*
        Verifies the Catalog support on DOM parser.
     */
-    @Test(dataProvider = "data_DOMC", expectedExceptions = {FileNotFoundException.class, SocketTimeoutException.class})
+    @Test(dataProvider = "data_DOMC", expectedExceptions = IOException.class)
     public void testDOMC(boolean setUseCatalog, boolean useCatalog, String catalog,
             String xml, MyHandler handler, String expected) throws Exception {
         testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected);
@@ -141,7 +139,7 @@
        @bug 8158084 8162438 these tests also verifies the fix for 8162438
        Verifies the Catalog support on the Schema Validator.
     */
-    @Test(dataProvider = "data_ValidatorC", expectedExceptions = {SAXException.class, FileNotFoundException.class})
+    @Test(dataProvider = "data_ValidatorC", expectedExceptions = {SAXException.class, IOException.class})
     public void testValidatorC(boolean setUseCatalog1, boolean setUseCatalog2, boolean useCatalog,
             Source source, LSResourceResolver resolver1, LSResourceResolver resolver2,
             String catalog1, String catalog2)
--- a/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxp/test/javax/xml/jaxp/unittest/validation/Bug6773084Test.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,11 +32,10 @@
 import java.util.concurrent.CyclicBarrier;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamSource;
@@ -69,6 +68,7 @@
     private static final ExecutorService EXEC = Executors.newCachedThreadPool();
 
     private static final CyclicBarrier BARRIER = new CyclicBarrier(NTHREADS);
+    private static final int TIMEOUT = 110;
 
     public static final String IN_FOLDER = Bug6773084Test.class.getResource("Bug6773084In").getPath();
     public static final String XSD_PATH = Bug6773084Test.class.getResource("Bug6773084.xsd").getPath();
@@ -93,20 +93,23 @@
             }
         });
 
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+
         for (int i = 0; i < files.length; i++) {
-            EXEC.execute(new XMLValiddator(files[i], i));
+            EXEC.execute(new XMLValiddator(dbf.newDocumentBuilder().parse(files[i]), i));
         }
         runWithAllPerm(() -> EXEC.shutdown());
-
+        EXEC.awaitTermination(TIMEOUT, TimeUnit.SECONDS);
     }
 
     private static class XMLValiddator implements Runnable {
 
-        private File file;
+        private Document document;
         private int index;
 
-        public XMLValiddator(File file, int index) {
-            this.file = file;
+        public XMLValiddator(Document document, int index) {
+            this.document = document;
             this.index = index;
         }
 
@@ -117,23 +120,14 @@
                 BARRIER.await();
                 System.out.println("Validating....");
 
-                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-                factory.setNamespaceAware(true);
-
-                DocumentBuilder builder = factory.newDocumentBuilder();
-                Document document = builder.parse(file);
-
                 Validator validator = schema.newValidator();
                 validator.setErrorHandler(new ErrorHandlerImpl());
                 validator.validate(new DOMSource(document));
-
             } catch (IOException e) {
                 e.printStackTrace();
             } catch (SAXException e) {
                 e.printStackTrace();
                 Assert.fail("Test failed.");
-            } catch (ParserConfigurationException e) {
-                e.printStackTrace();
             } catch (BrokenBarrierException e) {
                 e.printStackTrace();
             } catch (InterruptedException e) {
--- a/jaxws/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxws/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -376,3 +376,4 @@
 fe4e11bd2423635dc0f5f5cb9a64eb2f2cce7f4c jdk-9+128
 46a02f57218e4a8c334dbccf656fb048f823f163 jdk-9+129
 39c6293131d91aec7f2f5120395e070a937b8858 jdk-9+130
+783e7e2c587f2c7e1b9998a46d90ec196ab2a195 jdk-9+131
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java	Fri Aug 19 12:17:32 2016 -0700
@@ -140,7 +140,7 @@
         aptargs.add("-cp");
         aptargs.add(setClasspath(options.classpath)); // set original classpath + jaxb-api to be visible to annotation processor
 
-        aptargs.add("-addmods");
+        aptargs.add("--add-modules");
         aptargs.add("java.xml.bind");
 
         if(options.targetDir!=null) {
--- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java	Fri Aug 19 12:17:32 2016 -0700
@@ -162,7 +162,7 @@
         boolean bootCP = useBootClasspath(EndpointReference.class) || useBootClasspath(XmlSeeAlso.class);
         List<String> args = new ArrayList<String>(6 + (bootCP ? 1 : 0) + (options.nocompile ? 1 : 0)
                 + (options.encoding != null ? 2 : 0));
-        args.add("-addmods");
+        args.add("--add-modules");
         args.add("java.xml.ws");
         args.add("-d");
         args.add(options.destDir.getAbsolutePath());
--- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java	Fri Aug 19 12:17:32 2016 -0700
@@ -525,7 +525,7 @@
             String classpathString = createClasspathString();
             boolean bootCP = useBootClasspath(EndpointContext.class) || useBootClasspath(JAXBPermission.class);
             List<String> args = new ArrayList<String>();
-            args.add("-addmods");
+            args.add("--add-modules");
             args.add("java.xml.ws");
             args.add("-d");
             args.add(classDir);
--- a/jdk/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -374,3 +374,4 @@
 47699aa2e69ec2702542dc73eb01de3bfb61aea0 jdk-9+129
 6c827500e34587061af97ad6fef0e859280255c5 jdk-9+130
 8c57f4c293bbc5609928308a6d91ba765760b5f9 jdk-9+131
+d5c70818cd8a82e76632c8c815bdb4f75f53aeaf jdk-9+132
--- a/jdk/make/copy/Copy-java.base.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/make/copy/Copy-java.base.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -183,7 +183,7 @@
 
 DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC)
 
-ifeq ($(OPENJDK_TARGET_OS), windows)
+ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), )
   DEF_POLICY_SRC_LIST += $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy
 endif
 
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -107,7 +107,7 @@
             throw new InvalidKeySpecException("Key length is negative");
         }
         try {
-            this.prf = Mac.getInstance(prfAlgo, SunJCE.getInstance());
+            this.prf = Mac.getInstance(prfAlgo);
         } catch (NoSuchAlgorithmException nsae) {
             // not gonna happen; re-throw just in case
             InvalidKeySpecException ike = new InvalidKeySpecException();
--- a/jdk/src/java.base/share/classes/java/io/BufferedReader.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/BufferedReader.java	Fri Aug 19 12:17:32 2016 -0700
@@ -560,7 +560,7 @@
      * @since 1.8
      */
     public Stream<String> lines() {
-        Iterator<String> iter = new Iterator<String>() {
+        Iterator<String> iter = new Iterator<>() {
             String nextLine = null;
 
             @Override
--- a/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java	Fri Aug 19 12:17:32 2016 -0700
@@ -187,7 +187,7 @@
      * @return  the current contents of this output stream, as a byte array.
      * @see     java.io.ByteArrayOutputStream#size()
      */
-    public synchronized byte toByteArray()[] {
+    public synchronized byte[] toByteArray() {
         return Arrays.copyOf(buf, count);
     }
 
--- a/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -165,7 +165,7 @@
      *
      * @param  csq
      *         The character sequence to append.  If {@code csq} is
-     *         {@code null}, then the four characters "{@code null}" are
+     *         {@code null}, then the four characters {@code "null"} are
      *         appended to this writer.
      *
      * @return  This writer
@@ -173,7 +173,7 @@
      * @since  1.5
      */
     public CharArrayWriter append(CharSequence csq) {
-        String s = (csq == null ? "null" : csq.toString());
+        String s = String.valueOf(csq);
         write(s, 0, s.length());
         return this;
     }
@@ -193,7 +193,7 @@
      *         The character sequence from which a subsequence will be
      *         appended.  If {@code csq} is {@code null}, then characters
      *         will be appended as if {@code csq} contained the four
-     *         characters "{@code null}".
+     *         characters {@code "null"}.
      *
      * @param  start
      *         The index of the first character in the subsequence
@@ -212,9 +212,8 @@
      * @since  1.5
      */
     public CharArrayWriter append(CharSequence csq, int start, int end) {
-        String s = (csq == null ? "null" : csq).subSequence(start, end).toString();
-        write(s, 0, s.length());
-        return this;
+        if (csq == null) csq = "null";
+        return append(csq.subSequence(start, end));
     }
 
     /**
@@ -251,7 +250,7 @@
      *
      * @return an array of chars copied from the input data.
      */
-    public char toCharArray()[] {
+    public char[] toCharArray() {
         synchronized (lock) {
             return Arrays.copyOf(buf, count);
         }
--- a/jdk/src/java.base/share/classes/java/io/FileSystem.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/FileSystem.java	Fri Aug 19 12:17:32 2016 -0700
@@ -228,13 +228,8 @@
     static boolean useCanonPrefixCache = true;
 
     private static boolean getBooleanProperty(String prop, boolean defaultVal) {
-        String val = System.getProperty(prop);
-        if (val == null) return defaultVal;
-        if (val.equalsIgnoreCase("true")) {
-            return true;
-        } else {
-            return false;
-        }
+        return Boolean.parseBoolean(System.getProperty(prop,
+                String.valueOf(defaultVal)));
     }
 
     static {
--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1265,22 +1265,21 @@
         WeakClassKey key = new WeakClassKey(cl, Caches.subclassAuditsQueue);
         Boolean result = Caches.subclassAudits.get(key);
         if (result == null) {
-            result = Boolean.valueOf(auditSubclass(cl));
+            result = auditSubclass(cl);
             Caches.subclassAudits.putIfAbsent(key, result);
         }
-        if (result.booleanValue()) {
-            return;
+        if (!result) {
+            sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
         }
-        sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
     }
 
     /**
      * Performs reflective checks on given subclass to verify that it doesn't
-     * override security-sensitive non-final methods.  Returns true if subclass
-     * is "safe", false otherwise.
+     * override security-sensitive non-final methods.  Returns TRUE if subclass
+     * is "safe", FALSE otherwise.
      */
-    private static boolean auditSubclass(final Class<?> subcl) {
-        Boolean result = AccessController.doPrivileged(
+    private static Boolean auditSubclass(Class<?> subcl) {
+        return AccessController.doPrivileged(
             new PrivilegedAction<>() {
                 public Boolean run() {
                     for (Class<?> cl = subcl;
@@ -1303,7 +1302,6 @@
                 }
             }
         );
-        return result.booleanValue();
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1050,22 +1050,21 @@
         WeakClassKey key = new WeakClassKey(cl, Caches.subclassAuditsQueue);
         Boolean result = Caches.subclassAudits.get(key);
         if (result == null) {
-            result = Boolean.valueOf(auditSubclass(cl));
+            result = auditSubclass(cl);
             Caches.subclassAudits.putIfAbsent(key, result);
         }
-        if (result.booleanValue()) {
-            return;
+        if (!result) {
+            sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
         }
-        sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
     }
 
     /**
      * Performs reflective checks on given subclass to verify that it doesn't
-     * override security-sensitive non-final methods.  Returns true if subclass
-     * is "safe", false otherwise.
+     * override security-sensitive non-final methods.  Returns TRUE if subclass
+     * is "safe", FALSE otherwise.
      */
-    private static boolean auditSubclass(final Class<?> subcl) {
-        Boolean result = AccessController.doPrivileged(
+    private static Boolean auditSubclass(Class<?> subcl) {
+        return AccessController.doPrivileged(
             new PrivilegedAction<>() {
                 public Boolean run() {
                     for (Class<?> cl = subcl;
@@ -1088,7 +1087,6 @@
                 }
             }
         );
-        return result.booleanValue();
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/ObjectStreamClass.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1509,11 +1509,9 @@
     private static String getPackageName(Class<?> cl) {
         String s = cl.getName();
         int i = s.lastIndexOf('[');
-        if (i >= 0) {
-            s = s.substring(i + 2);
-        }
-        i = s.lastIndexOf('.');
-        return (i >= 0) ? s.substring(0, i) : "";
+        i = (i < 0) ? 0 : i + 2;
+        int j = s.lastIndexOf('.');
+        return (i < j) ? s.substring(i, j) : "";
     }
 
     /**
@@ -1535,14 +1533,14 @@
     private static String getMethodSignature(Class<?>[] paramTypes,
                                              Class<?> retType)
     {
-        StringBuilder sbuf = new StringBuilder();
-        sbuf.append('(');
+        StringBuilder sb = new StringBuilder();
+        sb.append('(');
         for (int i = 0; i < paramTypes.length; i++) {
-            appendClassSignature(sbuf, paramTypes[i]);
+            appendClassSignature(sb, paramTypes[i]);
         }
-        sbuf.append(')');
-        appendClassSignature(sbuf, retType);
-        return sbuf.toString();
+        sb.append(')');
+        appendClassSignature(sb, retType);
+        return sb.toString();
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -233,22 +233,16 @@
 
     @Override
     public Writer append(CharSequence csq, int start, int end) throws IOException {
-        if (csq == null) {
-            write("null".subSequence(start, end).toString());
-            return this;
-        } else {
-            return append(csq.subSequence(start, end));
-        }
+        if (csq == null) csq = "null";
+        return append(csq.subSequence(start, end));
     }
 
     @Override
     public Writer append(CharSequence csq) throws IOException {
-        if (csq == null) {
-            se.write("null");
-        } else if (csq instanceof CharBuffer) {
+        if (csq instanceof CharBuffer) {
             se.write((CharBuffer) csq);
         } else {
-            se.write(csq.toString());
+            se.write(String.valueOf(csq));
         }
         return this;
     }
--- a/jdk/src/java.base/share/classes/java/io/PrintStream.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/PrintStream.java	Fri Aug 19 12:17:32 2016 -0700
@@ -568,7 +568,7 @@
      * @param      b   The {@code boolean} to be printed
      */
     public void print(boolean b) {
-        write(b ? "true" : "false");
+        write(String.valueOf(b));
     }
 
     /**
@@ -663,10 +663,7 @@
      * @param      s   The {@code String} to be printed
      */
     public void print(String s) {
-        if (s == null) {
-            s = "null";
-        }
-        write(s);
+        write(String.valueOf(s));
     }
 
     /**
@@ -1068,10 +1065,7 @@
      * @since  1.5
      */
     public PrintStream append(CharSequence csq) {
-        if (csq == null)
-            print("null");
-        else
-            print(csq.toString());
+        print(String.valueOf(csq));
         return this;
     }
 
@@ -1111,9 +1105,8 @@
      * @since  1.5
      */
     public PrintStream append(CharSequence csq, int start, int end) {
-        CharSequence cs = (csq == null ? "null" : csq);
-        write(cs.subSequence(start, end).toString());
-        return this;
+        if (csq == null) csq = "null";
+        return append(csq.subSequence(start, end));
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/PrintWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/PrintWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -504,7 +504,7 @@
      * @param      b   The {@code boolean} to be printed
      */
     public void print(boolean b) {
-        write(b ? "true" : "false");
+        write(String.valueOf(b));
     }
 
     /**
@@ -599,10 +599,7 @@
      * @param      s   The {@code String} to be printed
      */
     public void print(String s) {
-        if (s == null) {
-            s = "null";
-        }
-        write(s);
+        write(String.valueOf(s));
     }
 
     /**
@@ -1005,10 +1002,7 @@
      * @since  1.5
      */
     public PrintWriter append(CharSequence csq) {
-        if (csq == null)
-            write("null");
-        else
-            write(csq.toString());
+        write(String.valueOf(csq));
         return this;
     }
 
@@ -1047,9 +1041,8 @@
      * @since  1.5
      */
     public PrintWriter append(CharSequence csq, int start, int end) {
-        CharSequence cs = (csq == null ? "null" : csq);
-        write(cs.subSequence(start, end).toString());
-        return this;
+        if (csq == null) csq = "null";
+        return append(csq.subSequence(start, end));
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/SequenceInputStream.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/SequenceInputStream.java	Fri Aug 19 12:17:32 2016 -0700
@@ -65,12 +65,7 @@
      */
     public SequenceInputStream(Enumeration<? extends InputStream> e) {
         this.e = e;
-        try {
-            nextStream();
-        } catch (IOException ex) {
-            // This should never happen
-            throw new Error("panic");
-        }
+        peekNextStream();
     }
 
     /**
@@ -86,16 +81,10 @@
      */
     public SequenceInputStream(InputStream s1, InputStream s2) {
         Vector<InputStream> v = new Vector<>(2);
-
         v.addElement(s1);
         v.addElement(s2);
         e = v.elements();
-        try {
-            nextStream();
-        } catch (IOException ex) {
-            // This should never happen
-            throw new Error("panic");
-        }
+        peekNextStream();
     }
 
     /**
@@ -105,14 +94,17 @@
         if (in != null) {
             in.close();
         }
+        peekNextStream();
+    }
 
+    private void peekNextStream() {
         if (e.hasMoreElements()) {
             in = (InputStream) e.nextElement();
             if (in == null)
                 throw new NullPointerException();
+        } else {
+            in = null;
         }
-        else in = null;
-
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/StringBufferInputStream.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/StringBufferInputStream.java	Fri Aug 19 12:17:32 2016 -0700
@@ -108,6 +108,7 @@
      *             <code>-1</code> if there is no more data because the end of
      *             the stream has been reached.
      */
+    @SuppressWarnings("deprecation")
     public synchronized int read(byte b[], int off, int len) {
         if (b == null) {
             throw new NullPointerException();
@@ -126,12 +127,8 @@
         if (len <= 0) {
             return 0;
         }
-        String  s = buffer;
-        int cnt = len;
-        while (--cnt >= 0) {
-            b[off++] = (byte)s.charAt(pos++);
-        }
-
+        buffer.getBytes(pos, pos + len, b, off);
+        pos += len;
         return len;
     }
 
--- a/jdk/src/java.base/share/classes/java/io/StringReader.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/StringReader.java	Fri Aug 19 12:17:32 2016 -0700
@@ -142,8 +142,8 @@
      */
     public boolean ready() throws IOException {
         synchronized (lock) {
-        ensureOpen();
-        return true;
+            ensureOpen();
+            return true;
         }
     }
 
--- a/jdk/src/java.base/share/classes/java/io/StringWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/StringWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -139,7 +139,7 @@
      *
      * @param  csq
      *         The character sequence to append.  If {@code csq} is
-     *         {@code null}, then the four characters "{@code null}" are
+     *         {@code null}, then the four characters {@code "null"} are
      *         appended to this writer.
      *
      * @return  This writer
@@ -147,10 +147,7 @@
      * @since  1.5
      */
     public StringWriter append(CharSequence csq) {
-        if (csq == null)
-            write("null");
-        else
-            write(csq.toString());
+        write(String.valueOf(csq));
         return this;
     }
 
@@ -170,7 +167,7 @@
      *         The character sequence from which a subsequence will be
      *         appended.  If {@code csq} is {@code null}, then characters
      *         will be appended as if {@code csq} contained the four
-     *         characters "{@code null}".
+     *         characters {@code "null"}.
      *
      * @param  start
      *         The index of the first character in the subsequence
@@ -189,9 +186,8 @@
      * @since  1.5
      */
     public StringWriter append(CharSequence csq, int start, int end) {
-        CharSequence cs = (csq == null ? "null" : csq);
-        write(cs.subSequence(start, end).toString());
-        return this;
+        if (csq == null) csq = "null";
+        return append(csq.subSequence(start, end));
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/io/Writer.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/io/Writer.java	Fri Aug 19 12:17:32 2016 -0700
@@ -221,7 +221,7 @@
      *
      * @param  csq
      *         The character sequence to append.  If {@code csq} is
-     *         {@code null}, then the four characters "{@code null}" are
+     *         {@code null}, then the four characters {@code "null"} are
      *         appended to this writer.
      *
      * @return  This writer
@@ -232,10 +232,7 @@
      * @since  1.5
      */
     public Writer append(CharSequence csq) throws IOException {
-        if (csq == null)
-            write("null");
-        else
-            write(csq.toString());
+        write(String.valueOf(csq));
         return this;
     }
 
@@ -256,7 +253,7 @@
      *         The character sequence from which a subsequence will be
      *         appended.  If {@code csq} is {@code null}, then characters
      *         will be appended as if {@code csq} contained the four
-     *         characters "{@code null}".
+     *         characters {@code "null"}.
      *
      * @param  start
      *         The index of the first character in the subsequence
@@ -278,9 +275,8 @@
      * @since  1.5
      */
     public Writer append(CharSequence csq, int start, int end) throws IOException {
-        CharSequence cs = (csq == null ? "null" : csq);
-        write(cs.subSequence(start, end).toString());
-        return this;
+        if (csq == null) csq = "null";
+        return append(csq.subSequence(start, end));
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Fri Aug 19 12:17:32 2016 -0700
@@ -36,7 +36,6 @@
 import java.lang.invoke.LambdaForm.NamedFunction;
 import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.reflect.Field;
-import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.function.Function;
@@ -308,7 +307,7 @@
         /*non-public*/ char fieldTypeChar(int i) {
             return typeChars.charAt(i);
         }
-        Object fieldSignature() {
+        String fieldSignature() {
             return typeChars;
         }
         public Class<? extends BoundMethodHandle> fieldHolder() {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java	Fri Aug 19 12:17:32 2016 -0700
@@ -27,6 +27,7 @@
 
 import java.util.Arrays;
 import static java.lang.invoke.LambdaForm.*;
+import static java.lang.invoke.LambdaForm.Kind.*;
 import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
@@ -96,14 +97,8 @@
                                         int whichCache,
                                         Object constraint,
                                         NamedFunction getTargetFn) {
-        String debugString;
-        switch(whichCache) {
-            case MethodTypeForm.LF_REBIND:            debugString = "BMH.reinvoke";      break;
-            case MethodTypeForm.LF_DELEGATE:          debugString = "MH.delegate";       break;
-            default:                                  debugString = "MH.reinvoke";       break;
-        }
         // No pre-action needed.
-        return makeReinvokerForm(target, whichCache, constraint, debugString, true, getTargetFn, null);
+        return makeReinvokerForm(target, whichCache, constraint, null, true, getTargetFn, null);
     }
     /** Create a LF which simply reinvokes a target of the given basic type. */
     static LambdaForm makeReinvokerForm(MethodHandle target,
@@ -114,6 +109,10 @@
                                         NamedFunction getTargetFn,
                                         NamedFunction preActionFn) {
         MethodType mtype = target.type().basicType();
+        Kind kind = whichKind(whichCache);
+        if (debugString == null) {
+            debugString = kind.defaultLambdaName;
+        }
         boolean customized = (whichCache < 0 ||
                 mtype.parameterSlotCount() > MethodType.MAX_MH_INVOKER_ARITY);
         boolean hasPreAction = (preActionFn != null);
@@ -145,13 +144,21 @@
             targetArgs[0] = names[NEXT_MH];  // overwrite this MH with next MH
             names[REINVOKE] = new LambdaForm.Name(mtype, targetArgs);
         }
-        form = new LambdaForm(debugString, ARG_LIMIT, names, forceInline);
+        form = new LambdaForm(debugString, ARG_LIMIT, names, forceInline, kind);
         if (!customized) {
             form = mtype.form().setCachedLambdaForm(whichCache, form);
         }
         return form;
     }
 
+    private static Kind whichKind(int whichCache) {
+        switch(whichCache) {
+            case MethodTypeForm.LF_REBIND:   return BOUND_REINVOKER;
+            case MethodTypeForm.LF_DELEGATE: return DELEGATE;
+            default:                         return REINVOKER;
+        }
+    }
+
     static final NamedFunction NF_getTarget;
     static {
         try {
@@ -160,5 +167,13 @@
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
+        // The Holder class will contain pre-generated DelegatingMethodHandles resolved
+        // speculatively using MemberName.getFactory().resolveOrNull. However, that
+        // doesn't initialize the class, which subtly breaks inlining etc. By forcing
+        // initialization of the Holder class we avoid these issues.
+        UNSAFE.ensureClassInitialized(Holder.class);
     }
+
+    /* Placeholder class for DelegatingMethodHandles generated ahead of time */
+    final class Holder {}
 }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Fri Aug 19 12:17:32 2016 -0700
@@ -38,6 +38,7 @@
 import java.util.Objects;
 
 import static java.lang.invoke.LambdaForm.*;
+import static java.lang.invoke.LambdaForm.Kind.*;
 import static java.lang.invoke.MethodHandleNatives.Constants.*;
 import static java.lang.invoke.MethodHandleStatics.UNSAFE;
 import static java.lang.invoke.MethodHandleStatics.newInternalError;
@@ -189,14 +190,15 @@
     static LambdaForm makePreparedLambdaForm(MethodType mtype, int which) {
         boolean needsInit = (which == LF_INVSTATIC_INIT);
         boolean doesAlloc = (which == LF_NEWINVSPECIAL);
-        String linkerName, lambdaName;
+        String linkerName;
+        LambdaForm.Kind kind;
         switch (which) {
-        case LF_INVVIRTUAL:    linkerName = "linkToVirtual";    lambdaName = "DMH.invokeVirtual";    break;
-        case LF_INVSTATIC:     linkerName = "linkToStatic";     lambdaName = "DMH.invokeStatic";     break;
-        case LF_INVSTATIC_INIT:linkerName = "linkToStatic";     lambdaName = "DMH.invokeStaticInit"; break;
-        case LF_INVSPECIAL:    linkerName = "linkToSpecial";    lambdaName = "DMH.invokeSpecial";    break;
-        case LF_INVINTERFACE:  linkerName = "linkToInterface";  lambdaName = "DMH.invokeInterface";  break;
-        case LF_NEWINVSPECIAL: linkerName = "linkToSpecial";    lambdaName = "DMH.newInvokeSpecial"; break;
+        case LF_INVVIRTUAL:    linkerName = "linkToVirtual";   kind = DIRECT_INVOKE_VIRTUAL;     break;
+        case LF_INVSTATIC:     linkerName = "linkToStatic";    kind = DIRECT_INVOKE_STATIC;      break;
+        case LF_INVSTATIC_INIT:linkerName = "linkToStatic";    kind = DIRECT_INVOKE_STATIC_INIT; break;
+        case LF_INVSPECIAL:    linkerName = "linkToSpecial";   kind = DIRECT_INVOKE_SPECIAL;     break;
+        case LF_INVINTERFACE:  linkerName = "linkToInterface"; kind = DIRECT_INVOKE_INTERFACE;   break;
+        case LF_NEWINVSPECIAL: linkerName = "linkToSpecial";   kind = DIRECT_NEW_INVOKE_SPECIAL; break;
         default:  throw new InternalError("which="+which);
         }
 
@@ -240,11 +242,11 @@
             result = NEW_OBJ;
         }
         names[LINKER_CALL] = new Name(linker, outArgs);
-        lambdaName += "_" + shortenSignature(basicTypeSignature(mtype));
-        LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result);
+        String lambdaName = kind.defaultLambdaName + "_" + shortenSignature(basicTypeSignature(mtype));
+        LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result, kind);
 
         // This is a tricky bit of code.  Don't send it through the LF interpreter.
-        lform.compileToBytecode(Holder.class);
+        lform.compileToBytecode();
         return lform;
     }
 
@@ -705,7 +707,7 @@
     }
 
     static {
-        // The DMH class will contain pre-generated DirectMethodHandles resolved
+        // The Holder class will contain pre-generated DirectMethodHandles resolved
         // speculatively using MemberName.getFactory().resolveOrNull. However, that
         // doesn't initialize the class, which subtly breaks inlining etc. By forcing
         // initialization of the Holder class we avoid these issues.
@@ -713,5 +715,5 @@
     }
 
     /* Placeholder class for DirectMethodHandles generated ahead of time */
-    private final class Holder {}
+    final class Holder {}
 }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java	Fri Aug 19 12:17:32 2016 -0700
@@ -29,21 +29,56 @@
 import jdk.internal.org.objectweb.asm.ClassWriter;
 import jdk.internal.org.objectweb.asm.Opcodes;
 
+import java.util.ArrayList;
+import java.util.HashSet;
+
 /**
  * Helper class to assist the GenerateJLIClassesPlugin to get access to
  * generate classes ahead of time.
  */
 class GenerateJLIClassesHelper {
 
-    static byte[] generateDMHClassBytes(String className,
+    static byte[] generateDirectMethodHandleHolderClassBytes(String className,
             MethodType[] methodTypes, int[] types) {
         LambdaForm[] forms = new LambdaForm[methodTypes.length];
+        String[] names = new String[methodTypes.length];
         for (int i = 0; i < forms.length; i++) {
             forms[i] = DirectMethodHandle.makePreparedLambdaForm(methodTypes[i],
                                                                  types[i]);
-            methodTypes[i] = forms[i].methodType();
+            names[i] = forms[i].kind.defaultLambdaName;
         }
-        return generateCodeBytesForLFs(className, forms, methodTypes);
+        return generateCodeBytesForLFs(className, names, forms);
+    }
+
+    static byte[] generateDelegatingMethodHandleHolderClassBytes(String className,
+            MethodType[] methodTypes) {
+
+        HashSet<MethodType> dedupSet = new HashSet<>();
+        ArrayList<LambdaForm> forms = new ArrayList<>();
+        ArrayList<String> names = new ArrayList<>();
+        for (int i = 0; i < methodTypes.length; i++) {
+            // generate methods representing the DelegatingMethodHandle
+            if (dedupSet.add(methodTypes[i])) {
+                // reinvokers are variant with the associated SpeciesData
+                // and shape of the target LF, but we can easily pregenerate
+                // the basic reinvokers associated with Species_L. Ultimately we
+                // may want to consider pregenerating more of these, which will
+                // require an even more complex naming scheme
+                LambdaForm reinvoker = makeReinvokerFor(methodTypes[i]);
+                forms.add(reinvoker);
+                String speciesSig = BoundMethodHandle
+                        .speciesData(reinvoker).fieldSignature();
+                assert(speciesSig.equals("L"));
+                names.add(reinvoker.kind.defaultLambdaName + "_" + speciesSig);
+
+                LambdaForm delegate = makeDelegateFor(methodTypes[i]);
+                forms.add(delegate);
+                names.add(delegate.kind.defaultLambdaName);
+            }
+        }
+        return generateCodeBytesForLFs(className,
+                names.toArray(new String[0]),
+                forms.toArray(new LambdaForm[0]));
     }
 
     /*
@@ -51,22 +86,45 @@
      * a class with a specified name.
      */
     private static byte[] generateCodeBytesForLFs(String className,
-            LambdaForm[] forms, MethodType[] types) {
-        assert(forms.length == types.length);
+            String[] names, LambdaForm[] forms) {
 
         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
         cw.visit(Opcodes.V1_8, Opcodes.ACC_PRIVATE + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER,
                 className, null, InvokerBytecodeGenerator.INVOKER_SUPER_NAME, null);
         cw.visitSource(className.substring(className.lastIndexOf('/') + 1), null);
+
         for (int i = 0; i < forms.length; i++) {
-            InvokerBytecodeGenerator g
-                    = new InvokerBytecodeGenerator(className, forms[i], types[i]);
-            g.setClassWriter(cw);
-            g.addMethod();
+            addMethod(className, names[i], forms[i],
+                    forms[i].methodType(), cw);
         }
         return cw.toByteArray();
     }
 
+    private static void addMethod(String className, String methodName, LambdaForm form,
+            MethodType type, ClassWriter cw) {
+        InvokerBytecodeGenerator g
+                = new InvokerBytecodeGenerator(className, methodName, form, type);
+        g.setClassWriter(cw);
+        g.addMethod();
+    }
+
+    private static LambdaForm makeReinvokerFor(MethodType type) {
+        MethodHandle emptyHandle = MethodHandles.empty(type);
+        return DelegatingMethodHandle.makeReinvokerForm(emptyHandle,
+                MethodTypeForm.LF_REBIND,
+                BoundMethodHandle.speciesData_L(),
+                BoundMethodHandle.speciesData_L().getterFunction(0));
+    }
+
+    private static LambdaForm makeDelegateFor(MethodType type) {
+        MethodHandle handle = MethodHandles.empty(type);
+        return DelegatingMethodHandle.makeReinvokerForm(
+                handle,
+                MethodTypeForm.LF_DELEGATE,
+                DelegatingMethodHandle.class,
+                DelegatingMethodHandle.NF_getTarget);
+    }
+
     static Map.Entry<String, byte[]> generateConcreteBMHClassBytes(
             final String types) {
         for (char c : types.toCharArray()) {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Fri Aug 19 12:17:32 2016 -0700
@@ -46,6 +46,7 @@
 
 import static java.lang.invoke.LambdaForm.*;
 import static java.lang.invoke.LambdaForm.BasicType.*;
+import static java.lang.invoke.LambdaForm.Kind.*;
 import static java.lang.invoke.MethodHandleNatives.Constants.*;
 import static java.lang.invoke.MethodHandleStatics.*;
 
@@ -125,9 +126,15 @@
     }
 
     /** For generating customized code for a single LambdaForm. */
-    InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) {
+    private InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) {
+        this(className, form.debugName, form, invokerType);
+    }
+
+    /** For generating customized code for a single LambdaForm. */
+    InvokerBytecodeGenerator(String className, String invokerName,
+            LambdaForm form, MethodType invokerType) {
         this(form, form.names.length,
-             className, form.debugName, invokerType);
+             className, invokerName, invokerType);
         // Create an array to map name indexes to locals indexes.
         Name[] names = form.names;
         for (int i = 0, index = 0; i < localsMap.length; i++) {
@@ -597,10 +604,42 @@
         return c.getName().replace('.', '/');
     }
 
+    private static MemberName resolveFrom(String name, MethodType type, Class<?> holder) {
+        MemberName member = new MemberName(holder, name, type, REF_invokeStatic);
+        MemberName resolvedMember = MemberName.getFactory().resolveOrNull(REF_invokeStatic, member, holder);
+
+        return resolvedMember;
+    }
+
+    private static MemberName lookupPregenerated(LambdaForm form) {
+        if (form.customized != null) {
+            // No pre-generated version for customized LF
+            return null;
+        }
+        MethodType invokerType = form.methodType();
+        String name = form.kind.methodName;
+        switch (form.kind) {
+            case BOUND_REINVOKER: {
+                name = name + "_" + BoundMethodHandle.speciesData(form).fieldSignature();
+                return resolveFrom(name, invokerType, DelegatingMethodHandle.Holder.class);
+            }
+            case DELEGATE:                  return resolveFrom(name, invokerType, DelegatingMethodHandle.Holder.class);
+            case DIRECT_INVOKE_INTERFACE:   // fall-through
+            case DIRECT_INVOKE_SPECIAL:     // fall-through
+            case DIRECT_INVOKE_STATIC:      // fall-through
+            case DIRECT_INVOKE_STATIC_INIT: // fall-through
+            case DIRECT_INVOKE_VIRTUAL:     return resolveFrom(name, invokerType, DirectMethodHandle.Holder.class);
+        }
+        return null;
+    }
+
     /**
      * Generate customized bytecode for a given LambdaForm.
      */
     static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType) {
+        MemberName pregenerated = lookupPregenerated(form);
+        if (pregenerated != null)  return pregenerated; // pre-generated bytecode
+
         InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("MH", form, invokerType);
         return g.loadMethod(g.generateCustomizedCodeBytes());
     }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Fri Aug 19 12:17:32 2016 -0700
@@ -41,6 +41,7 @@
 import static java.lang.invoke.LambdaForm.BasicType.*;
 import static java.lang.invoke.MethodHandleNatives.Constants.REF_invokeStatic;
 import static java.lang.invoke.MethodHandleStatics.*;
+import java.util.Objects;
 
 /**
  * The symbolic, non-executable form of a method handle's invocation semantics.
@@ -127,6 +128,7 @@
     final MethodHandle customized;
     @Stable final Name[] names;
     final String debugName;
+    final Kind kind;
     MemberName vmentry;   // low-level behavior, or null if not yet prepared
     private boolean isCompiled;
 
@@ -266,12 +268,46 @@
         }
     }
 
+    enum Kind {
+        GENERIC(""),
+        BOUND_REINVOKER("BMH.reinvoke"),
+        REINVOKER("MH.reinvoke"),
+        DELEGATE("MH.delegate"),
+        DIRECT_INVOKE_VIRTUAL("DMH.invokeVirtual"),
+        DIRECT_INVOKE_SPECIAL("DMH.invokeSpecial"),
+        DIRECT_INVOKE_STATIC("DMH.invokeStatic"),
+        DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial"),
+        DIRECT_INVOKE_INTERFACE("DMH.invokeInterface"),
+        DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit");
+
+        final String defaultLambdaName;
+        final String methodName;
+
+        private Kind(String defaultLambdaName) {
+            this.defaultLambdaName = defaultLambdaName;
+            int p = defaultLambdaName.indexOf('.');
+            if (p > -1) {
+                this.methodName = defaultLambdaName.substring(p + 1);
+            } else {
+                this.methodName = defaultLambdaName;
+            }
+        }
+    }
+
     LambdaForm(String debugName,
                int arity, Name[] names, int result) {
-        this(debugName, arity, names, result, /*forceInline=*/true, /*customized=*/null);
+        this(debugName, arity, names, result, /*forceInline=*/true, /*customized=*/null, Kind.GENERIC);
+    }
+    LambdaForm(String debugName,
+               int arity, Name[] names, int result, Kind kind) {
+        this(debugName, arity, names, result, /*forceInline=*/true, /*customized=*/null, kind);
     }
     LambdaForm(String debugName,
                int arity, Name[] names, int result, boolean forceInline, MethodHandle customized) {
+        this(debugName, arity, names, result, forceInline, customized, Kind.GENERIC);
+    }
+    LambdaForm(String debugName,
+               int arity, Name[] names, int result, boolean forceInline, MethodHandle customized, Kind kind) {
         assert(namesOK(arity, names));
         this.arity = arity;
         this.result = fixResult(result, names);
@@ -279,6 +315,7 @@
         this.debugName = fixDebugName(debugName);
         this.forceInline = forceInline;
         this.customized = customized;
+        this.kind = kind;
         int maxOutArity = normalize();
         if (maxOutArity > MethodType.MAX_MH_INVOKER_ARITY) {
             // Cannot use LF interpreter on very high arity expressions.
@@ -288,11 +325,15 @@
     }
     LambdaForm(String debugName,
                int arity, Name[] names) {
-        this(debugName, arity, names, LAST_RESULT, /*forceInline=*/true, /*customized=*/null);
+        this(debugName, arity, names, LAST_RESULT, /*forceInline=*/true, /*customized=*/null, Kind.GENERIC);
     }
     LambdaForm(String debugName,
                int arity, Name[] names, boolean forceInline) {
-        this(debugName, arity, names, LAST_RESULT, forceInline, /*customized=*/null);
+        this(debugName, arity, names, LAST_RESULT, forceInline, /*customized=*/null, Kind.GENERIC);
+    }
+    LambdaForm(String debugName,
+               int arity, Name[] names, boolean forceInline, Kind kind) {
+        this(debugName, arity, names, LAST_RESULT, forceInline, /*customized=*/null, kind);
     }
     LambdaForm(String debugName,
                Name[] formals, Name[] temps, Name result) {
@@ -325,6 +366,7 @@
         this.debugName = "LF.zero";
         this.forceInline = true;
         this.customized = null;
+        this.kind = Kind.GENERIC;
         assert(nameRefsAreLegal());
         assert(isEmpty());
         String sig = null;
@@ -395,7 +437,7 @@
 
     /** Customize LambdaForm for a particular MethodHandle */
     LambdaForm customize(MethodHandle mh) {
-        LambdaForm customForm = new LambdaForm(debugName, arity, names, result, forceInline, mh);
+        LambdaForm customForm = new LambdaForm(debugName, arity, names, result, forceInline, mh, kind);
         if (COMPILE_THRESHOLD >= 0 && isCompiled) {
             // If shared LambdaForm has been compiled, compile customized version as well.
             customForm.compileToBytecode();
@@ -773,28 +815,6 @@
         }
     }
 
-    /**
-     * Generate optimizable bytecode for this form after first looking for a
-     * pregenerated version in a specified class.
-     */
-    void compileToBytecode(Class<?> lookupClass) {
-        if (vmentry != null && isCompiled) {
-            return;  // already compiled somehow
-        }
-        MethodType invokerType = methodType();
-        assert(vmentry == null || vmentry.getMethodType().basicType().equals(invokerType));
-        int dot = debugName.indexOf('.');
-        String methodName = (dot > 0) ? debugName.substring(dot + 1) : debugName;
-        MemberName member = new MemberName(lookupClass, methodName, invokerType, REF_invokeStatic);
-        MemberName resolvedMember = MemberName.getFactory().resolveOrNull(REF_invokeStatic, member, lookupClass);
-        if (resolvedMember != null) {
-            vmentry = resolvedMember;
-            isCompiled = true;
-        } else {
-            compileToBytecode();
-        }
-    }
-
     private static void computeInitialPreparedForms() {
         // Find all predefined invokers and associate them with canonical empty lambda forms.
         for (MemberName m : MemberName.getFactory().getMethods(LambdaForm.class, false, null, null, null)) {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1718,10 +1718,19 @@
             }
 
             @Override
-            public byte[] generateDMHClassBytes(String className,
-            MethodType[] methodTypes, int[] types) {
+            public byte[] generateDirectMethodHandleHolderClassBytes(
+                    String className, MethodType[] methodTypes, int[] types) {
                 return GenerateJLIClassesHelper
-                        .generateDMHClassBytes(className, methodTypes, types);
+                        .generateDirectMethodHandleHolderClassBytes(
+                                className, methodTypes, types);
+            }
+
+            @Override
+            public byte[] generateDelegatingMethodHandleHolderClassBytes(
+                    String className, MethodType[] methodTypes) {
+                return GenerateJLIClassesHelper
+                        .generateDelegatingMethodHandleHolderClassBytes(
+                                className, methodTypes);
             }
 
             @Override
--- a/jdk/src/java.base/share/classes/java/security/Provider.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/security/Provider.java	Fri Aug 19 12:17:32 2016 -0700
@@ -601,7 +601,7 @@
     public synchronized Object compute(Object key, BiFunction<? super Object,
             ? super Object, ? extends Object> remappingFunction) {
         check("putProviderProperty." + name);
-        check("removeProviderProperty" + name);
+        check("removeProviderProperty." + name);
 
         if (debug != null) {
             debug.println("Compute " + name + " provider property " + key);
@@ -632,7 +632,7 @@
     public synchronized Object computeIfAbsent(Object key, Function<? super Object,
             ? extends Object> mappingFunction) {
         check("putProviderProperty." + name);
-        check("removeProviderProperty" + name);
+        check("removeProviderProperty." + name);
 
         if (debug != null) {
             debug.println("ComputeIfAbsent " + name + " provider property " +
@@ -662,7 +662,7 @@
     public synchronized Object computeIfPresent(Object key, BiFunction<? super Object,
             ? super Object, ? extends Object> remappingFunction) {
         check("putProviderProperty." + name);
-        check("removeProviderProperty" + name);
+        check("removeProviderProperty." + name);
 
         if (debug != null) {
             debug.println("ComputeIfPresent " + name + " provider property " +
@@ -695,7 +695,7 @@
     public synchronized Object merge(Object key, Object value,  BiFunction<? super Object,
             ? super Object, ? extends Object>  remappingFunction) {
         check("putProviderProperty." + name);
-        check("removeProviderProperty" + name);
+        check("removeProviderProperty." + name);
 
         if (debug != null) {
             debug.println("Merge " + name + " provider property " + key);
@@ -904,8 +904,8 @@
             if (!checkLegacy(key)) {
                 return null;
             }
-            legacyStrings.computeIfAbsent((String) key,
-                    (Function<? super String, ? extends String>) remappingFunction);
+            legacyStrings.compute((String) key,
+                    (BiFunction<? super String,? super String, ? extends String>) remappingFunction);
         }
         return super.compute(key, remappingFunction);
     }
--- a/jdk/src/java.base/share/classes/java/text/DateFormatSymbols.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/text/DateFormatSymbols.java	Fri Aug 19 12:17:32 2016 -0700
@@ -399,7 +399,10 @@
      * Calendar Elements in the Unicode Locale Data Markup Language
      * (LDML) specification</a> for more details.
      *
-     * @return the month strings.
+     * @return the month strings. Use
+     * {@link java.util.Calendar#JANUARY Calendar.JANUARY},
+     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY},
+     * etc. to index the result array.
      */
     public String[] getMonths() {
         return Arrays.copyOf(months, months.length);
@@ -407,7 +410,9 @@
 
     /**
      * Sets month strings. For example: "January", "February", etc.
-     * @param newMonths the new month strings.
+     * @param newMonths the new month strings. The array should
+     * be indexed by {@link java.util.Calendar#JANUARY Calendar.JANUARY},
+     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, etc.
      */
     public void setMonths(String[] newMonths) {
         months = Arrays.copyOf(newMonths, newMonths.length);
@@ -427,7 +432,10 @@
      * Calendar Elements in the Unicode Locale Data Markup Language
      * (LDML) specification</a> for more details.
      *
-     * @return the short month strings.
+     * @return the short month strings. Use
+     * {@link java.util.Calendar#JANUARY Calendar.JANUARY},
+     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY},
+     * etc. to index the result array.
      */
     public String[] getShortMonths() {
         return Arrays.copyOf(shortMonths, shortMonths.length);
@@ -435,7 +443,9 @@
 
     /**
      * Sets short month strings. For example: "Jan", "Feb", etc.
-     * @param newShortMonths the new short month strings.
+     * @param newShortMonths the new short month strings. The array should
+     * be indexed by {@link java.util.Calendar#JANUARY Calendar.JANUARY},
+     * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, etc.
      */
     public void setShortMonths(String[] newShortMonths) {
         shortMonths = Arrays.copyOf(newShortMonths, newShortMonths.length);
@@ -444,8 +454,10 @@
 
     /**
      * Gets weekday strings. For example: "Sunday", "Monday", etc.
-     * @return the weekday strings. Use <code>Calendar.SUNDAY</code>,
-     * <code>Calendar.MONDAY</code>, etc. to index the result array.
+     * @return the weekday strings. Use
+     * {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
+     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc. to index
+     * the result array.
      */
     public String[] getWeekdays() {
         return Arrays.copyOf(weekdays, weekdays.length);
@@ -454,8 +466,8 @@
     /**
      * Sets weekday strings. For example: "Sunday", "Monday", etc.
      * @param newWeekdays the new weekday strings. The array should
-     * be indexed by <code>Calendar.SUNDAY</code>,
-     * <code>Calendar.MONDAY</code>, etc.
+     * be indexed by {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
+     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc.
      */
     public void setWeekdays(String[] newWeekdays) {
         weekdays = Arrays.copyOf(newWeekdays, newWeekdays.length);
@@ -464,8 +476,10 @@
 
     /**
      * Gets short weekday strings. For example: "Sun", "Mon", etc.
-     * @return the short weekday strings. Use <code>Calendar.SUNDAY</code>,
-     * <code>Calendar.MONDAY</code>, etc. to index the result array.
+     * @return the short weekday strings. Use
+     * {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
+     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc. to index
+     * the result array.
      */
     public String[] getShortWeekdays() {
         return Arrays.copyOf(shortWeekdays, shortWeekdays.length);
@@ -474,8 +488,8 @@
     /**
      * Sets short weekday strings. For example: "Sun", "Mon", etc.
      * @param newShortWeekdays the new short weekday strings. The array should
-     * be indexed by <code>Calendar.SUNDAY</code>,
-     * <code>Calendar.MONDAY</code>, etc.
+     * be indexed by {@link java.util.Calendar#SUNDAY Calendar.SUNDAY},
+     * {@link java.util.Calendar#MONDAY Calendar.MONDAY}, etc.
      */
     public void setShortWeekdays(String[] newShortWeekdays) {
         shortWeekdays = Arrays.copyOf(newShortWeekdays, newShortWeekdays.length);
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java	Fri Aug 19 12:17:32 2016 -0700
@@ -147,11 +147,7 @@
      * @return the previous value
      */
     public final boolean getAndSet(boolean newValue) {
-        boolean prev;
-        do {
-            prev = get();
-        } while (!compareAndSet(prev, newValue));
-        return prev;
+        return (int)VALUE.getAndSet(this, (newValue ? 1 : 0)) != 0;
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java	Fri Aug 19 12:17:32 2016 -0700
@@ -263,6 +263,47 @@
      * is theoretically possible, so we additionally add a
      * storeStoreFence after lock acquisition CAS.
      *
+     * ----------------------------------------------------------------
+     * Here's an informal proof that plain reads by _successful_
+     * readers see plain writes from preceding but not following
+     * writers (following Boehm and the C++ standard [atomics.fences]):
+     *
+     * Because of the total synchronization order of accesses to
+     * volatile long state containing the sequence number, writers and
+     * _successful_ readers can be globally sequenced.
+     *
+     * int x, y;
+     *
+     * Writer 1:
+     * inc sequence (odd - "locked")
+     * storeStoreFence();
+     * x = 1; y = 2;
+     * inc sequence (even - "unlocked")
+     *
+     * Successful Reader:
+     * read sequence (even)
+     * // must see writes from Writer 1 but not Writer 2
+     * r1 = x; r2 = y;
+     * acquireFence();
+     * read sequence (even - validated unchanged)
+     * // use r1 and r2
+     *
+     * Writer 2:
+     * inc sequence (odd - "locked")
+     * storeStoreFence();
+     * x = 3; y = 4;
+     * inc sequence (even - "unlocked")
+     *
+     * Visibility of writer 1's stores is normal - reader's initial
+     * read of state synchronizes with writer 1's final write to state.
+     * Lack of visibility of writer 2's plain writes is less obvious.
+     * If reader's read of x or y saw writer 2's write, then (assuming
+     * semantics of C++ fences) the storeStoreFence would "synchronize"
+     * with reader's acquireFence and reader's validation read must see
+     * writer 2's initial write to state and so validation must fail.
+     * But making this "proof" formal and rigorous is an open problem!
+     * ----------------------------------------------------------------
+     *
      * The memory layout keeps lock state and queue pointers together
      * (normally on the same cache line). This usually works well for
      * read-mostly loads. In most other cases, the natural tendency of
@@ -276,14 +317,14 @@
     /** Number of processors, for spin control */
     private static final int NCPU = Runtime.getRuntime().availableProcessors();
 
-    /** Maximum number of retries before enqueuing on acquisition */
-    private static final int SPINS = (NCPU > 1) ? 1 << 6 : 0;
+    /** Maximum number of retries before enqueuing on acquisition; at least 1 */
+    private static final int SPINS = (NCPU > 1) ? 1 << 6 : 1;
 
-    /** Maximum number of retries before blocking at head on acquisition */
-    private static final int HEAD_SPINS = (NCPU > 1) ? 1 << 10 : 0;
+    /** Maximum number of tries before blocking at head on acquisition */
+    private static final int HEAD_SPINS = (NCPU > 1) ? 1 << 10 : 1;
 
     /** Maximum number of retries before re-blocking */
-    private static final int MAX_HEAD_SPINS = (NCPU > 1) ? 1 << 16 : 0;
+    private static final int MAX_HEAD_SPINS = (NCPU > 1) ? 1 << 16 : 1;
 
     /** The period for yielding when waiting for overflow spinlock */
     private static final int OVERFLOW_YIELD_RATE = 7; // must be power 2 - 1
@@ -1228,6 +1269,11 @@
                         WCOWAIT.compareAndSet(h, c, c.cowait) &&
                         (w = c.thread) != null) // help release
                         LockSupport.unpark(w);
+                    if (Thread.interrupted()) {
+                        if (interruptible)
+                            return cancelWaiter(node, p, true);
+                        wasInterrupted = true;
+                    }
                     if (h == (pp = p.prev) || h == p || pp == null) {
                         long m, s, ns;
                         do {
@@ -1264,11 +1310,6 @@
                                 LockSupport.parkNanos(this, time);
                         }
                         node.thread = null;
-                        if (Thread.interrupted()) {
-                            if (interruptible)
-                                return cancelWaiter(node, p, true);
-                            wasInterrupted = true;
-                        }
                     }
                 }
             }
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLEngine.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLEngine.java	Fri Aug 19 12:17:32 2016 -0700
@@ -861,6 +861,13 @@
      * be enabled by default, since this list may include cipher suites which
      * do not meet quality of service requirements for those defaults.  Such
      * cipher suites might be useful in specialized applications.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return  an array of cipher suite names
      * @see     #getEnabledCipherSuites()
@@ -880,6 +887,13 @@
      * or the requisite certificates (and private keys) for the suite are
      * not available, or an anonymous suite is enabled but authentication
      * is required.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return  an array of cipher suite names
      * @see     #getSupportedCipherSuites()
@@ -896,6 +910,14 @@
      * fail.  Following a successful call to this method, only suites
      * listed in the {@code suites} parameter are enabled for use.
      * <P>
+     * Note that the standard list of cipher suite names may be found in the
+     * <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation.  Providers
+     * may support cipher suite names not found in this list or might not
+     * use the recommended name for a certain cipher suite.
+     * <P>
      * See {@link #getEnabledCipherSuites()} for more information
      * on why a specific cipher suite may never be used on a engine.
      *
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLParameters.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLParameters.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -108,7 +108,12 @@
      * <p>
      * Calling this constructor is equivalent to calling the no-args
      * constructor followed by
-     * {@code setCipherSuites(cipherSuites);}.
+     * {@code setCipherSuites(cipherSuites);}.  Note that the
+     * standard list of cipher suite names may be found in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation.  Providers
+     * may support cipher suite names not found in this list.
      *
      * @param cipherSuites the array of ciphersuites (or null)
      */
@@ -123,6 +128,12 @@
      * Calling this constructor is equivalent to calling the no-args
      * constructor followed by
      * {@code setCipherSuites(cipherSuites); setProtocols(protocols);}.
+     * Note that the standard list of cipher suite names may be found in the
+     * <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation.  Providers
+     * may support cipher suite names not found in this list.
      *
      * @param cipherSuites the array of ciphersuites (or null)
      * @param protocols the array of protocols (or null)
@@ -139,6 +150,13 @@
     /**
      * Returns a copy of the array of ciphersuites or null if none
      * have been set.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return a copy of the array of ciphersuites or null if none
      * have been set.
@@ -150,7 +168,13 @@
     /**
      * Sets the array of ciphersuites.
      *
-     * @param cipherSuites the array of ciphersuites (or null)
+     * @param cipherSuites the array of ciphersuites (or null).  Note that the
+     * standard list of cipher suite names may be found in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation.  Providers
+     * may support cipher suite names not found in this list or might not
+     * use the recommended name for a certain cipher suite.
      */
     public void setCipherSuites(String[] cipherSuites) {
         this.cipherSuites = clone(cipherSuites);
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocket.java	Fri Aug 19 12:17:32 2016 -0700
@@ -195,6 +195,13 @@
      * or the requisite certificates (and private keys) for the suite are
      * not available, or an anonymous suite is enabled but authentication
      * is required.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return an array of cipher suites enabled
      * @see #getSupportedCipherSuites()
@@ -215,6 +222,14 @@
      * in this ServerSocket's authentication context will not be used
      * in any case, even if they are enabled.
      * <P>
+     * Note that the standard list of cipher suite names may be found in the
+     * <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation.  Providers
+     * may support cipher suite names not found in this list or might not
+     * use the recommended name for a certain cipher suite.
+     * <P>
      * <code>SSLSocket</code>s returned from <code>accept()</code>
      * inherit this setting.
      *
@@ -236,6 +251,13 @@
      * be enabled by default, since this list may include cipher suites which
      * do not meet quality of service requirements for those defaults.  Such
      * cipher suites are useful in specialized applications.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return an array of cipher suite names
      * @see #getEnabledCipherSuites()
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLServerSocketFactory.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -123,6 +123,13 @@
      * will use one of these cipher suites.  The minimum quality of service
      * for these defaults requires confidentiality protection and server
      * authentication (that is, no anonymous cipher suites).
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @see #getSupportedCipherSuites()
      * @return array of the cipher suites enabled by default
@@ -137,6 +144,13 @@
      * be enabled by default, since this list may include cipher suites which
      * do not meet quality of service requirements for those defaults.  Such
      * cipher suites are useful in specialized applications.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return an array of cipher suite names
      * @see #getDefaultCipherSuites()
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocket.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocket.java	Fri Aug 19 12:17:32 2016 -0700
@@ -265,6 +265,13 @@
      * be enabled by default, since this list may include cipher suites which
      * do not meet quality of service requirements for those defaults.  Such
      * cipher suites might be useful in specialized applications.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return an array of cipher suite names
      * @see #getEnabledCipherSuites()
@@ -284,6 +291,13 @@
      * or the requisite certificates (and private keys) for the suite are
      * not available, or an anonymous suite is enabled but authentication
      * is required.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @return an array of cipher suite names
      * @see #getSupportedCipherSuites()
@@ -300,6 +314,14 @@
      * fail.  Following a successful call to this method, only suites
      * listed in the <code>suites</code> parameter are enabled for use.
      * <P>
+     * Note that the standard list of cipher suite names may be found in the
+     * <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation.  Providers
+     * may support cipher suite names not found in this list or might not
+     * use the recommended name for a certain cipher suite.
+     * <P>
      * See {@link #getEnabledCipherSuites()} for more information
      * on why a specific ciphersuite may never be used on a connection.
      *
--- a/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -148,6 +148,13 @@
      * will use one of these cipher suites.  The minimum quality of service
      * for these defaults requires confidentiality protection and server
      * authentication (that is, no anonymous cipher suites).
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @see #getSupportedCipherSuites()
      * @return array of the cipher suites enabled by default
@@ -160,6 +167,13 @@
      * be enabled by default, since this list may include cipher suites which
      * do not meet quality of service requirements for those defaults.  Such
      * cipher suites are useful in specialized applications.
+     * <P>
+     * The returned array includes cipher suites from the list of standard
+     * cipher suite names in the <a href=
+     * "{@docRoot}/../technotes/guides/security/StandardNames.html#ciphersuites">
+     * JSSE Cipher Suite Names</a> section of the Java Cryptography
+     * Architecture Standard Algorithm Name Documentation, and may also
+     * include other cipher suites that the provider supports.
      *
      * @see #getDefaultCipherSuites()
      * @return an array of cipher suite names
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangInvokeAccess.java	Fri Aug 19 12:17:32 2016 -0700
@@ -51,8 +51,17 @@
      * an {@code int} representing method type.  Used by
      * GenerateJLIClassesPlugin to generate such a class during the jlink phase.
      */
-    byte[] generateDMHClassBytes(String className, MethodType[] methodTypes,
-            int[] types);
+    byte[] generateDirectMethodHandleHolderClassBytes(String className,
+            MethodType[] methodTypes, int[] types);
+
+    /**
+     * Returns a {@code byte[]} containing the bytecode for a class implementing
+     * DelegatingMethodHandles of each {@code MethodType} kind in the
+     * {@code methodTypes} argument.  Used by GenerateJLIClassesPlugin to
+     * generate such a class during the jlink phase.
+     */
+    byte[] generateDelegatingMethodHandleHolderClassBytes(String className,
+            MethodType[] methodTypes);
 
     /**
      * Returns a {@code byte[]} containing the bytecode for a BoundMethodHandle
--- a/jdk/src/java.base/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -24,9 +24,8 @@
  */
 
 /**
- * java.base defines and exports the core APIs of the Java SE platform.
+ * Defines the foundational APIs of the Java SE Platform.
  */
-
 module java.base {
 
     exports java.io;
--- a/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Fri Aug 19 12:17:32 2016 -0700
@@ -580,6 +580,9 @@
             Entry entry;
 
             if (key instanceof PrivateKey) {
+                // Check that all the certs are X.509 certs
+                checkX509Certs(chain);
+
                 PrivateKeyEntry keyEntry = new PrivateKeyEntry();
                 keyEntry.date = new Date();
 
@@ -690,6 +693,9 @@
                                   Certificate[] chain)
         throws KeyStoreException
     {
+        // Check that all the certs are X.509 certs
+        checkX509Certs(chain);
+
         // Private key must be encoded as EncryptedPrivateKeyInfo
         // as defined in PKCS#8
         try {
@@ -960,6 +966,13 @@
     private void setCertEntry(String alias, Certificate cert,
         Set<KeyStore.Entry.Attribute> attributes) throws KeyStoreException {
 
+        // Check that the cert is an X.509 cert
+        if (cert != null && (!(cert instanceof X509Certificate))) {
+            throw new KeyStoreException(
+                "Only X.509 certificates are supported - rejecting class: " +
+                cert.getClass().getName());
+        }
+
         Entry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
         if (entry != null && entry instanceof KeyEntry) {
             throw new KeyStoreException("Cannot overwrite own certificate");
@@ -1505,6 +1518,21 @@
         return set.size() == certChain.length;
     }
 
+    /*
+     * Check that all the certificates are X.509 certificates
+     */
+    private static void checkX509Certs(Certificate[] certs)
+            throws KeyStoreException {
+        if (certs != null) {
+            for (Certificate cert : certs) {
+                if (!(cert instanceof X509Certificate)) {
+                    throw new KeyStoreException(
+                        "Only X.509 certificates are supported - " +
+                        "rejecting class: " + cert.getClass().getName());
+                }
+            }
+        }
+    }
 
     /*
      * Create PKCS#12 Attributes, friendlyName, localKeyId and trustedKeyUsage.
--- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -59,6 +59,11 @@
             "jdk.tls.client.enableStatusRequestExtension", true);
     private final boolean serverEnableStapling = Debug.getBooleanProperty(
             "jdk.tls.server.enableStatusRequestExtension", false);
+    private final static Collection<CipherSuite> clientCustomizedCipherSuites =
+            getCustomizedCipherSuites("jdk.tls.client.cipherSuites");
+    private final static Collection<CipherSuite> serverCustomizedCipherSuites =
+            getCustomizedCipherSuites("jdk.tls.server.cipherSuites");
+
     private volatile StatusResponseManager statusResponseManager;
 
     SSLContextImpl() {
@@ -336,20 +341,52 @@
         return isClient ? clientEnableStapling : serverEnableStapling;
     }
 
+
     /*
-     * Return the list of all available CipherSuites with a priority of
-     * minPriority or above.
+     * Return the list of all available CipherSuites that are supported
+     * using currently installed providers.
+     */
+    private static CipherSuiteList getApplicableSupportedCipherSuiteList(
+            ProtocolList protocols) {
+
+        return getApplicableCipherSuiteList(
+                CipherSuite.allowedCipherSuites(),
+                protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY);
+    }
+
+    /*
+     * Return the list of all available CipherSuites that are default enabled
+     * in client or server side.
+     */
+    private static CipherSuiteList getApplicableEnabledCipherSuiteList(
+            ProtocolList protocols, boolean isClient) {
+
+        if (isClient) {
+            if (!clientCustomizedCipherSuites.isEmpty()) {
+                return getApplicableCipherSuiteList(
+                        clientCustomizedCipherSuites,
+                        protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY);
+            }
+        } else {
+            if (!serverCustomizedCipherSuites.isEmpty()) {
+                return getApplicableCipherSuiteList(
+                        serverCustomizedCipherSuites,
+                        protocols, CipherSuite.SUPPORTED_SUITES_PRIORITY);
+            }
+        }
+
+        return getApplicableCipherSuiteList(
+                CipherSuite.allowedCipherSuites(),
+                protocols, CipherSuite.DEFAULT_SUITES_PRIORITY);
+    }
+
+    /*
+     * Return the list of available CipherSuites which are applicable to
+     * the specified protocols.
      */
     private static CipherSuiteList getApplicableCipherSuiteList(
-            ProtocolList protocols, boolean onlyEnabled) {
-
-        int minPriority = CipherSuite.SUPPORTED_SUITES_PRIORITY;
-        if (onlyEnabled) {
-            minPriority = CipherSuite.DEFAULT_SUITES_PRIORITY;
-        }
-
-        Collection<CipherSuite> allowedCipherSuites =
-                                    CipherSuite.allowedCipherSuites();
+            Collection<CipherSuite> allowedCipherSuites,
+            ProtocolList protocols, int minPriority) {
 
         TreeSet<CipherSuite> suites = new TreeSet<>();
         if (!(protocols.collection().isEmpty()) &&
@@ -386,6 +423,67 @@
         return new CipherSuiteList(suites);
     }
 
+    /*
+     * Get the customized cipher suites specified by the given system property.
+     */
+    private static Collection<CipherSuite> getCustomizedCipherSuites(
+            String propertyName) {
+
+        String property = GetPropertyAction.privilegedGetProperty(propertyName);
+        if (debug != null && Debug.isOn("sslctx")) {
+            System.out.println(
+                    "System property " + propertyName + " is set to '" +
+                    property + "'");
+        }
+        if (property != null && property.length() != 0) {
+            // remove double quote marks from beginning/end of the property
+            if (property.length() > 1 && property.charAt(0) == '"' &&
+                    property.charAt(property.length() - 1) == '"') {
+                property = property.substring(1, property.length() - 1);
+            }
+        }
+
+        if (property != null && property.length() != 0) {
+            String[] cipherSuiteNames = property.split(",");
+            Collection<CipherSuite> cipherSuites =
+                        new ArrayList<>(cipherSuiteNames.length);
+            for (int i = 0; i < cipherSuiteNames.length; i++) {
+                cipherSuiteNames[i] = cipherSuiteNames[i].trim();
+                if (cipherSuiteNames[i].isEmpty()) {
+                    continue;
+                }
+
+                CipherSuite suite;
+                try {
+                    suite = CipherSuite.valueOf(cipherSuiteNames[i]);
+                } catch (IllegalArgumentException iae) {
+                    if (debug != null && Debug.isOn("sslctx")) {
+                        System.out.println(
+                                "Unknown or unsupported cipher suite name: " +
+                                cipherSuiteNames[i]);
+                    }
+
+                    continue;
+                }
+
+                if (suite.isAvailable()) {
+                    cipherSuites.add(suite);
+                } else {
+                    if (debug != null && Debug.isOn("sslctx")) {
+                        System.out.println(
+                                "The current installed providers do not " +
+                                "support cipher suite: " + cipherSuiteNames[i]);
+                    }
+                }
+            }
+
+            return cipherSuites;
+        }
+
+        return Collections.emptyList();
+    }
+
+
     private static String[] getAvailableProtocols(
             ProtocolVersion[] protocolCandidates) {
 
@@ -481,10 +579,10 @@
                 }));
             }
 
-            supportedCipherSuiteList = getApplicableCipherSuiteList(
-                    supportedProtocolList, false);          // all supported
-            serverDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    serverDefaultProtocolList, true);       // enabled only
+            supportedCipherSuiteList = getApplicableSupportedCipherSuiteList(
+                    supportedProtocolList);
+            serverDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
+                    serverDefaultProtocolList, false);
         }
 
         @Override
@@ -541,8 +639,8 @@
                 }));
             }
 
-            clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    clientDefaultProtocolList, true);       // enabled only
+            clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
+                    clientDefaultProtocolList, true);
         }
 
         @Override
@@ -581,8 +679,9 @@
                 }));
             }
 
-            clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    clientDefaultProtocolList, true);       // enabled only
+            clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
+                    clientDefaultProtocolList, true);
+
         }
 
         @Override
@@ -623,8 +722,8 @@
                 }));
             }
 
-            clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    clientDefaultProtocolList, true);       // enabled only
+            clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
+                    clientDefaultProtocolList, true);
         }
 
         @Override
@@ -757,8 +856,9 @@
 
                 clientDefaultProtocolList = new ProtocolList(
                         getAvailableProtocols(candidates));
-                clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    clientDefaultProtocolList, true);   // enabled only
+                clientDefaultCipherSuiteList =
+                        getApplicableEnabledCipherSuiteList(
+                                clientDefaultProtocolList, true);
             } else {
                 clientDefaultProtocolList = null;       // unlikely to be used
                 clientDefaultCipherSuiteList = null;    // unlikely to be used
@@ -1032,10 +1132,10 @@
                 ProtocolVersion.DTLS12
             }));
 
-            supportedCipherSuiteList = getApplicableCipherSuiteList(
-                    supportedProtocolList, false);          // all supported
-            serverDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    serverDefaultProtocolList, true);       // enabled only
+            supportedCipherSuiteList = getApplicableSupportedCipherSuiteList(
+                    supportedProtocolList);
+            serverDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
+                    serverDefaultProtocolList, false);
         }
 
         @Override
@@ -1090,8 +1190,8 @@
                 ProtocolVersion.DTLS10
             }));
 
-            clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    clientDefaultProtocolList, true);       // enabled only
+            clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
+                    clientDefaultProtocolList, true);
         }
 
         @Override
@@ -1122,8 +1222,8 @@
                 ProtocolVersion.DTLS12
             }));
 
-            clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    clientDefaultProtocolList, true);       // enabled only
+            clientDefaultCipherSuiteList = getApplicableEnabledCipherSuiteList(
+                    clientDefaultProtocolList, true);
         }
 
         @Override
@@ -1187,8 +1287,9 @@
 
                 clientDefaultProtocolList = new ProtocolList(
                         getAvailableProtocols(candidates));
-                clientDefaultCipherSuiteList = getApplicableCipherSuiteList(
-                    clientDefaultProtocolList, true);   // enabled only
+                clientDefaultCipherSuiteList =
+                        getApplicableEnabledCipherSuiteList(
+                                clientDefaultProtocolList, true);
             } else {
                 clientDefaultProtocolList = null;       // unlikely to be used
                 clientDefaultCipherSuiteList = null;    // unlikely to be used
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -3631,8 +3631,8 @@
                 if (time != null) {
                     if (time.matches("\\d\\d:\\d\\d:\\d\\d")) {
                         c.set(Calendar.HOUR_OF_DAY, Integer.valueOf(time.substring(0, 2)));
-                        c.set(Calendar.MINUTE, Integer.valueOf(time.substring(0, 2)));
-                        c.set(Calendar.SECOND, Integer.valueOf(time.substring(0, 2)));
+                        c.set(Calendar.MINUTE, Integer.valueOf(time.substring(3, 5)));
+                        c.set(Calendar.SECOND, Integer.valueOf(time.substring(6, 8)));
                         c.set(Calendar.MILLISECOND, 0);
                     } else {
                         throw ioe;
--- a/jdk/src/java.compact1/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.compact1/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Aggregates {@code java.base}, {@code java.logging}, and {@code java.scripting}.
+ */
 module java.compact1 {
     requires public java.logging;
     requires public java.scripting;
--- a/jdk/src/java.compact2/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.compact2/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Supplements {@code java.compact1} with JDBC, JAXP, and RMI.
+ */
 module java.compact2 {
     requires public java.compact1;
     requires public java.rmi;
--- a/jdk/src/java.compact3/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.compact3/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,10 @@
  * questions.
  */
 
+/**
+ * Supplements {@code java.compact2} with JDBC RowSet, JMX, JNDI, Compiler,
+ * Instrumentation, Preferences, Security, and XML cryptography APIs.
+ */
 module java.compact3 {
     requires public java.compact2;
     requires public java.compiler;
--- a/jdk/src/java.datatransfer/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.datatransfer/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -24,10 +24,8 @@
  */
 
 /**
- * Provides interfaces and classes for transferring data between and
- * within applications.
+ * Defines an API for transferring data between and within applications.
  */
-
 module java.datatransfer {
     exports java.awt.datatransfer;
     exports sun.datatransfer to java.desktop;
--- a/jdk/src/java.desktop/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.desktop/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -24,9 +24,9 @@
  */
 
 /**
-  * java.desktop defines and exports the user interface, graphics
-  * and imaging APIs of the Java SE platform.
-  */
+ * Defines the AWT and Swing user interface toolkits, plus APIs for
+ * accessibility, audio, imaging, printing, and JavaBeans.
+ */
 module java.desktop {
     requires public java.datatransfer;
     requires public java.xml;
--- a/jdk/src/java.httpclient/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.httpclient/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the high-level HTTP and WebSocket API.
+ */
 module java.httpclient {
     requires java.base;
     exports java.net.http;
--- a/jdk/src/java.instrument/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.instrument/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,10 @@
  * questions.
  */
 
+/**
+ * Defines services that allow agents to
+ * instrument programs running on the JVM.
+ */
 module java.instrument {
     exports java.lang.instrument;
 }
--- a/jdk/src/java.logging/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.logging/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the Java Logging API.
+ */
 module java.logging {
     exports java.util.logging;
     provides jdk.internal.logger.DefaultLoggerFinder with
--- a/jdk/src/java.management/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.management/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines the Java Management Extensions (JMX) API.
+ * <P>
+ * The JMX API consists of interfaces for monitoring and management of the
+ * JVM and other components in the Java runtime.
+ */
 module java.management {
     requires public java.rmi;
     requires java.logging;
--- a/jdk/src/java.naming/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.naming/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the Java Naming and Directory Interface (JNDI) API.
+ */
 module java.naming {
     requires java.security.sasl;
 
--- a/jdk/src/java.prefs/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.prefs/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the Preferences API.
+ */
 module java.prefs {
     requires java.xml;
 
--- a/jdk/src/java.rmi/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.rmi/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the Remote Method Invocation (RMI) API.
+ */
 module java.rmi {
     requires java.logging;
 
--- a/jdk/src/java.scripting/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.scripting/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the Scripting API.
+ */
 module java.scripting {
     exports javax.script;
     uses javax.script.ScriptEngineFactory;
--- a/jdk/src/java.se/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.se/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,13 @@
  * questions.
  */
 
+/**
+ * Defines the core Java SE API.
+ * <P>
+ * The modules defining
+ * CORBA and Java EE APIs are not required by this module, but they are
+ * required by {@code java.se.ee}.
+ */
 module java.se {
     requires public java.compact3;
     requires public java.datatransfer;
--- a/jdk/src/java.security.jgss/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.security.jgss/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,11 @@
  * questions.
  */
 
+/**
+ * Defines the Java binding of the IETF Generic Security Services API (GSS-API).
+ * <P>
+ * This module also contains GSS-API mechanisms including Kerberos v5 and SPNEGO.
+ */
 module java.security.jgss {
     requires java.naming;
     exports javax.security.auth.kerberos;
--- a/jdk/src/java.security.sasl/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.security.sasl/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,13 @@
  * questions.
  */
 
+/**
+ * Defines Java support for the IETF Simple Authentication and Security Layer
+ * (SASL).
+ * <P>
+ * This module also contains SASL mechanisms including DIGEST-MD5,
+ * CRAM-MD5, and NTLM.
+ */
 module java.security.sasl {
     requires java.logging;
 
--- a/jdk/src/java.smartcardio/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.smartcardio/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the Java Smart Card I/O API.
+ */
 module java.smartcardio {
     exports javax.smartcardio;
     provides java.security.Provider with sun.security.smartcardio.SunPCSC;
--- a/jdk/src/java.sql.rowset/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.sql.rowset/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the JDBC RowSet API.
+ */
 module java.sql.rowset {
     requires public java.logging;
     requires public java.naming;
--- a/jdk/src/java.sql/share/classes/javax/sql/DataSource.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.sql/share/classes/javax/sql/DataSource.java	Fri Aug 19 12:17:32 2016 -0700
@@ -64,7 +64,7 @@
  * <P>
  * A driver that is accessed via a {@code DataSource} object does not
  * register itself with the {@code DriverManager}.  Rather, a
- * {@code DataSource} object is retrieved though a lookup operation
+ * {@code DataSource} object is retrieved through a lookup operation
  * and then used to create a {@code Connection} object.  With a basic
  * implementation, the connection obtained through a {@code DataSource}
  * object is identical to a connection obtained through the
--- a/jdk/src/java.sql/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.sql/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines the JDBC API.
+ */
 module java.sql {
     requires public java.logging;
     requires public java.xml;
--- a/jdk/src/java.transaction/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.transaction/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,12 @@
  * questions.
  */
 
+/**
+ * Defines a subset of the Java Transaction API (JTA) to support CORBA interop.
+ * <P>
+ * The subset consists of RMI exception types which are mapped to CORBA system
+ * exceptions by the 'Java Language to IDL Mapping Specification'.
+ */
 module java.transaction {
     requires public java.rmi;
     exports javax.transaction;
--- a/jdk/src/java.xml.crypto/share/classes/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/java.xml.crypto/share/classes/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,9 @@
  * questions.
  */
 
+/**
+ * Defines an API for XML cryptography.
+ */
 module java.xml.crypto {
     requires public java.xml;
     requires java.logging;
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/Key.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -30,7 +30,6 @@
 /**
  * The handle for an RSA or DSA key using the Microsoft Crypto API.
  *
- * @see DSAPrivateKey
  * @see RSAPrivateKey
  * @see RSAPublicKey
  *
@@ -41,9 +40,35 @@
 {
     private static final long serialVersionUID = -1088859394025049194L;
 
-    // Native handle
-    protected long hCryptProv = 0;
-    protected long hCryptKey = 0;
+    static class NativeHandles {
+        long hCryptProv = 0;
+        long hCryptKey = 0;
+
+        public NativeHandles(long hCryptProv, long hCryptKey) {
+            this.hCryptProv = hCryptProv;
+            this.hCryptKey = hCryptKey;
+        }
+
+        /**
+         * Finalization method
+         */
+        protected void finalize() throws Throwable
+        {
+            try {
+                synchronized(this)
+                {
+                    cleanUp(hCryptProv, hCryptKey);
+                    hCryptProv = 0;
+                    hCryptKey = 0;
+                }
+
+            } finally {
+                super.finalize();
+            }
+        }
+    }
+
+    protected NativeHandles handles;
 
     // Key length
     protected int keyLength = 0;
@@ -51,29 +76,10 @@
     /**
      * Construct a Key object.
      */
-    protected Key(long hCryptProv, long hCryptKey, int keyLength)
-    {
-        this.hCryptProv = hCryptProv;
-        this.hCryptKey = hCryptKey;
-        this.keyLength = keyLength;
-    }
-
-    /**
-     * Finalization method
-     */
-    protected void finalize() throws Throwable
+    protected Key(NativeHandles handles, int keyLength)
     {
-        try {
-            synchronized(this)
-            {
-                cleanUp(hCryptProv, hCryptKey);
-                hCryptProv = 0;
-                hCryptKey = 0;
-            }
-
-        } finally {
-            super.finalize();
-        }
+        this.handles = handles;
+        this.keyLength = keyLength;
     }
 
     /**
@@ -96,7 +102,7 @@
      */
     public long getHCryptKey()
     {
-        return hCryptKey;
+        return handles.hCryptKey;
     }
 
     /**
@@ -104,12 +110,12 @@
      */
     public long getHCryptProvider()
     {
-        return hCryptProv;
+        return handles.hCryptProv;
     }
 
     /**
      * Returns the standard algorithm name for this key. For
-     * example, "DSA" would indicate that this key is a DSA key.
+     * example, "RSA" would indicate that this key is a RSA key.
      * See Appendix A in the <a href=
      * "../../../guide/security/CryptoSpec.html#AppA">
      * Java Cryptography Architecture API Specification &amp; Reference </a>
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java	Fri Aug 19 12:17:32 2016 -0700
@@ -168,7 +168,7 @@
             }
             certChain = chain;
         }
-    };
+    }
 
     /*
      * An X.509 certificate factory.
@@ -798,7 +798,8 @@
             }
 
             storeWithUniqueAlias(alias, new KeyEntry(alias,
-                    new RSAPrivateKey(hCryptProv, hCryptKey, keyLength),
+                    new RSAPrivateKey(new Key.NativeHandles(hCryptProv,
+                            hCryptKey), keyLength),
                     certChain));
         }
         catch (Throwable e)
@@ -854,7 +855,6 @@
      * Load keys and/or certificates from keystore into Collection.
      *
      * @param name Name of keystore.
-     * @param entries Collection of key/certificate.
      */
     private native void loadKeysOrCertificateChains(String name)
             throws KeyStoreException;
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAKeyPair.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAKeyPair.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -41,8 +41,9 @@
      */
     RSAKeyPair(long hCryptProv, long hCryptKey, int keyLength)
     {
-        privateKey = new RSAPrivateKey(hCryptProv, hCryptKey, keyLength);
-        publicKey = new RSAPublicKey(hCryptProv, hCryptKey, keyLength);
+        Key.NativeHandles handles = new Key.NativeHandles(hCryptProv, hCryptKey);
+        privateKey = new RSAPrivateKey(handles, keyLength);
+        publicKey = new RSAPublicKey(handles, keyLength);
     }
 
     public RSAPrivateKey getPrivate() {
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAPrivateKey.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAPrivateKey.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -42,7 +42,15 @@
      */
     RSAPrivateKey(long hCryptProv, long hCryptKey, int keyLength)
     {
-        super(hCryptProv, hCryptKey, keyLength);
+        super(new NativeHandles(hCryptProv, hCryptKey), keyLength);
+    }
+
+    /**
+     * Construct an RSAPrivateKey object.
+     */
+    RSAPrivateKey(NativeHandles handles, int keyLength)
+    {
+        super(handles, keyLength);
     }
 
     /**
@@ -63,8 +71,8 @@
     public String toString()
     {
         return "RSAPrivateKey [size=" + keyLength + " bits, type=" +
-            getKeyType(hCryptKey) + ", container=" +
-            getContainerName(hCryptProv) + "]";
+            getKeyType(handles.hCryptKey) + ", container=" +
+            getContainerName(handles.hCryptProv) + "]";
     }
 
     // This class is not serializable
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAPublicKey.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/RSAPublicKey.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -51,7 +51,15 @@
      */
     RSAPublicKey(long hCryptProv, long hCryptKey, int keyLength)
     {
-        super(hCryptProv, hCryptKey, keyLength);
+        super(new NativeHandles(hCryptProv, hCryptKey), keyLength);
+    }
+
+    /**
+     * Construct an RSAPublicKey object.
+     */
+    RSAPublicKey(NativeHandles handles, int keyLength)
+    {
+        super(handles, keyLength);
     }
 
     /**
@@ -77,8 +85,8 @@
         StringBuffer sb = new StringBuffer();
 
         sb.append("RSAPublicKey [size=").append(keyLength)
-            .append(" bits, type=").append(getKeyType(hCryptKey))
-            .append(", container=").append(getContainerName(hCryptProv))
+            .append(" bits, type=").append(getKeyType(handles.hCryptKey))
+            .append(", container=").append(getContainerName(handles.hCryptProv))
             .append("]\n  modulus: ").append(getModulus())
             .append("\n  public exponent: ").append(getPublicExponent());
 
@@ -93,7 +101,7 @@
         if (exponent == null) {
 
             try {
-                publicKeyBlob = getPublicKeyBlob(hCryptKey);
+                publicKeyBlob = getPublicKeyBlob(handles.hCryptKey);
                 exponent = new BigInteger(1, getExponent(publicKeyBlob));
 
             } catch (KeyException e) {
@@ -112,7 +120,7 @@
         if (modulus == null) {
 
             try {
-                publicKeyBlob = getPublicKeyBlob(hCryptKey);
+                publicKeyBlob = getPublicKeyBlob(handles.hCryptKey);
                 modulus = new BigInteger(1, getModulus(publicKeyBlob));
 
             } catch (KeyException e) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Fri Aug 19 12:17:32 2016 -0700
@@ -55,7 +55,7 @@
 
     private static final String DESCRIPTION = PluginsResourceBundle.getDescription(NAME);
 
-    private static final String DMH = "java/lang/invoke/DirectMethodHandle$Holder";
+    private static final String DIRECT_METHOD_HANDLE = "java/lang/invoke/DirectMethodHandle$Holder";
     private static final String DMH_INVOKE_VIRTUAL = "invokeVirtual";
     private static final String DMH_INVOKE_STATIC = "invokeStatic";
     private static final String DMH_INVOKE_SPECIAL = "invokeSpecial";
@@ -63,6 +63,8 @@
     private static final String DMH_INVOKE_INTERFACE = "invokeInterface";
     private static final String DMH_INVOKE_STATIC_INIT = "invokeStaticInit";
 
+    private static final String DELEGATING_METHOD_HANDLE = "java/lang/invoke/DelegatingMethodHandle$Holder";
+
     private static final JavaLangInvokeAccess JLIA
             = SharedSecrets.getJavaLangInvokeAccess();
 
@@ -222,7 +224,15 @@
     @Override
     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
         // Copy all but DMH_ENTRY to out
-        in.transformAndCopy(entry -> entry.path().equals(DMH_ENTRY) ? null : entry, out);
+        in.transformAndCopy(entry -> {
+                // filter out placeholder entries
+                if (entry.path().equals(DIRECT_METHOD_HANDLE_ENTRY) ||
+                    entry.path().equals(DELEGATING_METHOD_HANDLE_ENTRY)) {
+                    return null;
+                } else {
+                    return entry;
+                }
+            }, out);
         speciesTypes.forEach(types -> generateBMHClass(types, out));
         generateDMHClass(out);
         return out.build();
@@ -264,15 +274,24 @@
             }
         }
         try {
-            byte[] bytes =
-                    JLIA.generateDMHClassBytes(DMH, methodTypes, dmhTypes);
-            ResourcePoolEntry ndata = ResourcePoolEntry.create(DMH_ENTRY, bytes);
+            byte[] bytes = JLIA.generateDirectMethodHandleHolderClassBytes(
+                    DIRECT_METHOD_HANDLE, methodTypes, dmhTypes);
+            ResourcePoolEntry ndata = ResourcePoolEntry
+                    .create(DIRECT_METHOD_HANDLE_ENTRY, bytes);
+            out.add(ndata);
+
+            bytes = JLIA.generateDelegatingMethodHandleHolderClassBytes(
+                    DELEGATING_METHOD_HANDLE, methodTypes);
+            ndata = ResourcePoolEntry.create(DELEGATING_METHOD_HANDLE_ENTRY, bytes);
             out.add(ndata);
         } catch (Exception ex) {
             throw new PluginException(ex);
         }
     }
-    private static final String DMH_ENTRY = "/java.base/" + DMH + ".class";
+    private static final String DIRECT_METHOD_HANDLE_ENTRY =
+            "/java.base/" + DIRECT_METHOD_HANDLE + ".class";
+    private static final String DELEGATING_METHOD_HANDLE_ENTRY =
+            "/java.base/" + DELEGATING_METHOD_HANDLE + ".class";
 
     // Convert LL -> LL, L3 -> LLL
     private static String expandSignature(String signature) {
@@ -310,15 +329,19 @@
         assert(parts.length == 2);
         assert(parts[1].length() == 1);
         String parameters = expandSignature(parts[0]);
-        Class<?> rtype = primitiveType(parts[1].charAt(0));
-        Class<?>[] ptypes = new Class<?>[parameters.length()];
-        for (int i = 0; i < ptypes.length; i++) {
-            ptypes[i] = primitiveType(parameters.charAt(i));
+        Class<?> rtype = simpleType(parts[1].charAt(0));
+        if (parameters.isEmpty()) {
+            return MethodType.methodType(rtype);
+        } else {
+            Class<?>[] ptypes = new Class<?>[parameters.length()];
+            for (int i = 0; i < ptypes.length; i++) {
+                ptypes[i] = simpleType(parameters.charAt(i));
+            }
+            return MethodType.methodType(rtype, ptypes);
         }
-        return MethodType.methodType(rtype, ptypes);
     }
 
-    private static Class<?> primitiveType(char c) {
+    private static Class<?> simpleType(char c) {
         switch (c) {
             case 'F':
                 return float.class;
--- a/jdk/test/ProblemList.txt	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/ProblemList.txt	Fri Aug 19 12:17:32 2016 -0700
@@ -211,6 +211,8 @@
 
 java/rmi/transport/dgcDeadLock/DGCDeadLock.java                 8029360 macosx-all
 
+sun/rmi/runtime/Log/6409194/NoConsoleOutput.java                8164124 windows-all
+
 ############################################################################
 
 # jdk_security
--- a/jdk/test/java/lang/StackWalker/VerifyStackTrace.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/lang/StackWalker/VerifyStackTrace.java	Fri Aug 19 12:17:32 2016 -0700
@@ -205,8 +205,12 @@
                     .replaceAll("java.base@(\\d+\\.){0,3}(\\d+)/", "java.base/")
                     .replaceAll("/[0-9]+\\.run", "/xxxxxxxx.run")
                     .replaceAll("/[0-9]+\\.invoke", "/xxxxxxxx.invoke")
+                    // DMHs may or may not be pre-generated, making frames differ
                     .replaceAll("DirectMethodHandle\\$Holder", "LambdaForm\\$DMH")
                     .replaceAll("DMH\\.invoke", "DMH/xxxxxxxx.invoke")
+                    // invoke frames may or may not have basic method type
+                    // information encoded for diagnostic purposes
+                    .replaceAll("xx\\.invoke([A-Za-z]*)_[A-Z]+_[A-Z]", "xx.invoke$1")
                     .replaceAll("\\$[0-9]+", "\\$??");
         } else {
             return produced;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/KeyPairGenerator/FinalizeHalf.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2016, 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 8163896
+ * @summary Finalizing one key of a KeyPair invalidates the other key
+ */
+
+import java.security.Key;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.ProviderException;
+import java.security.Security;
+import java.util.function.Consumer;
+import java.util.ArrayList;
+import java.util.List;
+
+public class FinalizeHalf {
+
+    static int failures = 0;
+
+    public static void main(String[] args) throws Throwable {
+        List<Consumer<Key>> methods = new ArrayList<>();
+        methods.add((Key k) -> k.getEncoded());
+        methods.add((Key k) -> k.toString());
+
+        for (String algo : new String[] {"DiffieHellman", "DSA", "RSA"}) {
+            for (Provider provider : Security.getProviders()) {
+                for (boolean priv : new boolean[] {true, false}) {
+                    for (Consumer<Key> method : methods) {
+                        test(algo, provider, priv, method);
+                    }
+                }
+            }
+        }
+
+        if (failures > 0) {
+            throw new RuntimeException(failures + " test(s) failed.");
+        }
+    }
+
+    static void test(String algo, Provider provider, boolean priv,
+            Consumer<Key> method) throws Exception {
+        KeyPairGenerator generator;
+        try {
+            generator = KeyPairGenerator.getInstance(algo, provider);
+        } catch (NoSuchAlgorithmException nsae) {
+            return;
+        }
+
+        System.out.println("Checking " + provider.getName() + ", " + algo);
+
+        KeyPair pair = generator.generateKeyPair();
+        Key key = priv ? pair.getPrivate() : pair.getPublic();
+
+        pair = null;
+        for (int i = 0; i < 32; ++i) {
+            System.gc();
+        }
+
+        try {
+            method.accept(key);
+        } catch (ProviderException pe) {
+            failures++;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/Security/ClassLoader/DeprivilegedModuleLoaderTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import javax.security.auth.kerberos.KeyTab;
+import javax.xml.crypto.KeySelectorException;
+import javax.xml.crypto.dsig.XMLSignatureFactory;
+import com.sun.security.auth.callback.TextCallbackHandler;
+import com.sun.security.jgss.AuthorizationDataEntry;
+
+/*
+ * @test
+ * @bug 8159964
+ * @summary Classes from deprivileged modules should get loaded through
+ *          Platform Classloader.
+ * @run main DeprivilegedModuleLoaderTest
+ */
+public class DeprivilegedModuleLoaderTest {
+
+    public static void main(String[] args) {
+
+        boolean pass = true;
+        List<Class<?>> classes = getDeprivilegedClasses();
+        for (Class<?> cls : classes) {
+            try {
+                pass &= testPlatformClassLoader(cls);
+            } catch (Exception exc) {
+                exc.printStackTrace(System.out);
+                pass = false;
+            }
+        }
+
+        if (!pass) {
+            throw new RuntimeException("Atleast one test failed.");
+        }
+    }
+
+    private static List<Class<?>> getDeprivilegedClasses() {
+
+        List<Class<?>> classes = new ArrayList<Class<?>>();
+        // Test from java.xml.crypto/javax/xml/crypto/dsig package
+        classes.add(XMLSignatureFactory.class);
+        // Test from java.xml.crypto/javax/xml/crypto package
+        classes.add(KeySelectorException.class);
+        // Test From java.security.jgss/javax/security/auth/kerberos package
+        classes.add(KeyTab.class);
+        // Test from jdk.security.jgss/com/sun/security/jgss package
+        classes.add(AuthorizationDataEntry.class);
+        // Test from jdk.security.auth/com/sun/security/auth/callback package
+        classes.add(TextCallbackHandler.class);
+        return classes;
+    }
+
+    private static boolean testPlatformClassLoader(Class<?> cls) {
+
+        ClassLoader loader = cls.getClassLoader();
+        if (loader == null) {
+            throw new RuntimeException(String.format(
+                    "Loaded through Bootstrap Classloader: '%s'", cls));
+        } else if (!loader.toString().contains("PlatformClassLoader")) {
+            throw new RuntimeException(String.format(
+                    "Not loaded through Platform ClassLoader: '%s'", cls));
+        }
+        System.out.println(String.format(
+                "Pass: '%s' get loaded through PlatformClassLoader", cls));
+        return true;
+    }
+}
--- a/jdk/test/java/security/testlibrary/SimpleOCSPServer.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/security/testlibrary/SimpleOCSPServer.java	Fri Aug 19 12:17:32 2016 -0700
@@ -64,6 +64,8 @@
     private static final SimpleDateFormat utcDateFmt =
             new SimpleDateFormat("MMM dd yyyy, HH:mm:ss z");
 
+    static final int FREE_PORT = 0;
+
     // CertStatus values
     public static enum CertStatus {
         CERT_STATUS_GOOD,
@@ -88,7 +90,8 @@
     private volatile boolean started = false;
     private volatile boolean serverReady = false;
     private volatile boolean receivedShutdown = false;
-    private long delayMsec = 0;
+    private volatile boolean acceptConnections = true;
+    private volatile long delayMsec = 0;
 
     // Fields used in the generation of responses
     private long nextUpdateInterval = -1;
@@ -116,7 +119,7 @@
      */
     public SimpleOCSPServer(KeyStore ks, String password, String issuerAlias,
             String signerAlias) throws GeneralSecurityException, IOException {
-        this(null, 0, ks, password, issuerAlias, signerAlias);
+        this(null, FREE_PORT, ks, password, issuerAlias, signerAlias);
     }
 
     /**
@@ -230,6 +233,15 @@
                     while (!receivedShutdown) {
                         try {
                             Socket newConnection = servSocket.accept();
+                            if (!acceptConnections) {
+                                try {
+                                    log("Reject connection");
+                                    newConnection.close();
+                                } catch (IOException e) {
+                                    // ignore
+                                }
+                                continue;
+                            }
                             threadPool.submit(new OcspHandler(newConnection));
                         } catch (SocketTimeoutException timeout) {
                             // Nothing to do here.  If receivedShutdown
@@ -257,6 +269,23 @@
     }
 
     /**
+     * Make the OCSP server reject incoming connections.
+     */
+    public synchronized void rejectConnections() {
+        log("Reject OCSP connections");
+        acceptConnections = false;
+    }
+
+    /**
+     * Make the OCSP server accept incoming connections.
+     */
+    public synchronized void acceptConnections() {
+        log("Accept OCSP connections");
+        acceptConnections = true;
+    }
+
+
+    /**
      * Stop the OCSP server.
      */
     public synchronized void stop() {
@@ -499,13 +528,11 @@
      * on the incoming request.
      */
     public void setDelay(long delayMillis) {
-        if (!started) {
-            delayMsec = delayMillis > 0 ? delayMillis : 0;
-            if (delayMsec > 0) {
-                log("OCSP latency set to " + delayMsec + " milliseconds.");
-            } else {
-                log("OCSP latency disabled");
-            }
+        delayMsec = delayMillis > 0 ? delayMillis : 0;
+        if (delayMsec > 0) {
+            log("OCSP latency set to " + delayMsec + " milliseconds.");
+        } else {
+            log("OCSP latency disabled");
         }
     }
 
--- a/jdk/test/java/util/concurrent/BlockingQueue/PollMemoryLeak.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/BlockingQueue/PollMemoryLeak.java	Fri Aug 19 12:17:32 2016 -0700
@@ -26,43 +26,133 @@
  * However, the following notice accompanied the original version of this
  * file:
  *
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
+ * Written by Doug Lea and Martin Buchholz with assistance from
+ * members of JCP JSR-166 Expert Group and released to the public
+ * domain, as explained at
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 /*
  * @test
  * @bug 6236036 6264015
- * @compile PollMemoryLeak.java
- * @run main/othervm -Xmx8m PollMemoryLeak
- * @summary  Checks for OutOfMemoryError when an unbounded
- * number of aborted timed waits occur without a signal.
+ * @summary Checks for a memory leak when a sequence of aborted timed
+ * waits occur without a signal.  Uses the strategy of detecting
+ * changes in the size of the object graph retained by a root object.
  */
 
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayDeque;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Set;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.LinkedTransferQueue;
+import java.util.concurrent.PriorityBlockingQueue;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.TimeUnit;
 
 public class PollMemoryLeak {
-    public static void main(String[] args) throws InterruptedException {
-        final BlockingQueue[] qs = {
-            new LinkedBlockingDeque(10),
-            new LinkedBlockingQueue(10),
-            new LinkedTransferQueue(),
-            new ArrayBlockingQueue(10),
-            new ArrayBlockingQueue(10, true),
-            new SynchronousQueue(),
-            new SynchronousQueue(true),
-        };
-        final long start = System.currentTimeMillis();
-        final long end = start + 10 * 1000;
-        while (System.currentTimeMillis() < end)
-            for (BlockingQueue q : qs)
-                q.poll(1, TimeUnit.NANOSECONDS);
+    public static void main(String[] args) throws Throwable {
+        new PollMemoryLeak().main();
+    }
+
+    void main() throws Throwable {
+        test(new LinkedBlockingDeque(10));
+        test(new LinkedBlockingQueue(10));
+        test(new LinkedTransferQueue());
+        test(new ArrayBlockingQueue(10));
+        test(new PriorityBlockingQueue());
+        test(new SynchronousQueue());
+        test(new SynchronousQueue(true));
+    }
+
+    void test(BlockingQueue q) throws Throwable {
+        assertNoLeak(q, () -> timedPoll(q));
+
+        // A demo that the leak detection infrastructure works
+        // assertNoLeak(q, () -> q.add(1));
+        // printRetainedObjects(q);
+    }
+
+    static void timedPoll(BlockingQueue q) {
+        try { q.poll(1, TimeUnit.NANOSECONDS); }
+        catch (InterruptedException ex) { throw new AssertionError(ex); }
+    }
+
+    // -------- leak detection infrastructure ---------------
+    void assertNoLeak(Object root, Runnable r) {
+        int prev = retainedObjects(root).size();
+        for (int i = 0; i < 3; i++) {
+            for (int j = 0; j < 3; j++) r.run();
+            int next = retainedObjects(root).size();
+            if (next <= prev)
+                return;
+            prev = next;
+        }
+        throw new AssertionError(
+            String.format("probable memory leak in %s: %s",
+                          root.getClass().getSimpleName(), root));
+    }
+
+    ConcurrentHashMap<Class<?>, Collection<Field>> classFields
+        = new ConcurrentHashMap<Class<?>, Collection<Field>>();
+
+    Collection<Field> referenceFieldsOf(Class<?> k) {
+        Collection<Field> fields = classFields.get(k);
+        if (fields == null) {
+            fields = new ArrayDeque<Field>();
+            ArrayDeque<Field> allFields = new ArrayDeque<Field>();
+            for (Class<?> c = k; c != null; c = c.getSuperclass())
+                for (Field field : c.getDeclaredFields())
+                    if (!Modifier.isStatic(field.getModifiers())
+                        && !field.getType().isPrimitive())
+                        fields.add(field);
+            AccessibleObject.setAccessible(
+                fields.toArray(new AccessibleObject[0]), true);
+            classFields.put(k, fields);
+        }
+        return fields;
+    }
+
+    static Object get(Field field, Object x) {
+        try { return field.get(x); }
+        catch (IllegalAccessException ex) { throw new AssertionError(ex); }
+    }
+
+    Set<Object> retainedObjects(Object x) {
+        ArrayDeque<Object> todo = new ArrayDeque<Object>() {
+            public void push(Object x) { if (x != null) super.push(x); }};
+        Set<Object> uniqueObjects = Collections.newSetFromMap(
+            new IdentityHashMap<Object, Boolean>());
+        todo.push(x);
+        while (!todo.isEmpty()) {
+            Object y = todo.pop();
+            if (uniqueObjects.contains(y))
+                continue;
+            uniqueObjects.add(y);
+            Class<?> k = y.getClass();
+            if (k.isArray() && !k.getComponentType().isPrimitive()) {
+                for (int i = 0, len = Array.getLength(y); i < len; i++)
+                    todo.push(Array.get(y, i));
+            } else {
+                for (Field field : referenceFieldsOf(k))
+                    todo.push(get(field, y));
+            }
+        }
+        return uniqueObjects;
+    }
+
+    /** for debugging the retained object graph */
+    void printRetainedObjects(Object x) {
+        for (Object y : retainedObjects(x))
+            System.out.printf("%s : %s%n", y.getClass().getSimpleName(), y);
     }
 }
--- a/jdk/test/java/util/concurrent/ConcurrentLinkedQueue/RemoveLeak.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/ConcurrentLinkedQueue/RemoveLeak.java	Fri Aug 19 12:17:32 2016 -0700
@@ -35,26 +35,120 @@
  * @test
  * @bug 8054446 8137184 8137185
  * @summary Regression test for memory leak in remove(Object)
- * @run main/othervm -Xmx2200k RemoveLeak
  */
 
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayDeque;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedDeque;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.LinkedTransferQueue;
+import java.util.concurrent.PriorityBlockingQueue;
 
 public class RemoveLeak {
-    public static void main(String[] args) {
-        int i = 0;
-        // Without bug fix, OutOfMemoryError was observed at iteration 65120
-        int iterations = 10 * 65120;
-        try {
-            ConcurrentLinkedQueue<Long> queue = new ConcurrentLinkedQueue<>();
-            queue.add(0L);
-            while (i++ < iterations) {
-                queue.add(1L);
-                queue.remove(1L);
+    public static void main(String[] args) throws Throwable {
+        new RemoveLeak().main();
+    }
+
+    void main() throws Throwable {
+        test(new ConcurrentLinkedDeque());
+        test(new ConcurrentLinkedQueue());
+        test(new LinkedBlockingDeque(10));
+        test(new LinkedBlockingQueue(10));
+        test(new LinkedTransferQueue());
+        test(new ArrayBlockingQueue(10));
+        test(new PriorityBlockingQueue());
+    }
+
+    void test(Collection c) throws Throwable {
+        assertNoLeak(c, () -> addRemove(c));
+
+        // A demo that the leak detection infrastructure works
+        // assertNoLeak(c, () -> c.add(1));
+        // printRetainedObjects(c);
+    }
+
+    static void addRemove(Collection c) {
+        c.add(1);
+        c.remove(1);
+    }
+
+    // -------- leak detection infrastructure ---------------
+    void assertNoLeak(Object root, Runnable r) {
+        int prev = retainedObjects(root).size();
+        for (int i = 0; i < 3; i++) {
+            for (int j = 0; j < 3; j++) r.run();
+            int next = retainedObjects(root).size();
+            if (next <= prev)
+                return;
+            prev = next;
+        }
+        throw new AssertionError(
+            String.format("probable memory leak in %s: %s",
+                          root.getClass().getSimpleName(), root));
+    }
+
+    ConcurrentHashMap<Class<?>, Collection<Field>> classFields
+        = new ConcurrentHashMap<Class<?>, Collection<Field>>();
+
+    Collection<Field> referenceFieldsOf(Class<?> k) {
+        Collection<Field> fields = classFields.get(k);
+        if (fields == null) {
+            fields = new ArrayDeque<Field>();
+            ArrayDeque<Field> allFields = new ArrayDeque<Field>();
+            for (Class<?> c = k; c != null; c = c.getSuperclass())
+                for (Field field : c.getDeclaredFields())
+                    if (!Modifier.isStatic(field.getModifiers())
+                        && !field.getType().isPrimitive())
+                        fields.add(field);
+            AccessibleObject.setAccessible(
+                fields.toArray(new AccessibleObject[0]), true);
+            classFields.put(k, fields);
+        }
+        return fields;
+    }
+
+    static Object get(Field field, Object x) {
+        try { return field.get(x); }
+        catch (IllegalAccessException ex) { throw new AssertionError(ex); }
+    }
+
+    Set<Object> retainedObjects(Object x) {
+        ArrayDeque<Object> todo = new ArrayDeque<Object>() {
+            public void push(Object x) { if (x != null) super.push(x); }};
+        Set<Object> uniqueObjects = Collections.newSetFromMap(
+            new IdentityHashMap<Object, Boolean>());
+        todo.push(x);
+        while (!todo.isEmpty()) {
+            Object y = todo.pop();
+            if (uniqueObjects.contains(y))
+                continue;
+            uniqueObjects.add(y);
+            Class<?> k = y.getClass();
+            if (k.isArray() && !k.getComponentType().isPrimitive()) {
+                for (int i = 0, len = Array.getLength(y); i < len; i++)
+                    todo.push(Array.get(y, i));
+            } else {
+                for (Field field : referenceFieldsOf(k))
+                    todo.push(get(field, y));
             }
-        } catch (Error t) {
-            System.err.printf("failed at iteration %d/%d%n", i, iterations);
-            throw t;
         }
+        return uniqueObjects;
+    }
+
+    /** for debugging the retained object graph */
+    void printRetainedObjects(Object x) {
+        for (Object y : retainedObjects(x))
+            System.out.printf("%s : %s%n", y.getClass().getSimpleName(), y);
     }
 }
--- a/jdk/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java	Fri Aug 19 12:17:32 2016 -0700
@@ -26,51 +26,117 @@
  * However, the following notice accompanied the original version of this
  * file:
  *
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
+ * Written by Doug Lea and Martin Buchholz with assistance from
+ * members of JCP JSR-166 Expert Group and released to the public
+ * domain, as explained at
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 /*
  * @test
- * @author Doug Lea
  * @bug 8004138
- * @key intermittent
- * @summary Check if ForkJoinPool table leaks thrown exceptions.
- * @run main/othervm -Xmx8m -Djava.util.concurrent.ForkJoinPool.common.parallelism=4 FJExceptionTableLeak
+ * @summary Checks that ForkJoinTask thrown exceptions are not leaked.
+ * This whitebox test is sensitive to forkjoin implementation details.
  */
 
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.ForkJoinTask;
 import java.util.concurrent.RecursiveAction;
+import java.util.function.BooleanSupplier;
 
 public class FJExceptionTableLeak {
-    // This test was observed to fail with pre-bug-fix jdk7 -Xmx8m,
-    // using STEPS = 220 and TASKS_PER_STEP = 100
-    static final int PRE_BUG_FIX_FAILURE_STEPS = 220;
-    static final int STEPS = 10 * PRE_BUG_FIX_FAILURE_STEPS;
-    static final int TASKS_PER_STEP = 100;
-
     static class FailingTaskException extends RuntimeException {}
     static class FailingTask extends RecursiveAction {
-        public void compute() {
-            throw new FailingTaskException();
-        }
+        public void compute() { throw new FailingTaskException(); }
+    }
+
+    static int bucketsInuse(Object[] exceptionTable) {
+        int count = 0;
+        for (Object x : exceptionTable)
+            if (x != null) count++;
+        return count;
     }
 
-    public static void main(String[] args) throws InterruptedException {
-        ForkJoinPool pool = new ForkJoinPool(4);
-        FailingTask[] tasks = new FailingTask[TASKS_PER_STEP];
-        for (int k = 0; k < STEPS; ++k) {
-            for (int i = 0; i < tasks.length; ++i)
-                tasks[i] = new FailingTask();
-            for (int i = 0; i < tasks.length; ++i)
-                pool.execute(tasks[i]);
-            for (int i = 0; i < tasks.length; ++i) {
+    public static void main(String[] args) throws Exception {
+        final ForkJoinPool pool = new ForkJoinPool(4);
+        final Field exceptionTableField =
+            ForkJoinTask.class.getDeclaredField("exceptionTable");
+        exceptionTableField.setAccessible(true);
+        final Object[] exceptionTable = (Object[]) exceptionTableField.get(null);
+
+        if (bucketsInuse(exceptionTable) != 0) throw new AssertionError();
+
+        final ArrayList<FailingTask> tasks = new ArrayList<>();
+
+        // Keep submitting failing tasks until most of the exception
+        // table buckets are in use
+        do {
+            for (int i = 0; i < exceptionTable.length; i++) {
+                FailingTask task = new FailingTask();
+                pool.execute(task);
+                tasks.add(task); // retain strong refs to all tasks, for now
+            }
+            for (FailingTask task : tasks) {
                 try {
-                    tasks[i].join();
+                    task.join();
                     throw new AssertionError("should throw");
                 } catch (FailingTaskException success) {}
             }
+        } while (bucketsInuse(exceptionTable) < exceptionTable.length * 3 / 4);
+
+        // Retain a strong ref to one last failing task;
+        // task.join() will trigger exception table expunging.
+        FailingTask lastTask = tasks.get(0);
+
+        // Clear all other strong refs, making exception table cleanable
+        tasks.clear();
+
+        BooleanSupplier exceptionTableIsClean = () -> {
+            try {
+                lastTask.join();
+                throw new AssertionError("should throw");
+            } catch (FailingTaskException expected) {}
+            int count = bucketsInuse(exceptionTable);
+            if (count == 0)
+                throw new AssertionError("expected to find last task");
+            return count == 1;
+        };
+        gcAwait(exceptionTableIsClean);
+    }
+
+    // --------------- GC finalization infrastructure ---------------
+
+    /** No guarantees, but effective in practice. */
+    static void forceFullGc() {
+        CountDownLatch finalizeDone = new CountDownLatch(1);
+        WeakReference<?> ref = new WeakReference<Object>(new Object() {
+            protected void finalize() { finalizeDone.countDown(); }});
+        try {
+            for (int i = 0; i < 10; i++) {
+                System.gc();
+                if (finalizeDone.await(1L, SECONDS) && ref.get() == null) {
+                    System.runFinalization(); // try to pick up stragglers
+                    return;
+                }
+            }
+        } catch (InterruptedException unexpected) {
+            throw new AssertionError("unexpected InterruptedException");
         }
+        throw new AssertionError("failed to do a \"full\" gc");
+    }
+
+    static void gcAwait(BooleanSupplier s) {
+        for (int i = 0; i < 10; i++) {
+            if (s.getAsBoolean())
+                return;
+            forceFullGc();
+        }
+        throw new AssertionError("failed to satisfy condition");
     }
 }
--- a/jdk/test/java/util/concurrent/tck/ArrayBlockingQueueTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/ArrayBlockingQueueTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -492,7 +492,7 @@
             }});
 
         await(aboutToWait);
-        waitForThreadToEnterWaitState(t, LONG_DELAY_MS);
+        waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
         checkEmpty(q);
--- a/jdk/test/java/util/concurrent/tck/AtomicBooleanTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/AtomicBooleanTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -136,11 +136,14 @@
      * getAndSet returns previous value and sets to given value
      */
     public void testGetAndSet() {
-        AtomicBoolean ai = new AtomicBoolean(true);
-        assertEquals(true, ai.getAndSet(false));
-        assertEquals(false, ai.getAndSet(false));
-        assertEquals(false, ai.getAndSet(true));
-        assertTrue(ai.get());
+        AtomicBoolean ai = new AtomicBoolean();
+        boolean[] booleans = { false, true };
+        for (boolean before : booleans)
+            for (boolean after : booleans) {
+                ai.set(before);
+                assertEquals(before, ai.getAndSet(after));
+                assertEquals(after, ai.get());
+            }
     }
 
     /**
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java	Fri Aug 19 12:17:32 2016 -0700
@@ -433,7 +433,7 @@
         Integer[] elements = new Integer[size];
         for (int i = 0; i < size; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedSet(elements);
 
         Iterator it = full.iterator();
@@ -523,7 +523,7 @@
         Integer[] elements = new Integer[size];
         for (int i = 0; i < size; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedSet(elements);
 
         assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray())));
@@ -553,7 +553,7 @@
         Integer[] elements = new Integer[size];
         for (int i = 0; i < size; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedSet(elements);
 
         Arrays.fill(a, 42);
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -291,7 +291,7 @@
         Integer[] elements = new Integer[SIZE];
         for (int i = 0; i < SIZE; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedArray(elements);
 
         Iterator it = full.iterator();
@@ -459,7 +459,7 @@
         Integer[] elements = new Integer[SIZE];
         for (int i = 0; i < SIZE; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedArray(elements);
 
         assertTrue(Arrays.equals(elements, full.toArray()));
@@ -487,7 +487,7 @@
         Integer[] elements = new Integer[SIZE];
         for (int i = 0; i < SIZE; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedArray(elements);
 
         Arrays.fill(a, 42);
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -251,7 +251,7 @@
         Integer[] elements = new Integer[SIZE];
         for (int i = 0; i < SIZE; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedSet(elements);
 
         Iterator it = full.iterator();
@@ -338,7 +338,7 @@
         Integer[] elements = new Integer[SIZE];
         for (int i = 0; i < SIZE; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedSet(elements);
 
         assertTrue(Arrays.equals(elements, full.toArray()));
@@ -366,7 +366,7 @@
         Integer[] elements = new Integer[SIZE];
         for (int i = 0; i < SIZE; i++)
             elements[i] = i;
-        Collections.shuffle(Arrays.asList(elements));
+        shuffle(elements);
         Collection<Integer> full = populatedSet(elements);
 
         Arrays.fill(a, 42);
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java	Fri Aug 19 12:17:32 2016 -0700
@@ -948,7 +948,7 @@
                 AsyncFib f = new AsyncFib(8);
                 FailingAsyncFib g = new FailingAsyncFib(9);
                 ForkJoinTask[] tasks = { f, g };
-                Collections.shuffle(Arrays.asList(tasks));
+                shuffle(tasks);
                 try {
                     invokeAll(tasks[0], tasks[1]);
                     shouldThrow();
@@ -975,7 +975,7 @@
                 FailingAsyncFib g = new FailingAsyncFib(9);
                 AsyncFib h = new AsyncFib(7);
                 ForkJoinTask[] tasks = { f, g, h };
-                Collections.shuffle(Arrays.asList(tasks));
+                shuffle(tasks);
                 try {
                     invokeAll(tasks[0], tasks[1], tasks[2]);
                     shouldThrow();
@@ -1002,7 +1002,7 @@
                 AsyncFib g = new AsyncFib(9);
                 AsyncFib h = new AsyncFib(7);
                 ForkJoinTask[] tasks = { f, g, h };
-                Collections.shuffle(Arrays.asList(tasks));
+                shuffle(tasks);
                 try {
                     invokeAll(Arrays.asList(tasks));
                     shouldThrow();
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -924,7 +924,7 @@
                 AsyncFib f = new AsyncFib(8);
                 FailingAsyncFib g = new FailingAsyncFib(9);
                 ForkJoinTask[] tasks = { f, g };
-                Collections.shuffle(Arrays.asList(tasks));
+                shuffle(tasks);
                 try {
                     invokeAll(tasks);
                     shouldThrow();
@@ -962,7 +962,7 @@
                 FailingAsyncFib g = new FailingAsyncFib(9);
                 AsyncFib h = new AsyncFib(7);
                 ForkJoinTask[] tasks = { f, g, h };
-                Collections.shuffle(Arrays.asList(tasks));
+                shuffle(tasks);
                 try {
                     invokeAll(tasks);
                     shouldThrow();
@@ -983,10 +983,9 @@
                 AsyncFib g = new AsyncFib(9);
                 AsyncFib h = new AsyncFib(7);
                 ForkJoinTask[] tasks = { f, g, h };
-                List taskList = Arrays.asList(tasks);
-                Collections.shuffle(taskList);
+                shuffle(tasks);
                 try {
-                    invokeAll(taskList);
+                    invokeAll(Arrays.asList(tasks));
                     shouldThrow();
                 } catch (FJException success) {
                     checkCompletedAbnormally(f, success);
@@ -1594,7 +1593,7 @@
                 AsyncFib f = new AsyncFib(8);
                 FailingAsyncFib g = new FailingAsyncFib(9);
                 ForkJoinTask[] tasks = { f, g };
-                Collections.shuffle(Arrays.asList(tasks));
+                shuffle(tasks);
                 try {
                     invokeAll(tasks);
                     shouldThrow();
@@ -1632,7 +1631,7 @@
                 FailingAsyncFib g = new FailingAsyncFib(9);
                 AsyncFib h = new AsyncFib(7);
                 ForkJoinTask[] tasks = { f, g, h };
-                Collections.shuffle(Arrays.asList(tasks));
+                shuffle(tasks);
                 try {
                     invokeAll(tasks);
                     shouldThrow();
@@ -1653,10 +1652,9 @@
                 AsyncFib g = new AsyncFib(9);
                 AsyncFib h = new AsyncFib(7);
                 ForkJoinTask[] tasks = { f, g, h };
-                List taskList = Arrays.asList(tasks);
-                Collections.shuffle(taskList);
+                shuffle(tasks);
                 try {
-                    invokeAll(taskList);
+                    invokeAll(Arrays.asList(tasks));
                     shouldThrow();
                 } catch (FJException success) {
                     checkCompletedAbnormally(f, success);
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java	Fri Aug 19 12:17:32 2016 -0700
@@ -68,6 +68,7 @@
 import java.security.SecurityPermission;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Iterator;
@@ -89,6 +90,7 @@
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -1278,7 +1280,7 @@
      * thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING.
      */
     void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) {
-        long startTime = System.nanoTime();
+        long startTime = 0L;
         for (;;) {
             Thread.State s = thread.getState();
             if (s == Thread.State.BLOCKED ||
@@ -1287,6 +1289,8 @@
                 return;
             else if (s == Thread.State.TERMINATED)
                 fail("Unexpected thread termination");
+            else if (startTime == 0L)
+                startTime = System.nanoTime();
             else if (millisElapsedSince(startTime) > timeoutMillis) {
                 threadAssertTrue(thread.isAlive());
                 return;
@@ -1900,4 +1904,7 @@
                                1000L, MILLISECONDS,
                                new SynchronousQueue<Runnable>());
 
+    static <T> void shuffle(T[] array) {
+        Collections.shuffle(Arrays.asList(array), ThreadLocalRandom.current());
+    }
 }
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -792,7 +792,7 @@
             }});
 
         aboutToWait.await();
-        waitForThreadToEnterWaitState(t, LONG_DELAY_MS);
+        waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
         checkEmpty(q);
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -481,7 +481,7 @@
             }});
 
         await(aboutToWait);
-        waitForThreadToEnterWaitState(t, LONG_DELAY_MS);
+        waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
         checkEmpty(q);
--- a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -437,7 +437,7 @@
             }});
 
         aboutToWait.await();
-        waitForThreadToEnterWaitState(t, LONG_DELAY_MS);
+        waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
     }
--- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -34,10 +34,12 @@
 
 import static java.util.concurrent.TimeUnit.DAYS;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.StampedLock;
@@ -57,207 +59,188 @@
     }
 
     /**
-     * A runnable calling writeLockInterruptibly
+     * Releases write lock, checking isWriteLocked before and after
      */
-    class InterruptibleLockRunnable extends CheckedRunnable {
-        final StampedLock lock;
-        InterruptibleLockRunnable(StampedLock l) { lock = l; }
-        public void realRun() throws InterruptedException {
-            lock.writeLockInterruptibly();
-        }
+    void releaseWriteLock(StampedLock lock, long stamp) {
+        assertTrue(lock.isWriteLocked());
+        assertValid(lock, stamp);
+        lock.unlockWrite(stamp);
+        assertFalse(lock.isWriteLocked());
+        assertFalse(lock.validate(stamp));
     }
 
     /**
-     * A runnable calling writeLockInterruptibly that expects to be
-     * interrupted
+     * Releases read lock, checking isReadLocked before and after
      */
-    class InterruptedLockRunnable extends CheckedInterruptedRunnable {
-        final StampedLock lock;
-        InterruptedLockRunnable(StampedLock l) { lock = l; }
-        public void realRun() throws InterruptedException {
-            lock.writeLockInterruptibly();
-        }
+    void releaseReadLock(StampedLock lock, long stamp) {
+        assertTrue(lock.isReadLocked());
+        assertValid(lock, stamp);
+        lock.unlockRead(stamp);
+        assertFalse(lock.isReadLocked());
+        assertTrue(lock.validate(stamp));
+    }
+
+    long assertNonZero(long v) {
+        assertTrue(v != 0L);
+        return v;
+    }
+
+    long assertValid(StampedLock lock, long stamp) {
+        assertTrue(stamp != 0L);
+        assertTrue(lock.validate(stamp));
+        return stamp;
+    }
+
+    void assertUnlocked(StampedLock lock) {
+        assertFalse(lock.isReadLocked());
+        assertFalse(lock.isWriteLocked());
+        assertEquals(0, lock.getReadLockCount());
+        assertValid(lock, lock.tryOptimisticRead());
+    }
+
+    List<Action> lockLockers(Lock lock) {
+        List<Action> lockers = new ArrayList<>();
+        lockers.add(() -> lock.lock());
+        lockers.add(() -> lock.lockInterruptibly());
+        lockers.add(() -> lock.tryLock());
+        lockers.add(() -> lock.tryLock(Long.MIN_VALUE, DAYS));
+        lockers.add(() -> lock.tryLock(0L, DAYS));
+        lockers.add(() -> lock.tryLock(Long.MAX_VALUE, DAYS));
+        return lockers;
     }
 
-    /**
-     * Releases write lock, checking isWriteLocked before and after
-     */
-    void releaseWriteLock(StampedLock lock, long s) {
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(s);
-        assertFalse(lock.isWriteLocked());
+    List<Function<StampedLock, Long>> readLockers() {
+        List<Function<StampedLock, Long>> readLockers = new ArrayList<>();
+        readLockers.add((sl) -> sl.readLock());
+        readLockers.add((sl) -> sl.tryReadLock());
+        readLockers.add((sl) -> readLockInterruptiblyUninterrupted(sl));
+        readLockers.add((sl) -> tryReadLockUninterrupted(sl, Long.MIN_VALUE, DAYS));
+        readLockers.add((sl) -> tryReadLockUninterrupted(sl, 0L, DAYS));
+        readLockers.add((sl) -> sl.tryConvertToReadLock(sl.tryOptimisticRead()));
+        return readLockers;
+    }
+
+    List<BiConsumer<StampedLock, Long>> readUnlockers() {
+        List<BiConsumer<StampedLock, Long>> readUnlockers = new ArrayList<>();
+        readUnlockers.add((sl, stamp) -> sl.unlockRead(stamp));
+        readUnlockers.add((sl, stamp) -> assertTrue(sl.tryUnlockRead()));
+        readUnlockers.add((sl, stamp) -> sl.asReadLock().unlock());
+        readUnlockers.add((sl, stamp) -> sl.unlock(stamp));
+        readUnlockers.add((sl, stamp) -> assertValid(sl, sl.tryConvertToOptimisticRead(stamp)));
+        return readUnlockers;
+    }
+
+    List<Function<StampedLock, Long>> writeLockers() {
+        List<Function<StampedLock, Long>> writeLockers = new ArrayList<>();
+        writeLockers.add((sl) -> sl.writeLock());
+        writeLockers.add((sl) -> sl.tryWriteLock());
+        writeLockers.add((sl) -> writeLockInterruptiblyUninterrupted(sl));
+        writeLockers.add((sl) -> tryWriteLockUninterrupted(sl, Long.MIN_VALUE, DAYS));
+        writeLockers.add((sl) -> tryWriteLockUninterrupted(sl, 0L, DAYS));
+        writeLockers.add((sl) -> sl.tryConvertToWriteLock(sl.tryOptimisticRead()));
+        return writeLockers;
+    }
+
+    List<BiConsumer<StampedLock, Long>> writeUnlockers() {
+        List<BiConsumer<StampedLock, Long>> writeUnlockers = new ArrayList<>();
+        writeUnlockers.add((sl, stamp) -> sl.unlockWrite(stamp));
+        writeUnlockers.add((sl, stamp) -> assertTrue(sl.tryUnlockWrite()));
+        writeUnlockers.add((sl, stamp) -> sl.asWriteLock().unlock());
+        writeUnlockers.add((sl, stamp) -> sl.unlock(stamp));
+        writeUnlockers.add((sl, stamp) -> assertValid(sl, sl.tryConvertToOptimisticRead(stamp)));
+        return writeUnlockers;
     }
 
     /**
      * Constructed StampedLock is in unlocked state
      */
     public void testConstructor() {
-        StampedLock lock;
-        lock = new StampedLock();
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
+        assertUnlocked(new StampedLock());
     }
 
     /**
-     * write-locking and read-locking an unlocked lock succeed
+     * write-locking, then unlocking, an unlocked lock succeed
      */
-    public void testLock() {
+    public void testWriteLock_lockUnlock() {
         StampedLock lock = new StampedLock();
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        long s = lock.writeLock();
-        assertTrue(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        lock.unlockWrite(s);
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        long rs = lock.readLock();
-        assertFalse(lock.isWriteLocked());
-        assertTrue(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 1);
-        lock.unlockRead(rs);
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-    }
 
-    /**
-     * unlock releases either a read or write lock
-     */
-    public void testUnlock() {
-        StampedLock lock = new StampedLock();
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        long s = lock.writeLock();
-        assertTrue(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        lock.unlock(s);
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        long rs = lock.readLock();
-        assertFalse(lock.isWriteLocked());
-        assertTrue(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 1);
-        lock.unlock(rs);
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
+        for (Function<StampedLock, Long> writeLocker : writeLockers())
+        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers()) {
+            assertFalse(lock.isWriteLocked());
+            assertFalse(lock.isReadLocked());
+            assertEquals(0, lock.getReadLockCount());
+
+            long s = writeLocker.apply(lock);
+            assertValid(lock, s);
+            assertTrue(lock.isWriteLocked());
+            assertFalse(lock.isReadLocked());
+            assertEquals(0, lock.getReadLockCount());
+            writeUnlocker.accept(lock, s);
+            assertUnlocked(lock);
+        }
     }
 
     /**
-     * tryUnlockRead/Write succeeds if locked in associated mode else
-     * returns false
+     * read-locking, then unlocking, an unlocked lock succeed
      */
-    public void testTryUnlock() {
+    public void testReadLock_lockUnlock() {
         StampedLock lock = new StampedLock();
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        long s = lock.writeLock();
-        assertTrue(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        assertFalse(lock.tryUnlockRead());
-        assertTrue(lock.tryUnlockWrite());
-        assertFalse(lock.tryUnlockWrite());
-        assertFalse(lock.tryUnlockRead());
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-        long rs = lock.readLock();
-        assertFalse(lock.isWriteLocked());
-        assertTrue(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 1);
-        assertFalse(lock.tryUnlockWrite());
-        assertTrue(lock.tryUnlockRead());
-        assertFalse(lock.tryUnlockRead());
-        assertFalse(lock.tryUnlockWrite());
-        assertFalse(lock.isWriteLocked());
-        assertFalse(lock.isReadLocked());
-        assertEquals(lock.getReadLockCount(), 0);
-    }
 
-    /**
-     * write-unlocking an unlocked lock throws IllegalMonitorStateException
-     */
-    public void testWriteUnlock_IMSE() {
-        StampedLock lock = new StampedLock();
-        try {
-            lock.unlockWrite(0L);
-            shouldThrow();
-        } catch (IllegalMonitorStateException success) {}
+        for (Function<StampedLock, Long> readLocker : readLockers())
+        for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers()) {
+            long s = 42;
+            for (int i = 0; i < 2; i++) {
+                s = assertValid(lock, readLocker.apply(lock));
+                assertFalse(lock.isWriteLocked());
+                assertTrue(lock.isReadLocked());
+                assertEquals(i + 1, lock.getReadLockCount());
+            }
+            for (int i = 0; i < 2; i++) {
+                assertFalse(lock.isWriteLocked());
+                assertTrue(lock.isReadLocked());
+                assertEquals(2 - i, lock.getReadLockCount());
+                readUnlocker.accept(lock, s);
+            }
+            assertUnlocked(lock);
+        }
     }
 
     /**
-     * write-unlocking an unlocked lock throws IllegalMonitorStateException
+     * tryUnlockWrite fails if not write locked
      */
-    public void testWriteUnlock_IMSE2() {
+    public void testTryUnlockWrite_failure() {
         StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        lock.unlockWrite(s);
-        try {
-            lock.unlockWrite(s);
-            shouldThrow();
-        } catch (IllegalMonitorStateException success) {}
-    }
+        assertFalse(lock.tryUnlockWrite());
 
-    /**
-     * write-unlocking after readlock throws IllegalMonitorStateException
-     */
-    public void testWriteUnlock_IMSE3() {
-        StampedLock lock = new StampedLock();
-        long s = lock.readLock();
-        try {
-            lock.unlockWrite(s);
-            shouldThrow();
-        } catch (IllegalMonitorStateException success) {}
+        for (Function<StampedLock, Long> readLocker : readLockers())
+        for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers()) {
+            long s = assertValid(lock, readLocker.apply(lock));
+            assertFalse(lock.tryUnlockWrite());
+            assertTrue(lock.isReadLocked());
+            readUnlocker.accept(lock, s);
+            assertUnlocked(lock);
+        }
     }
 
     /**
-     * read-unlocking an unlocked lock throws IllegalMonitorStateException
+     * tryUnlockRead fails if not read locked
      */
-    public void testReadUnlock_IMSE() {
+    public void testTryUnlockRead_failure() {
         StampedLock lock = new StampedLock();
-        long s = lock.readLock();
-        lock.unlockRead(s);
-        try {
-            lock.unlockRead(s);
-            shouldThrow();
-        } catch (IllegalMonitorStateException success) {}
+        assertFalse(lock.tryUnlockRead());
+
+        for (Function<StampedLock, Long> writeLocker : writeLockers())
+        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers()) {
+            long s = writeLocker.apply(lock);
+            assertFalse(lock.tryUnlockRead());
+            assertTrue(lock.isWriteLocked());
+            writeUnlocker.accept(lock, s);
+            assertUnlocked(lock);
+        }
     }
 
     /**
-     * read-unlocking an unlocked lock throws IllegalMonitorStateException
-     */
-    public void testReadUnlock_IMSE2() {
-        StampedLock lock = new StampedLock();
-        try {
-            lock.unlockRead(0L);
-            shouldThrow();
-        } catch (IllegalMonitorStateException success) {}
-    }
-
-    /**
-     * read-unlocking after writeLock throws IllegalMonitorStateException
-     */
-    public void testReadUnlock_IMSE3() {
-        StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        try {
-            lock.unlockRead(s);
-            shouldThrow();
-        } catch (IllegalMonitorStateException success) {}
-    }
-
-    /**
-     * validate(0) fails
+     * validate(0L) fails
      */
     public void testValidate0() {
         StampedLock lock = new StampedLock();
@@ -265,29 +248,24 @@
     }
 
     /**
-     * A stamp obtained from a successful lock operation validates
+     * A stamp obtained from a successful lock operation validates while the lock is held
      */
     public void testValidate() throws InterruptedException {
         StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        assertTrue(lock.validate(s));
-        lock.unlockWrite(s);
-        s = lock.readLock();
-        assertTrue(lock.validate(s));
-        lock.unlockRead(s);
-        assertTrue((s = lock.tryWriteLock()) != 0L);
-        assertTrue(lock.validate(s));
-        lock.unlockWrite(s);
-        assertTrue((s = lock.tryReadLock()) != 0L);
-        assertTrue(lock.validate(s));
-        lock.unlockRead(s);
-        assertTrue((s = lock.tryWriteLock(100L, MILLISECONDS)) != 0L);
-        assertTrue(lock.validate(s));
-        lock.unlockWrite(s);
-        assertTrue((s = lock.tryReadLock(100L, MILLISECONDS)) != 0L);
-        assertTrue(lock.validate(s));
-        lock.unlockRead(s);
-        assertTrue((s = lock.tryOptimisticRead()) != 0L);
+
+        for (Function<StampedLock, Long> readLocker : readLockers())
+        for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers()) {
+            long s = assertNonZero(readLocker.apply(lock));
+            assertTrue(lock.validate(s));
+            readUnlocker.accept(lock, s);
+        }
+
+        for (Function<StampedLock, Long> writeLocker : writeLockers())
+        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers()) {
+            long s = assertNonZero(writeLocker.apply(lock));
+            assertTrue(lock.validate(s));
+            writeUnlocker.accept(lock, s);
+        }
     }
 
     /**
@@ -295,124 +273,190 @@
      */
     public void testValidate2() throws InterruptedException {
         StampedLock lock = new StampedLock();
-        long s;
-        assertTrue((s = lock.writeLock()) != 0L);
+        long s = assertNonZero(lock.writeLock());
         assertTrue(lock.validate(s));
         assertFalse(lock.validate(lock.tryWriteLock()));
-        assertFalse(lock.validate(lock.tryWriteLock(10L, MILLISECONDS)));
+        assertFalse(lock.validate(lock.tryWriteLock(0L, SECONDS)));
         assertFalse(lock.validate(lock.tryReadLock()));
-        assertFalse(lock.validate(lock.tryReadLock(10L, MILLISECONDS)));
+        assertFalse(lock.validate(lock.tryReadLock(0L, SECONDS)));
         assertFalse(lock.validate(lock.tryOptimisticRead()));
         lock.unlockWrite(s);
     }
 
-    /**
-     * writeLockInterruptibly is interruptible
-     */
-    public void testWriteLockInterruptibly_Interruptible()
-            throws InterruptedException {
-        final CountDownLatch running = new CountDownLatch(1);
-        final StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
-            public void realRun() throws InterruptedException {
-                running.countDown();
-                lock.writeLockInterruptibly();
-            }});
-
-        running.await();
-        waitForThreadToEnterWaitState(t, 100);
-        t.interrupt();
-        awaitTermination(t);
-        releaseWriteLock(lock, s);
+    void assertThrowInterruptedExceptionWhenPreInterrupted(Action[] actions) {
+        for (Action action : actions) {
+            Thread.currentThread().interrupt();
+            try {
+                action.run();
+                shouldThrow();
+            }
+            catch (InterruptedException success) {}
+            catch (Throwable fail) { threadUnexpectedException(fail); }
+            assertFalse(Thread.interrupted());
+        }
     }
 
     /**
-     * timed tryWriteLock is interruptible
+     * interruptible operations throw InterruptedException when pre-interrupted
      */
-    public void testWriteTryLock_Interruptible() throws InterruptedException {
+    public void testInterruptibleOperationsThrowInterruptedExceptionWhenPreInterrupted() {
+        final CountDownLatch running = new CountDownLatch(1);
+        final StampedLock lock = new StampedLock();
+
+        Action[] interruptibleLockActions = {
+            () -> lock.writeLockInterruptibly(),
+            () -> lock.tryWriteLock(Long.MIN_VALUE, DAYS),
+            () -> lock.tryWriteLock(Long.MAX_VALUE, DAYS),
+            () -> lock.readLockInterruptibly(),
+            () -> lock.tryReadLock(Long.MIN_VALUE, DAYS),
+            () -> lock.tryReadLock(Long.MAX_VALUE, DAYS),
+            () -> lock.asWriteLock().lockInterruptibly(),
+            () -> lock.asWriteLock().tryLock(0L, DAYS),
+            () -> lock.asWriteLock().tryLock(Long.MAX_VALUE, DAYS),
+            () -> lock.asReadLock().lockInterruptibly(),
+            () -> lock.asReadLock().tryLock(0L, DAYS),
+            () -> lock.asReadLock().tryLock(Long.MAX_VALUE, DAYS),
+        };
+        shuffle(interruptibleLockActions);
+
+        assertThrowInterruptedExceptionWhenPreInterrupted(interruptibleLockActions);
+        {
+            long s = lock.writeLock();
+            assertThrowInterruptedExceptionWhenPreInterrupted(interruptibleLockActions);
+            lock.unlockWrite(s);
+        }
+        {
+            long s = lock.readLock();
+            assertThrowInterruptedExceptionWhenPreInterrupted(interruptibleLockActions);
+            lock.unlockRead(s);
+        }
+    }
+
+    void assertThrowInterruptedExceptionWhenInterrupted(Action[] actions) {
+        int n = actions.length;
+        Future<?>[] futures = new Future<?>[n];
+        CountDownLatch threadsStarted = new CountDownLatch(n);
+        CountDownLatch done = new CountDownLatch(n);
+
+        for (int i = 0; i < n; i++) {
+            Action action = actions[i];
+            futures[i] = cachedThreadPool.submit(new CheckedRunnable() {
+                public void realRun() throws Throwable {
+                    threadsStarted.countDown();
+                    try {
+                        action.run();
+                        shouldThrow();
+                    }
+                    catch (InterruptedException success) {}
+                    catch (Throwable fail) { threadUnexpectedException(fail); }
+                    assertFalse(Thread.interrupted());
+                    done.countDown();
+                }});
+        }
+
+        await(threadsStarted);
+        assertEquals(n, done.getCount());
+        for (Future<?> future : futures) // Interrupt all the tasks
+            future.cancel(true);
+        await(done);
+    }
+
+    /**
+     * interruptible operations throw InterruptedException when write locked and interrupted
+     */
+    public void testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInterrupted() {
         final CountDownLatch running = new CountDownLatch(1);
         final StampedLock lock = new StampedLock();
         long s = lock.writeLock();
-        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
-            public void realRun() throws InterruptedException {
-                running.countDown();
-                lock.tryWriteLock(2 * LONG_DELAY_MS, MILLISECONDS);
-            }});
 
-        running.await();
-        waitForThreadToEnterWaitState(t, 100);
-        t.interrupt();
-        awaitTermination(t);
-        releaseWriteLock(lock, s);
+        Action[] interruptibleLockBlockingActions = {
+            () -> lock.writeLockInterruptibly(),
+            () -> lock.tryWriteLock(Long.MAX_VALUE, DAYS),
+            () -> lock.readLockInterruptibly(),
+            () -> lock.tryReadLock(Long.MAX_VALUE, DAYS),
+            () -> lock.asWriteLock().lockInterruptibly(),
+            () -> lock.asWriteLock().tryLock(Long.MAX_VALUE, DAYS),
+            () -> lock.asReadLock().lockInterruptibly(),
+            () -> lock.asReadLock().tryLock(Long.MAX_VALUE, DAYS),
+        };
+        shuffle(interruptibleLockBlockingActions);
+
+        assertThrowInterruptedExceptionWhenInterrupted(interruptibleLockBlockingActions);
     }
 
     /**
-     * readLockInterruptibly is interruptible
+     * interruptible operations throw InterruptedException when read locked and interrupted
      */
-    public void testReadLockInterruptibly_Interruptible()
-            throws InterruptedException {
+    public void testInterruptibleOperationsThrowInterruptedExceptionReadLockedInterrupted() {
         final CountDownLatch running = new CountDownLatch(1);
         final StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
-            public void realRun() throws InterruptedException {
-                running.countDown();
-                lock.readLockInterruptibly();
-            }});
+        long s = lock.readLock();
 
-        running.await();
-        waitForThreadToEnterWaitState(t, 100);
-        t.interrupt();
-        awaitTermination(t);
-        releaseWriteLock(lock, s);
+        Action[] interruptibleLockBlockingActions = {
+            () -> lock.writeLockInterruptibly(),
+            () -> lock.tryWriteLock(Long.MAX_VALUE, DAYS),
+            () -> lock.asWriteLock().lockInterruptibly(),
+            () -> lock.asWriteLock().tryLock(Long.MAX_VALUE, DAYS),
+        };
+        shuffle(interruptibleLockBlockingActions);
+
+        assertThrowInterruptedExceptionWhenInterrupted(interruptibleLockBlockingActions);
     }
 
     /**
-     * timed tryReadLock is interruptible
+     * Non-interruptible operations ignore and preserve interrupt status
      */
-    public void testReadTryLock_Interruptible() throws InterruptedException {
-        final CountDownLatch running = new CountDownLatch(1);
+    public void testNonInterruptibleOperationsIgnoreInterrupts() {
         final StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
-            public void realRun() throws InterruptedException {
-                running.countDown();
-                lock.tryReadLock(2 * LONG_DELAY_MS, MILLISECONDS);
-            }});
+        Thread.currentThread().interrupt();
+
+        for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers()) {
+            long s = assertValid(lock, lock.readLock());
+            readUnlocker.accept(lock, s);
+            s = assertValid(lock, lock.tryReadLock());
+            readUnlocker.accept(lock, s);
+        }
+
+        lock.asReadLock().lock();
+        lock.asReadLock().unlock();
 
-        running.await();
-        waitForThreadToEnterWaitState(t, 100);
-        t.interrupt();
-        awaitTermination(t);
-        releaseWriteLock(lock, s);
+        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers()) {
+            long s = assertValid(lock, lock.writeLock());
+            writeUnlocker.accept(lock, s);
+            s = assertValid(lock, lock.tryWriteLock());
+            writeUnlocker.accept(lock, s);
+        }
+
+        lock.asWriteLock().lock();
+        lock.asWriteLock().unlock();
+
+        assertTrue(Thread.interrupted());
     }
 
     /**
      * tryWriteLock on an unlocked lock succeeds
      */
-    public void testWriteTryLock() {
+    public void testTryWriteLock() {
         final StampedLock lock = new StampedLock();
         long s = lock.tryWriteLock();
         assertTrue(s != 0L);
         assertTrue(lock.isWriteLocked());
-        long s2 = lock.tryWriteLock();
-        assertEquals(s2, 0L);
+        assertEquals(0L, lock.tryWriteLock());
         releaseWriteLock(lock, s);
     }
 
     /**
      * tryWriteLock fails if locked
      */
-    public void testWriteTryLockWhenLocked() {
+    public void testTryWriteLockWhenLocked() {
         final StampedLock lock = new StampedLock();
         long s = lock.writeLock();
         Thread t = newStartedThread(new CheckedRunnable() {
             public void realRun() {
-                long ws = lock.tryWriteLock();
-                assertTrue(ws == 0L);
+                assertEquals(0L, lock.tryWriteLock());
             }});
 
+        assertEquals(0L, lock.tryWriteLock());
         awaitTermination(t);
         releaseWriteLock(lock, s);
     }
@@ -420,15 +464,15 @@
     /**
      * tryReadLock fails if write-locked
      */
-    public void testReadTryLockWhenLocked() {
+    public void testTryReadLockWhenLocked() {
         final StampedLock lock = new StampedLock();
         long s = lock.writeLock();
         Thread t = newStartedThread(new CheckedRunnable() {
             public void realRun() {
-                long rs = lock.tryReadLock();
-                assertEquals(rs, 0L);
+                assertEquals(0L, lock.tryReadLock());
             }});
 
+        assertEquals(0L, lock.tryReadLock());
         awaitTermination(t);
         releaseWriteLock(lock, s);
     }
@@ -442,13 +486,20 @@
         Thread t = newStartedThread(new CheckedRunnable() {
             public void realRun() throws InterruptedException {
                 long s2 = lock.tryReadLock();
-                assertTrue(s2 != 0L);
+                assertValid(lock, s2);
                 lock.unlockRead(s2);
                 long s3 = lock.tryReadLock(LONG_DELAY_MS, MILLISECONDS);
-                assertTrue(s3 != 0L);
+                assertValid(lock, s3);
                 lock.unlockRead(s3);
                 long s4 = lock.readLock();
+                assertValid(lock, s4);
                 lock.unlockRead(s4);
+                lock.asReadLock().lock();
+                lock.asReadLock().unlock();
+                lock.asReadLock().lockInterruptibly();
+                lock.asReadLock().unlock();
+                lock.asReadLock().tryLock(Long.MIN_VALUE, DAYS);
+                lock.asReadLock().unlock();
             }});
 
         awaitTermination(t);
@@ -470,7 +521,7 @@
             }});
 
         running.await();
-        waitForThreadToEnterWaitState(t, 100);
+        waitForThreadToEnterWaitState(t, MEDIUM_DELAY_MS);
         assertFalse(lock.isWriteLocked());
         lock.unlockRead(rs);
         awaitTermination(t);
@@ -497,6 +548,7 @@
                 lock.unlockWrite(ws);
             }});
 
+        assertTrue(lock.isReadLocked());
         assertFalse(lock.isWriteLocked());
         lock.unlockRead(s);
         awaitTermination(t2);
@@ -508,25 +560,31 @@
      */
     public void testReadAfterWriteLock() {
         final StampedLock lock = new StampedLock();
+        final CountDownLatch threadsStarted = new CountDownLatch(2);
         final long s = lock.writeLock();
         Thread t1 = newStartedThread(new CheckedRunnable() {
             public void realRun() {
+                threadsStarted.countDown();
                 long rs = lock.readLock();
                 lock.unlockRead(rs);
             }});
         Thread t2 = newStartedThread(new CheckedRunnable() {
             public void realRun() {
+                threadsStarted.countDown();
                 long rs = lock.readLock();
                 lock.unlockRead(rs);
             }});
 
+        await(threadsStarted);
+        waitForThreadToEnterWaitState(t1, MEDIUM_DELAY_MS);
+        waitForThreadToEnterWaitState(t2, MEDIUM_DELAY_MS);
         releaseWriteLock(lock, s);
         awaitTermination(t1);
         awaitTermination(t2);
     }
 
     /**
-     * tryReadLock succeeds if readlocked but not writelocked
+     * tryReadLock succeeds if read locked but not write locked
      */
     public void testTryLockWhenReadLocked() {
         final StampedLock lock = new StampedLock();
@@ -534,7 +592,7 @@
         Thread t = newStartedThread(new CheckedRunnable() {
             public void realRun() {
                 long rs = lock.tryReadLock();
-                threadAssertTrue(rs != 0L);
+                assertValid(lock, rs);
                 lock.unlockRead(rs);
             }});
 
@@ -543,15 +601,14 @@
     }
 
     /**
-     * tryWriteLock fails when readlocked
+     * tryWriteLock fails when read locked
      */
-    public void testWriteTryLockWhenReadLocked() {
+    public void testTryWriteLockWhenReadLocked() {
         final StampedLock lock = new StampedLock();
         long s = lock.readLock();
         Thread t = newStartedThread(new CheckedRunnable() {
             public void realRun() {
-                long ws = lock.tryWriteLock();
-                threadAssertEquals(ws, 0L);
+                threadAssertEquals(0L, lock.tryWriteLock());
             }});
 
         awaitTermination(t);
@@ -559,86 +616,82 @@
     }
 
     /**
-     * timed tryWriteLock times out if locked
+     * timed lock operations time out if lock not available
      */
-    public void testWriteTryLock_Timeout() {
+    public void testTimedLock_Timeout() throws Exception {
+        ArrayList<Future<?>> futures = new ArrayList<>();
+
+        // Write locked
         final StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        Thread t = newStartedThread(new CheckedRunnable() {
+        long stamp = lock.writeLock();
+        assertEquals(0L, lock.tryReadLock(0L, DAYS));
+        assertEquals(0L, lock.tryReadLock(Long.MIN_VALUE, DAYS));
+        assertFalse(lock.asReadLock().tryLock(0L, DAYS));
+        assertFalse(lock.asReadLock().tryLock(Long.MIN_VALUE, DAYS));
+        assertEquals(0L, lock.tryWriteLock(0L, DAYS));
+        assertEquals(0L, lock.tryWriteLock(Long.MIN_VALUE, DAYS));
+        assertFalse(lock.asWriteLock().tryLock(0L, DAYS));
+        assertFalse(lock.asWriteLock().tryLock(Long.MIN_VALUE, DAYS));
+
+        futures.add(cachedThreadPool.submit(new CheckedRunnable() {
+            public void realRun() throws InterruptedException {
+                long startTime = System.nanoTime();
+                assertEquals(0L, lock.tryWriteLock(timeoutMillis(), MILLISECONDS));
+                assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
+            }}));
+
+        futures.add(cachedThreadPool.submit(new CheckedRunnable() {
             public void realRun() throws InterruptedException {
                 long startTime = System.nanoTime();
-                long timeoutMillis = 10;
-                long ws = lock.tryWriteLock(timeoutMillis, MILLISECONDS);
-                assertEquals(ws, 0L);
-                assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
-            }});
+                assertEquals(0L, lock.tryReadLock(timeoutMillis(), MILLISECONDS));
+                assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
+            }}));
+
+        // Read locked
+        final StampedLock lock2 = new StampedLock();
+        long stamp2 = lock2.readLock();
+        assertEquals(0L, lock2.tryWriteLock(0L, DAYS));
+        assertEquals(0L, lock2.tryWriteLock(Long.MIN_VALUE, DAYS));
+        assertFalse(lock2.asWriteLock().tryLock(0L, DAYS));
+        assertFalse(lock2.asWriteLock().tryLock(Long.MIN_VALUE, DAYS));
 
-        awaitTermination(t);
+        futures.add(cachedThreadPool.submit(new CheckedRunnable() {
+            public void realRun() throws InterruptedException {
+                long startTime = System.nanoTime();
+                assertEquals(0L, lock2.tryWriteLock(timeoutMillis(), MILLISECONDS));
+                assertTrue(millisElapsedSince(startTime) >= timeoutMillis());
+            }}));
+
+        for (Future<?> future : futures)
+            assertNull(future.get());
+
+        releaseWriteLock(lock, stamp);
+        releaseReadLock(lock2, stamp2);
+    }
+
+    /**
+     * writeLockInterruptibly succeeds if unlocked
+     */
+    public void testWriteLockInterruptibly() throws InterruptedException {
+        final StampedLock lock = new StampedLock();
+        long s = lock.writeLockInterruptibly();
+        assertTrue(lock.isWriteLocked());
         releaseWriteLock(lock, s);
     }
 
     /**
-     * timed tryReadLock times out if write-locked
-     */
-    public void testReadTryLock_Timeout() {
-        final StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
-        Thread t = newStartedThread(new CheckedRunnable() {
-            public void realRun() throws InterruptedException {
-                long startTime = System.nanoTime();
-                long timeoutMillis = 10;
-                long rs = lock.tryReadLock(timeoutMillis, MILLISECONDS);
-                assertEquals(rs, 0L);
-                assertTrue(millisElapsedSince(startTime) >= timeoutMillis);
-            }});
-
-        awaitTermination(t);
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(s);
-    }
-
-    /**
-     * writeLockInterruptibly succeeds if unlocked, else is interruptible
-     */
-    public void testWriteLockInterruptibly() throws InterruptedException {
-        final CountDownLatch running = new CountDownLatch(1);
-        final StampedLock lock = new StampedLock();
-        long s = lock.writeLockInterruptibly();
-        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
-            public void realRun() throws InterruptedException {
-                running.countDown();
-                lock.writeLockInterruptibly();
-            }});
-
-        running.await();
-        waitForThreadToEnterWaitState(t, 100);
-        t.interrupt();
-        assertTrue(lock.isWriteLocked());
-        awaitTermination(t);
-        releaseWriteLock(lock, s);
-    }
-
-    /**
-     * readLockInterruptibly succeeds if lock free else is interruptible
+     * readLockInterruptibly succeeds if lock free
      */
     public void testReadLockInterruptibly() throws InterruptedException {
-        final CountDownLatch running = new CountDownLatch(1);
         final StampedLock lock = new StampedLock();
-        long s;
-        s = lock.readLockInterruptibly();
+
+        long s = assertValid(lock, lock.readLockInterruptibly());
+        assertTrue(lock.isReadLocked());
         lock.unlockRead(s);
-        s = lock.writeLockInterruptibly();
-        Thread t = newStartedThread(new CheckedInterruptedRunnable() {
-            public void realRun() throws InterruptedException {
-                running.countDown();
-                lock.readLockInterruptibly();
-            }});
 
-        running.await();
-        waitForThreadToEnterWaitState(t, 100);
-        t.interrupt();
-        awaitTermination(t);
-        releaseWriteLock(lock, s);
+        lock.asReadLock().lockInterruptibly();
+        assertTrue(lock.isReadLocked());
+        lock.asReadLock().unlock();
     }
 
     /**
@@ -670,54 +723,39 @@
     }
 
     /**
-     * tryOptimisticRead succeeds and validates if unlocked, fails if locked
+     * tryOptimisticRead succeeds and validates if unlocked, fails if
+     * exclusively locked
      */
     public void testValidateOptimistic() throws InterruptedException {
         StampedLock lock = new StampedLock();
-        long s, p;
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue((s = lock.writeLock()) != 0L);
-        assertFalse((p = lock.tryOptimisticRead()) != 0L);
-        assertTrue(lock.validate(s));
-        lock.unlockWrite(s);
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue((s = lock.readLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
-        assertTrue(lock.validate(p));
-        lock.unlockRead(s);
-        assertTrue((s = lock.tryWriteLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertFalse((p = lock.tryOptimisticRead()) != 0L);
-        lock.unlockWrite(s);
-        assertTrue((s = lock.tryReadLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
-        lock.unlockRead(s);
-        assertTrue(lock.validate(p));
-        assertTrue((s = lock.tryWriteLock(100L, MILLISECONDS)) != 0L);
-        assertFalse((p = lock.tryOptimisticRead()) != 0L);
-        assertTrue(lock.validate(s));
-        lock.unlockWrite(s);
-        assertTrue((s = lock.tryReadLock(100L, MILLISECONDS)) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
-        lock.unlockRead(s);
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
+
+        assertValid(lock, lock.tryOptimisticRead());
+
+        for (Function<StampedLock, Long> writeLocker : writeLockers()) {
+            long s = assertValid(lock, writeLocker.apply(lock));
+            assertEquals(0L, lock.tryOptimisticRead());
+            releaseWriteLock(lock, s);
+        }
+
+        for (Function<StampedLock, Long> readLocker : readLockers()) {
+            long s = assertValid(lock, readLocker.apply(lock));
+            long p = assertValid(lock, lock.tryOptimisticRead());
+            releaseReadLock(lock, s);
+            assertTrue(lock.validate(p));
+        }
+
+        assertValid(lock, lock.tryOptimisticRead());
     }
 
     /**
      * tryOptimisticRead stamp does not validate if a write lock intervenes
      */
     public void testValidateOptimisticWriteLocked() {
-        StampedLock lock = new StampedLock();
-        long s, p;
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
-        assertTrue((s = lock.writeLock()) != 0L);
+        final StampedLock lock = new StampedLock();
+        final long p = assertValid(lock, lock.tryOptimisticRead());
+        final long s = assertValid(lock, lock.writeLock());
         assertFalse(lock.validate(p));
-        assertFalse((p = lock.tryOptimisticRead()) != 0L);
+        assertEquals(0L, lock.tryOptimisticRead());
         assertTrue(lock.validate(s));
         lock.unlockWrite(s);
     }
@@ -730,8 +768,8 @@
             throws InterruptedException {
         final CountDownLatch running = new CountDownLatch(1);
         final StampedLock lock = new StampedLock();
-        long s, p;
-        assertTrue((p = lock.tryOptimisticRead()) != 0L);
+        final long p = assertValid(lock, lock.tryOptimisticRead());
+
         Thread t = newStartedThread(new CheckedInterruptedRunnable() {
             public void realRun() throws InterruptedException {
                 lock.writeLockInterruptibly();
@@ -741,228 +779,209 @@
 
         running.await();
         assertFalse(lock.validate(p));
-        assertFalse((p = lock.tryOptimisticRead()) != 0L);
+        assertEquals(0L, lock.tryOptimisticRead());
         t.interrupt();
         awaitTermination(t);
     }
 
     /**
-     * tryConvertToOptimisticRead succeeds and validates if successfully locked,
+     * tryConvertToOptimisticRead succeeds and validates if successfully locked
      */
     public void testTryConvertToOptimisticRead() throws InterruptedException {
         StampedLock lock = new StampedLock();
-        long s, p;
+        long s, p, q;
         assertEquals(0L, lock.tryConvertToOptimisticRead(0L));
 
-        assertTrue((s = lock.tryOptimisticRead()) != 0L);
+        s = assertValid(lock, lock.tryOptimisticRead());
         assertEquals(s, lock.tryConvertToOptimisticRead(s));
         assertTrue(lock.validate(s));
 
-        assertTrue((p = lock.readLock()) != 0L);
-        assertTrue((s = lock.tryOptimisticRead()) != 0L);
-        assertEquals(s, lock.tryConvertToOptimisticRead(s));
-        assertTrue(lock.validate(s));
-        lock.unlockRead(p);
-
-        assertTrue((s = lock.writeLock()) != 0L);
-        assertTrue((p = lock.tryConvertToOptimisticRead(s)) != 0L);
-        assertTrue(lock.validate(p));
-
-        assertTrue((s = lock.readLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToOptimisticRead(s)) != 0L);
-        assertTrue(lock.validate(p));
+        for (Function<StampedLock, Long> writeLocker : writeLockers()) {
+            s = assertValid(lock, writeLocker.apply(lock));
+            p = assertValid(lock, lock.tryConvertToOptimisticRead(s));
+            assertFalse(lock.validate(s));
+            assertTrue(lock.validate(p));
+            assertUnlocked(lock);
+        }
 
-        assertTrue((s = lock.tryWriteLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToOptimisticRead(s)) != 0L);
-        assertTrue(lock.validate(p));
-
-        assertTrue((s = lock.tryReadLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToOptimisticRead(s)) != 0L);
-        assertTrue(lock.validate(p));
-
-        assertTrue((s = lock.tryWriteLock(100L, MILLISECONDS)) != 0L);
-        assertTrue((p = lock.tryConvertToOptimisticRead(s)) != 0L);
-        assertTrue(lock.validate(p));
-
-        assertTrue((s = lock.tryReadLock(100L, MILLISECONDS)) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToOptimisticRead(s)) != 0L);
-        assertTrue(lock.validate(p));
+        for (Function<StampedLock, Long> readLocker : readLockers()) {
+            s = assertValid(lock, readLocker.apply(lock));
+            q = assertValid(lock, lock.tryOptimisticRead());
+            assertEquals(q, lock.tryConvertToOptimisticRead(q));
+            assertTrue(lock.validate(q));
+            assertTrue(lock.isReadLocked());
+            p = assertValid(lock, lock.tryConvertToOptimisticRead(s));
+            assertTrue(lock.validate(p));
+            assertTrue(lock.validate(s));
+            assertUnlocked(lock);
+            assertEquals(q, lock.tryConvertToOptimisticRead(q));
+            assertTrue(lock.validate(q));
+        }
     }
 
     /**
-     * tryConvertToReadLock succeeds and validates if successfully locked
-     * or lock free;
+     * tryConvertToReadLock succeeds for valid stamps
      */
     public void testTryConvertToReadLock() throws InterruptedException {
         StampedLock lock = new StampedLock();
         long s, p;
 
-        assertFalse((p = lock.tryConvertToReadLock(0L)) != 0L);
+        assertEquals(0L, lock.tryConvertToReadLock(0L));
 
-        assertTrue((s = lock.tryOptimisticRead()) != 0L);
-        assertTrue((p = lock.tryConvertToReadLock(s)) != 0L);
+        s = assertValid(lock, lock.tryOptimisticRead());
+        p = assertValid(lock, lock.tryConvertToReadLock(s));
         assertTrue(lock.isReadLocked());
         assertEquals(1, lock.getReadLockCount());
+        assertTrue(lock.validate(s));
         lock.unlockRead(p);
 
-        assertTrue((s = lock.tryOptimisticRead()) != 0L);
+        s = assertValid(lock, lock.tryOptimisticRead());
         lock.readLock();
-        assertTrue((p = lock.tryConvertToReadLock(s)) != 0L);
+        p = assertValid(lock, lock.tryConvertToReadLock(s));
         assertTrue(lock.isReadLocked());
         assertEquals(2, lock.getReadLockCount());
         lock.unlockRead(p);
         lock.unlockRead(p);
-
-        assertTrue((s = lock.writeLock()) != 0L);
-        assertTrue((p = lock.tryConvertToReadLock(s)) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue(lock.isReadLocked());
-        assertEquals(1, lock.getReadLockCount());
-        lock.unlockRead(p);
-
-        assertTrue((s = lock.readLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertEquals(s, lock.tryConvertToReadLock(s));
-        assertTrue(lock.validate(s));
-        assertTrue(lock.isReadLocked());
-        assertEquals(1, lock.getReadLockCount());
-        lock.unlockRead(s);
-
-        assertTrue((s = lock.tryWriteLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToReadLock(s)) != 0L);
-        assertTrue(lock.validate(p));
-        assertEquals(1, lock.getReadLockCount());
-        lock.unlockRead(p);
+        assertUnlocked(lock);
 
-        assertTrue((s = lock.tryReadLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertEquals(s, lock.tryConvertToReadLock(s));
-        assertTrue(lock.validate(s));
-        assertTrue(lock.isReadLocked());
-        assertEquals(1, lock.getReadLockCount());
-        lock.unlockRead(s);
+        for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers()) {
+            for (Function<StampedLock, Long> writeLocker : writeLockers()) {
+                s = assertValid(lock, writeLocker.apply(lock));
+                p = assertValid(lock, lock.tryConvertToReadLock(s));
+                assertFalse(lock.validate(s));
+                assertTrue(lock.isReadLocked());
+                assertEquals(1, lock.getReadLockCount());
+                readUnlocker.accept(lock, p);
+            }
 
-        assertTrue((s = lock.tryWriteLock(100L, MILLISECONDS)) != 0L);
-        assertTrue((p = lock.tryConvertToReadLock(s)) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue(lock.isReadLocked());
-        assertEquals(1, lock.getReadLockCount());
-        lock.unlockRead(p);
-
-        assertTrue((s = lock.tryReadLock(100L, MILLISECONDS)) != 0L);
-        assertTrue(lock.validate(s));
-        assertEquals(s, lock.tryConvertToReadLock(s));
-        assertTrue(lock.validate(s));
-        assertTrue(lock.isReadLocked());
-        assertEquals(1, lock.getReadLockCount());
-        lock.unlockRead(s);
+            for (Function<StampedLock, Long> readLocker : readLockers()) {
+                s = assertValid(lock, readLocker.apply(lock));
+                assertEquals(s, lock.tryConvertToReadLock(s));
+                assertTrue(lock.validate(s));
+                assertTrue(lock.isReadLocked());
+                assertEquals(1, lock.getReadLockCount());
+                readUnlocker.accept(lock, s);
+            }
+        }
     }
 
     /**
-     * tryConvertToWriteLock succeeds and validates if successfully locked
-     * or lock free;
+     * tryConvertToWriteLock succeeds if lock available; fails if multiply read locked
      */
     public void testTryConvertToWriteLock() throws InterruptedException {
         StampedLock lock = new StampedLock();
         long s, p;
 
-        assertFalse((p = lock.tryConvertToWriteLock(0L)) != 0L);
+        assertEquals(0L, lock.tryConvertToWriteLock(0L));
 
         assertTrue((s = lock.tryOptimisticRead()) != 0L);
         assertTrue((p = lock.tryConvertToWriteLock(s)) != 0L);
         assertTrue(lock.isWriteLocked());
         lock.unlockWrite(p);
 
-        assertTrue((s = lock.writeLock()) != 0L);
-        assertEquals(s, lock.tryConvertToWriteLock(s));
-        assertTrue(lock.validate(s));
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(s);
-
-        assertTrue((s = lock.readLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToWriteLock(s)) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(p);
-
-        assertTrue((s = lock.tryWriteLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertEquals(s, lock.tryConvertToWriteLock(s));
-        assertTrue(lock.validate(s));
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(s);
+        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers()) {
+            for (Function<StampedLock, Long> writeLocker : writeLockers()) {
+                s = assertValid(lock, writeLocker.apply(lock));
+                assertEquals(s, lock.tryConvertToWriteLock(s));
+                assertTrue(lock.validate(s));
+                assertTrue(lock.isWriteLocked());
+                writeUnlocker.accept(lock, s);
+            }
 
-        assertTrue((s = lock.tryReadLock()) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToWriteLock(s)) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(p);
+            for (Function<StampedLock, Long> readLocker : readLockers()) {
+                s = assertValid(lock, readLocker.apply(lock));
+                p = assertValid(lock, lock.tryConvertToWriteLock(s));
+                assertFalse(lock.validate(s));
+                assertTrue(lock.validate(p));
+                assertTrue(lock.isWriteLocked());
+                writeUnlocker.accept(lock, p);
+            }
+        }
 
-        assertTrue((s = lock.tryWriteLock(100L, MILLISECONDS)) != 0L);
-        assertTrue((p = lock.tryConvertToWriteLock(s)) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(p);
-
-        assertTrue((s = lock.tryReadLock(100L, MILLISECONDS)) != 0L);
-        assertTrue(lock.validate(s));
-        assertTrue((p = lock.tryConvertToWriteLock(s)) != 0L);
-        assertTrue(lock.validate(p));
-        assertTrue(lock.isWriteLocked());
-        lock.unlockWrite(p);
+        // failure if multiply read locked
+        for (Function<StampedLock, Long> readLocker : readLockers()) {
+            s = assertValid(lock, readLocker.apply(lock));
+            p = assertValid(lock, readLocker.apply(lock));
+            assertEquals(0L, lock.tryConvertToWriteLock(s));
+            assertTrue(lock.validate(s));
+            assertTrue(lock.validate(p));
+            assertEquals(2, lock.getReadLockCount());
+            lock.unlock(p);
+            lock.unlock(s);
+            assertUnlocked(lock);
+        }
     }
 
     /**
      * asWriteLock can be locked and unlocked
      */
-    public void testAsWriteLock() {
+    public void testAsWriteLock() throws Throwable {
         StampedLock sl = new StampedLock();
         Lock lock = sl.asWriteLock();
-        lock.lock();
-        assertFalse(lock.tryLock());
-        lock.unlock();
-        assertTrue(lock.tryLock());
+        for (Action locker : lockLockers(lock)) {
+            locker.run();
+            assertTrue(sl.isWriteLocked());
+            assertFalse(sl.isReadLocked());
+            assertFalse(lock.tryLock());
+            lock.unlock();
+            assertUnlocked(sl);
+        }
     }
 
     /**
      * asReadLock can be locked and unlocked
      */
-    public void testAsReadLock() {
+    public void testAsReadLock() throws Throwable {
         StampedLock sl = new StampedLock();
         Lock lock = sl.asReadLock();
-        lock.lock();
-        lock.unlock();
-        assertTrue(lock.tryLock());
+        for (Action locker : lockLockers(lock)) {
+            locker.run();
+            assertTrue(sl.isReadLocked());
+            assertFalse(sl.isWriteLocked());
+            assertEquals(1, sl.getReadLockCount());
+            locker.run();
+            assertTrue(sl.isReadLocked());
+            assertEquals(2, sl.getReadLockCount());
+            lock.unlock();
+            lock.unlock();
+            assertUnlocked(sl);
+        }
     }
 
     /**
      * asReadWriteLock.writeLock can be locked and unlocked
      */
-    public void testAsReadWriteLockWriteLock() {
+    public void testAsReadWriteLockWriteLock() throws Throwable {
         StampedLock sl = new StampedLock();
         Lock lock = sl.asReadWriteLock().writeLock();
-        lock.lock();
-        assertFalse(lock.tryLock());
-        lock.unlock();
-        assertTrue(lock.tryLock());
+        for (Action locker : lockLockers(lock)) {
+            locker.run();
+            assertTrue(sl.isWriteLocked());
+            assertFalse(sl.isReadLocked());
+            assertFalse(lock.tryLock());
+            lock.unlock();
+            assertUnlocked(sl);
+        }
     }
 
     /**
      * asReadWriteLock.readLock can be locked and unlocked
      */
-    public void testAsReadWriteLockReadLock() {
+    public void testAsReadWriteLockReadLock() throws Throwable {
         StampedLock sl = new StampedLock();
         Lock lock = sl.asReadWriteLock().readLock();
-        lock.lock();
-        lock.unlock();
-        assertTrue(lock.tryLock());
+        for (Action locker : lockLockers(lock)) {
+            locker.run();
+            assertTrue(sl.isReadLocked());
+            assertFalse(sl.isWriteLocked());
+            assertEquals(1, sl.getReadLockCount());
+            locker.run();
+            assertTrue(sl.isReadLocked());
+            assertEquals(2, sl.getReadLockCount());
+            lock.unlock();
+            lock.unlock();
+            assertUnlocked(sl);
+        }
     }
 
     /**
@@ -985,8 +1004,7 @@
         Runnable[] actions = {
             () -> {
                 StampedLock sl = new StampedLock();
-                long stamp = sl.tryOptimisticRead();
-                assertTrue(stamp != 0);
+                long stamp = assertValid(sl, sl.tryOptimisticRead());
                 sl.unlockRead(stamp);
             },
             () -> {
@@ -1003,21 +1021,21 @@
             },
             () -> {
                 StampedLock sl = new StampedLock();
-                long stamp = sl.tryOptimisticRead();
                 sl.readLock();
+                long stamp = assertValid(sl, sl.tryOptimisticRead());
                 sl.unlockRead(stamp);
             },
             () -> {
                 StampedLock sl = new StampedLock();
-                long stamp = sl.tryOptimisticRead();
                 sl.readLock();
+                long stamp = assertValid(sl, sl.tryOptimisticRead());
                 sl.unlock(stamp);
             },
 
             () -> {
                 StampedLock sl = new StampedLock();
                 long stamp = sl.tryConvertToOptimisticRead(sl.writeLock());
-                assertTrue(stamp != 0);
+                assertValid(sl, stamp);
                 sl.writeLock();
                 sl.unlockWrite(stamp);
             },
@@ -1043,7 +1061,7 @@
             () -> {
                 StampedLock sl = new StampedLock();
                 long stamp = sl.tryConvertToOptimisticRead(sl.readLock());
-                assertTrue(stamp != 0);
+                assertValid(sl, stamp);
                 sl.writeLock();
                 sl.unlockWrite(stamp);
             },
@@ -1063,7 +1081,7 @@
                 StampedLock sl = new StampedLock();
                 sl.readLock();
                 long stamp = sl.tryConvertToOptimisticRead(sl.readLock());
-                assertTrue(stamp != 0);
+                assertValid(sl, stamp);
                 sl.readLock();
                 sl.unlockRead(stamp);
             },
@@ -1106,100 +1124,84 @@
     }
 
     /**
-     * Invalid write stamps result in IllegalMonitorStateException
+     * Invalid stamps result in IllegalMonitorStateException
      */
-    public void testInvalidWriteStampsThrowIllegalMonitorStateException() {
-        List<Function<StampedLock, Long>> writeLockers = new ArrayList<>();
-        writeLockers.add((sl) -> sl.writeLock());
-        writeLockers.add((sl) -> writeLockInterruptiblyUninterrupted(sl));
-        writeLockers.add((sl) -> tryWriteLockUninterrupted(sl, Long.MIN_VALUE, DAYS));
-        writeLockers.add((sl) -> tryWriteLockUninterrupted(sl, 0, DAYS));
+    public void testInvalidStampsThrowIllegalMonitorStateException() {
+        final StampedLock sl = new StampedLock();
+
+        assertThrows(IllegalMonitorStateException.class,
+                     () -> sl.unlockWrite(0L),
+                     () -> sl.unlockRead(0L),
+                     () -> sl.unlock(0L));
 
-        List<BiConsumer<StampedLock, Long>> writeUnlockers = new ArrayList<>();
-        writeUnlockers.add((sl, stamp) -> sl.unlockWrite(stamp));
-        writeUnlockers.add((sl, stamp) -> assertTrue(sl.tryUnlockWrite()));
-        writeUnlockers.add((sl, stamp) -> sl.asWriteLock().unlock());
-        writeUnlockers.add((sl, stamp) -> sl.unlock(stamp));
+        final long optimisticStamp = sl.tryOptimisticRead();
+        final long readStamp = sl.readLock();
+        sl.unlockRead(readStamp);
+        final long writeStamp = sl.writeLock();
+        sl.unlockWrite(writeStamp);
+        assertTrue(optimisticStamp != 0L && readStamp != 0L && writeStamp != 0L);
+        final long[] noLongerValidStamps = { optimisticStamp, readStamp, writeStamp };
+        final Runnable assertNoLongerValidStampsThrow = () -> {
+            for (long noLongerValidStamp : noLongerValidStamps)
+                assertThrows(IllegalMonitorStateException.class,
+                             () -> sl.unlockWrite(noLongerValidStamp),
+                             () -> sl.unlockRead(noLongerValidStamp),
+                             () -> sl.unlock(noLongerValidStamp));
+        };
+        assertNoLongerValidStampsThrow.run();
 
-        List<Consumer<StampedLock>> mutaters = new ArrayList<>();
-        mutaters.add((sl) -> {});
-        mutaters.add((sl) -> sl.readLock());
-        for (Function<StampedLock, Long> writeLocker : writeLockers)
-            mutaters.add((sl) -> writeLocker.apply(sl));
+        for (Function<StampedLock, Long> readLocker : readLockers())
+        for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers()) {
+            final long stamp = readLocker.apply(sl);
+            assertValid(sl, stamp);
+            assertNoLongerValidStampsThrow.run();
+            assertThrows(IllegalMonitorStateException.class,
+                         () -> sl.unlockWrite(stamp),
+                         () -> sl.unlockRead(sl.tryOptimisticRead()),
+                         () -> sl.unlockRead(0L));
+            readUnlocker.accept(sl, stamp);
+            assertUnlocked(sl);
+            assertNoLongerValidStampsThrow.run();
+        }
 
-        for (Function<StampedLock, Long> writeLocker : writeLockers)
-        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers)
-        for (Consumer<StampedLock> mutater : mutaters) {
-            final StampedLock sl = new StampedLock();
+        for (Function<StampedLock, Long> writeLocker : writeLockers())
+        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers()) {
             final long stamp = writeLocker.apply(sl);
-            assertTrue(stamp != 0L);
+            assertValid(sl, stamp);
+            assertNoLongerValidStampsThrow.run();
             assertThrows(IllegalMonitorStateException.class,
-                         () -> sl.unlockRead(stamp));
+                         () -> sl.unlockRead(stamp),
+                         () -> sl.unlockWrite(0L));
             writeUnlocker.accept(sl, stamp);
-            mutater.accept(sl);
-            assertThrows(IllegalMonitorStateException.class,
-                         () -> sl.unlock(stamp),
-                         () -> sl.unlockRead(stamp),
-                         () -> sl.unlockWrite(stamp));
+            assertUnlocked(sl);
+            assertNoLongerValidStampsThrow.run();
         }
     }
 
     /**
-     * Invalid read stamps result in IllegalMonitorStateException
+     * Read locks can be very deeply nested
      */
-    public void testInvalidReadStampsThrowIllegalMonitorStateException() {
-        List<Function<StampedLock, Long>> readLockers = new ArrayList<>();
-        readLockers.add((sl) -> sl.readLock());
-        readLockers.add((sl) -> readLockInterruptiblyUninterrupted(sl));
-        readLockers.add((sl) -> tryReadLockUninterrupted(sl, Long.MIN_VALUE, DAYS));
-        readLockers.add((sl) -> tryReadLockUninterrupted(sl, 0, DAYS));
-
-        List<BiConsumer<StampedLock, Long>> readUnlockers = new ArrayList<>();
-        readUnlockers.add((sl, stamp) -> sl.unlockRead(stamp));
-        readUnlockers.add((sl, stamp) -> assertTrue(sl.tryUnlockRead()));
-        readUnlockers.add((sl, stamp) -> sl.asReadLock().unlock());
-        readUnlockers.add((sl, stamp) -> sl.unlock(stamp));
-
-        List<Function<StampedLock, Long>> writeLockers = new ArrayList<>();
-        writeLockers.add((sl) -> sl.writeLock());
-        writeLockers.add((sl) -> writeLockInterruptiblyUninterrupted(sl));
-        writeLockers.add((sl) -> tryWriteLockUninterrupted(sl, Long.MIN_VALUE, DAYS));
-        writeLockers.add((sl) -> tryWriteLockUninterrupted(sl, 0, DAYS));
-
-        List<BiConsumer<StampedLock, Long>> writeUnlockers = new ArrayList<>();
-        writeUnlockers.add((sl, stamp) -> sl.unlockWrite(stamp));
-        writeUnlockers.add((sl, stamp) -> assertTrue(sl.tryUnlockWrite()));
-        writeUnlockers.add((sl, stamp) -> sl.asWriteLock().unlock());
-        writeUnlockers.add((sl, stamp) -> sl.unlock(stamp));
-
-
-        for (Function<StampedLock, Long> readLocker : readLockers)
-        for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers)
-        for (Function<StampedLock, Long> writeLocker : writeLockers)
-        for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers) {
-            final StampedLock sl = new StampedLock();
-            final long stamp = readLocker.apply(sl);
-            assertTrue(stamp != 0L);
-            assertThrows(IllegalMonitorStateException.class,
-                         () -> sl.unlockWrite(stamp));
-            readUnlocker.accept(sl, stamp);
-            assertThrows(IllegalMonitorStateException.class,
-                         () -> sl.unlock(stamp),
-                         () -> sl.unlockRead(stamp),
-                         () -> sl.unlockWrite(stamp));
-            final long writeStamp = writeLocker.apply(sl);
-            assertTrue(writeStamp != 0L);
-            assertTrue(writeStamp != stamp);
-            assertThrows(IllegalMonitorStateException.class,
-                         () -> sl.unlock(stamp),
-                         () -> sl.unlockRead(stamp),
-                         () -> sl.unlockWrite(stamp));
-            writeUnlocker.accept(sl, writeStamp);
-            assertThrows(IllegalMonitorStateException.class,
-                         () -> sl.unlock(stamp),
-                         () -> sl.unlockRead(stamp),
-                         () -> sl.unlockWrite(stamp));
+    public void testDeeplyNestedReadLocks() {
+        final StampedLock lock = new StampedLock();
+        final int depth = 300;
+        final long[] stamps = new long[depth];
+        final List<Function<StampedLock, Long>> readLockers = readLockers();
+        final List<BiConsumer<StampedLock, Long>> readUnlockers = readUnlockers();
+        for (int i = 0; i < depth; i++) {
+            Function<StampedLock, Long> readLocker
+                = readLockers.get(i % readLockers.size());
+            long stamp = readLocker.apply(lock);
+            assertEquals(i + 1, lock.getReadLockCount());
+            assertTrue(lock.isReadLocked());
+            stamps[i] = stamp;
         }
+        for (int i = 0; i < depth; i++) {
+            BiConsumer<StampedLock, Long> readUnlocker
+                = readUnlockers.get(i % readUnlockers.size());
+            assertEquals(depth - i, lock.getReadLockCount());
+            assertTrue(lock.isReadLocked());
+            readUnlocker.accept(lock, stamps[depth - 1 - i]);
+        }
+        assertUnlocked(lock);
     }
-
 }
--- a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Fri Aug 19 12:17:32 2016 -0700
@@ -119,20 +119,22 @@
             System.setProperty("javax.net.debug", "ssl");
         }
 
-        // Create the PKI we will use for the test and start the OCSP servers
-        createPKI();
+        try {
+            // Create the PKI we will use for the test and start the OCSP servers
+            createPKI();
 
-        testAllDefault();
-        testPKIXParametersRevEnabled();
-        testRevokedCertificate();
-        testHardFailFallback();
-        testSoftFailFallback();
-        testLatencyNoStaple(false);
-        testLatencyNoStaple(true);
-
-        // shut down the OCSP responders before finishing the test
-        intOcsp.stop();
-        rootOcsp.stop();
+            testAllDefault();
+            testPKIXParametersRevEnabled();
+            testRevokedCertificate();
+            testHardFailFallback();
+            testSoftFailFallback();
+            testLatencyNoStaple(false);
+            testLatencyNoStaple(true);
+        } finally {
+            // shut down the OCSP responders before finishing the test
+            intOcsp.stop();
+            rootOcsp.stop();
+        }
     }
 
     /**
@@ -281,11 +283,9 @@
         ServerParameters servParams = new ServerParameters();
         serverReady = false;
 
-        // Stop the OCSP responders and give a 1 second delay before
-        // running the test.
-        intOcsp.stop();
-        rootOcsp.stop();
-        Thread.sleep(1000);
+        // make OCSP responders reject connections
+        intOcsp.rejectConnections();
+        rootOcsp.rejectConnections();
 
         System.out.println("=======================================");
         System.out.println("Stapling enbled in client and server,");
@@ -315,9 +315,9 @@
         System.out.println("                 PASS");
         System.out.println("=======================================\n");
 
-        // Start the OCSP responders up again
-        intOcsp.start();
-        rootOcsp.start();
+        // Make OCSP responders accept connections
+        intOcsp.acceptConnections();
+        rootOcsp.acceptConnections();
 
         // Wait 5 seconds for server ready
         for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
@@ -338,11 +338,9 @@
         ServerParameters servParams = new ServerParameters();
         serverReady = false;
 
-        // Stop the OCSP responders and give a 1 second delay before
-        // running the test.
-        intOcsp.stop();
-        rootOcsp.stop();
-        Thread.sleep(1000);
+        // make OCSP responders reject connections
+        intOcsp.rejectConnections();
+        rootOcsp.rejectConnections();
 
         System.out.println("=======================================");
         System.out.println("Stapling enbled in client and server,");
@@ -372,9 +370,9 @@
         System.out.println("                 PASS");
         System.out.println("=======================================\n");
 
-        // Start the OCSP responders up again
-        intOcsp.start();
-        rootOcsp.start();
+        // Make OCSP responders accept connections
+        intOcsp.acceptConnections();
+        rootOcsp.acceptConnections();
 
         // Wait 5 seconds for server ready
         for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
@@ -401,15 +399,10 @@
         ServerParameters servParams = new ServerParameters();
         serverReady = false;
 
-        // Stop the OCSP responders and give a 1 second delay before
-        // running the test.
-        intOcsp.stop();
-        rootOcsp.stop();
-        Thread.sleep(1000);
+        // Give a 1 second delay before running the test.
         intOcsp.setDelay(3000);
         rootOcsp.setDelay(3000);
-        rootOcsp.start();
-        intOcsp.start();
+        Thread.sleep(1000);
 
         // Wait 5 seconds for server ready
         for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
@@ -458,13 +451,9 @@
         System.out.println("========================================\n");
 
         // Remove the OCSP responder latency
-        intOcsp.stop();
-        rootOcsp.stop();
-        Thread.sleep(1000);
         intOcsp.setDelay(0);
         rootOcsp.setDelay(0);
-        rootOcsp.start();
-        intOcsp.start();
+        Thread.sleep(1000);
 
         // Wait 5 seconds for server ready
         for (int i = 0; (i < 100 && (!intOcsp.isServerReady() || !rootOcsp.isServerReady())); i++) {
@@ -676,6 +665,7 @@
                          * Release the client, if not active already...
                          */
                         System.err.println("Server died...");
+                        e.printStackTrace(System.err);
                         serverReady = true;
                         serverException = e;
                     }
--- a/jdk/test/javax/xml/crypto/dsig/TransformService/NullParent.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/javax/xml/crypto/dsig/TransformService/NullParent.java	Fri Aug 19 12:17:32 2016 -0700
@@ -26,6 +26,7 @@
  * @bug 8022120
  * @summary check that the init and marshalParams methods throw
  *          NullPointerException when the parent parameter is null
+ * @run main/othervm/java.security.policy==test.policy NullParent
  */
 
 import javax.xml.crypto.dsig.CanonicalizationMethod;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/crypto/dsig/TransformService/test.policy	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,3 @@
+grant {
+
+};
--- a/jdk/test/javax/xml/crypto/dsig/keyinfo/KeyInfo/Marshal.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/javax/xml/crypto/dsig/keyinfo/KeyInfo/Marshal.java	Fri Aug 19 12:17:32 2016 -0700
@@ -27,7 +27,7 @@
  * @summary Test that KeyInfo.marshal works correctly
  * @modules java.xml.crypto/org.jcp.xml.dsig.internal.dom
  * @compile -XDignore.symbol.file Marshal.java
- * @run main Marshal
+ * @run main/othervm/java.security.policy==test.policy Marshal
  * @author Sean Mullan
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/xml/crypto/dsig/keyinfo/KeyInfo/test.policy	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,3 @@
+grant {
+    permission java.lang.RuntimePermission "accessClassInPackage.org.jcp.xml.dsig.internal.dom";
+};
--- a/jdk/test/sun/misc/URLClassPath/ClassnameCharTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/sun/misc/URLClassPath/ClassnameCharTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -103,16 +103,60 @@
 
     //--------------------- Infrastructure ---------------------------
     static volatile int passed = 0, failed = 0;
-    static boolean pass() {passed++; return true;}
-    static boolean fail() {failed++; server.stop(0); Thread.dumpStack(); return false;}
-    static boolean fail(String msg) {System.out.println(msg); return fail();}
-    static void unexpected(Throwable t) {failed++; server.stop(0); t.printStackTrace();}
-    static boolean check(boolean cond) {if (cond) pass(); else fail(); return cond;}
+
+    static boolean pass() {
+        passed++;
+        return true;
+    }
+
+    static boolean fail() {
+        failed++;
+        if (server != null) {
+            server.stop(0);
+        }
+        Thread.dumpStack();
+        return false;
+    }
+
+    static boolean fail(String msg) {
+        System.out.println(msg);
+        return fail();
+    }
+
+    static void unexpected(Throwable t) {
+        failed++;
+        if (server != null) {
+            server.stop(0);
+        }
+        t.printStackTrace();
+    }
+
+    static boolean check(boolean cond) {
+        if (cond) {
+            pass();
+        } else {
+            fail();
+        }
+        return cond;
+    }
+
     static boolean equal(Object x, Object y) {
-        if (x == null ? y == null : x.equals(y)) return pass();
-        else return fail(x + " not equal to " + y);}
+        if (x == null ? y == null : x.equals(y)) {
+            return pass();
+        } else {
+            return fail(x + " not equal to " + y);
+        }
+    }
+
     public static void main(String[] args) throws Throwable {
-        try {realMain(args);} catch (Throwable t) {unexpected(t);}
+        try {
+            realMain(args);
+        } catch (Throwable t) {
+            unexpected(t);
+        }
         System.out.println("\nPassed = " + passed + " failed = " + failed);
-        if (failed > 0) throw new AssertionError("Some tests failed");}
+        if (failed > 0) {
+            throw new AssertionError("Some tests failed");
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/CommMatcher.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Matches the krb5 debug output:
+ * >>> KDCCommunication: kdc=host UDP:11555, timeout=100,Attempt =1, #bytes=138
+ *
+ * Example:
+ *   CommMatcher cm = new CommMatcher();
+ *   cm.addPort(12345).addPort(23456);
+ *   for (String line : debugOutput) {
+ *       if (cm.match(line)) {
+ *           println("KDC: %c, %s, Timeout: %d\n",
+ *              cm.kdc(), cm.protocol(), cm.timeout());
+ *       }
+ *   }
+ */
+public class CommMatcher {
+
+    static final Pattern re = Pattern.compile(
+            ">>> KDCCommunication: kdc=\\S+ (TCP|UDP):(\\d+), " +
+                    "timeout=(\\d+),Attempt\\s*=(\\d+)");
+
+    List<Integer> kdcPorts = new ArrayList<>();
+    Matcher matcher;
+
+    /**
+     * Add KDC ports one by one. The 1st KDC will be 'a' in {@link #kdc()},
+     * 2nd is 'b', etc, etc.
+     */
+    public CommMatcher addPort(int port) {
+        if (port > 0) {
+            kdcPorts.add(port);
+        } else {
+            kdcPorts.clear();
+        }
+        return this;
+    }
+
+    public boolean match(String line) {
+        matcher = re.matcher(line);
+        return matcher.find();
+    }
+
+    public String protocol() {
+        return matcher.group(1);
+    }
+
+    public char kdc() {
+        int port = Integer.parseInt(matcher.group(2));
+        return (char)(kdcPorts.indexOf(port) + 'a');
+    }
+
+    public int timeout() {
+        return BadKdc.toSymbolicSec(Integer.parseInt(matcher.group(3)));
+    }
+
+    public int attempt() {
+        return Integer.parseInt(matcher.group(4));
+    }
+}
--- a/jdk/test/sun/security/krb5/auto/MaxRetries.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/sun/security/krb5/auto/MaxRetries.java	Fri Aug 19 12:17:32 2016 -0700
@@ -30,6 +30,7 @@
  * @summary support max_retries in krb5.conf
  */
 
+import javax.security.auth.login.LoginException;
 import java.io.*;
 import java.net.DatagramSocket;
 import java.security.Security;
@@ -37,46 +38,86 @@
 public class MaxRetries {
 
     static int idlePort = -1;
+    static CommMatcher cm = new CommMatcher();
 
     public static void main(String[] args)
             throws Exception {
 
         System.setProperty("sun.security.krb5.debug", "true");
-        new OneKDC(null).writeJAASConf();
+        OneKDC kdc = new OneKDC(null).writeJAASConf();
 
         // An idle UDP socket to prevent PortUnreachableException
         DatagramSocket ds = new DatagramSocket();
         idlePort = ds.getLocalPort();
 
+        cm.addPort(idlePort);
+        cm.addPort(kdc.getPort());
+
         System.setProperty("java.security.krb5.conf", "alternative-krb5.conf");
 
-        // For tryLast
         Security.setProperty("krb5.kdc.bad.policy", "trylast");
+
+        // We always make the real timeout to be 1 second
+        BadKdc.setRatio(0.25f);
         rewriteMaxRetries(4);
-        test1(4000, 6);         // 1 1 1 1 2 2
-        test1(4000, 2);         // 2 2
 
+        // Explanation: In this case, max_retries=4 and timeout=4s.
+        // For AS-REQ without preauth, we will see 4 4s timeout on kdc#1
+        // ("a4" repeat 4 times), and one 4s timeout on kdc#2 ("b4"). For
+        // AS-REQ with preauth, one 4s timeout on kdc#2 (second "b4").
+        // we tolerate 4 real timeout on kdc#2, so make it "(b4){2,6}".
+        test1("a4a4a4a4b4b4", "a4a4a4a4(b4){2,6}");
+        test1("b4b4", "(b4){2,6}");
+
+        BadKdc.setRatio(1f);
         rewriteMaxRetries(1);
-        test1(1000, 3);         // 1 2 2
-        test1(1000, 2);         // 2 2
+        // Explanation: Since max_retries=1 only, we could fail in 1st or 2nd
+        // AS-REQ to kdc#2.
+        String actual = test1("a1b1b1", "(a1b1b1|a1b1x|a1b1b1x)");
+        if (actual.endsWith("x")) {
+            // If 1st attempt fails, all bads are back available
+            test1("a1b1b1", "(a1b1b1|a1b1x|a1b1b1x)");
+        } else {
+            test1("b1b1", "(b1b1|b1x|b1b1x)");
+        }
 
+        BadKdc.setRatio(0.2f);
         rewriteMaxRetries(-1);
-        test1(5000, 4);         // 1 1 2 2
-        test1(5000, 2);         // 2 2
+        test1("a5a5a5b5b5", "a5a5a5(b5){2,4}");
+        test1("b5b5", "(b5){2,4}");
 
-        // For tryLess
-        Security.setProperty("krb5.kdc.bad.policy", "tryless:1," + BadKdc.toReal(5000));
+        BadKdc.setRatio(0.25f);
+        Security.setProperty("krb5.kdc.bad.policy",
+                "tryless:1,1000");
         rewriteMaxRetries(4);
-        test1(4000, 7);         // 1 1 1 1 2 1 2
-        test1(4000, 4);         // 1 2 1 2
+        test1("a4a4a4a4b4a4b4", "a4a4a4a4(b4){1,3}a4(b4){1,3}");
+        test1("a4b4a4b4", "a4(b4){1,3}a4(b4){1,3}");
 
+        BadKdc.setRatio(1f);
         rewriteMaxRetries(1);
-        test1(1000, 4);         // 1 2 1 2
-        test1(1000, 4);         // 1 2 1 2
+        actual = test1("a1b1a1b1", "(a1b1|a1b1x|a1b1a1b1|a1b1a1b1x)");
+        if (actual.endsWith("x")) {
+            test1("a1b1a1b1", "(a1b1|a1b1x|a1b1a1b1|a1b1a1b1x)");
+        } else {
+            test1("a1b1a1b1", "(a1b1|a1b1x|a1b1a1b1|a1b1a1b1x)");
+        }
+
+        BadKdc.setRatio(.2f);
+        rewriteMaxRetries(-1);
+        test1("a5a5a5b5a5b5", "a5a5a5(b5){1,2}a5(b5){1,2}");
+        test1("a5b5a5b5", "a5(b5){1,2}a5(b5){1,2}");
 
-        rewriteMaxRetries(-1);
-        test1(5000, 5);         // 1 1 2 1 2
-        test1(5000, 4);         // 1 2 1 2
+        BadKdc.setRatio(1f);
+        rewriteMaxRetries(2);
+        if (BadKdc.toReal(2000) > 1000) {
+            // Explanation: if timeout is longer than 1s in tryLess,
+            // we will see "a1" at 2nd kdc#1 access
+            test1("a2a2b2a1b2", "a2a2(b2){1,2}a1(b2){1,2}");
+        } else {
+            test1("a2a2b2a2b2", "a2a2(b2){1,2}a2(b2){1,2}");
+        }
+
+        BadKdc.setRatio(1f);
 
         rewriteUdpPrefLimit(-1, -1);    // default, no limit
         test2("UDP");
@@ -95,32 +136,52 @@
 
     /**
      * One round of test for max_retries and timeout.
-     * @param timeout the expected timeout
-     * @param count the expected total try
+     *
+     * @param exact the expected exact match, where no timeout
+     *              happens for real KDCs
+     * @param relaxed the expected relaxed match, where some timeout
+     *                could happen for real KDCs
+     * @return the actual result
      */
-    private static void test1(int timeout, int count) throws Exception {
-        String timeoutTag = "timeout=" + BadKdc.toReal(timeout);
+    private static String test1(String exact, String relaxed) throws Exception {
         ByteArrayOutputStream bo = new ByteArrayOutputStream();
         PrintStream oldout = System.out;
         System.setOut(new PrintStream(bo));
-        Context c = Context.fromJAAS("client");
+        boolean failed = false;
+        long start = System.nanoTime();
+        try {
+            Context c = Context.fromJAAS("client");
+        } catch (LoginException e) {
+            failed = true;
+        }
         System.setOut(oldout);
 
         String[] lines = new String(bo.toByteArray()).split("\n");
-        System.out.println("----------------- TEST (" + timeout + "," +
-                count + ") -----------------");
+        System.out.println("----------------- TEST (" + exact
+                + ") -----------------");
+
+        // Result, a series of timeout + kdc#
+        StringBuilder sb = new StringBuilder();
         for (String line: lines) {
-            if (line.startsWith(">>> KDCCommunication")) {
+            if (cm.match(line)) {
                 System.out.println(line);
-                if (line.indexOf(timeoutTag) < 0) {
-                    throw new Exception("Wrong timeout value" + timeoutTag);
-                }
-                count--;
+                sb.append(cm.kdc()).append(cm.timeout());
             }
         }
-        if (count != 0) {
-            throw new Exception("Retry count is " + count + " less");
+        if (failed) {
+            sb.append("x");
         }
+        System.out.println("Time: " + (System.nanoTime() - start) / 1000000000d);
+        String actual = sb.toString();
+        System.out.println("Actual: " + actual);
+        if (actual.equals(exact)) {
+            System.out.println("Exact match: " + exact);
+        } else if (actual.matches(relaxed)) {
+            System.out.println("!!!! Tolerant match: " + relaxed);
+        } else {
+            throw new Exception("Match neither " + exact + " nor " + relaxed);
+        }
+        return actual;
     }
 
     /**
@@ -138,11 +199,11 @@
         String[] lines = new String(bo.toByteArray()).split("\n");
         System.out.println("----------------- TEST -----------------");
         for (String line: lines) {
-            if (line.startsWith(">>> KDCCommunication")) {
+            if (cm.match(line)) {
                 System.out.println(line);
                 count--;
-                if (line.indexOf(proto) < 0) {
-                    throw new Exception("Wrong timeout value");
+                if (!cm.protocol().equals(proto)) {
+                    throw new Exception("Wrong protocol value");
                 }
             }
         }
@@ -165,6 +226,7 @@
             }
             if (s.startsWith("[realms]")) {
                 // Reconfig global setting
+                fw.write("kdc_timeout = 5000\n");
                 if (global != -1) {
                     fw.write("udp_preference_limit = " + global + "\n");
                 }
@@ -183,7 +245,8 @@
 
     /**
      * Set max_retries and timeout value for realm. The global value is always
-     * 2 and 5000.
+     * 3 and 5000.
+     *
      * @param value max_retries and timeout/1000 for a realm, -1 means none.
      */
     private static void rewriteMaxRetries(int value) throws Exception {
@@ -196,7 +259,7 @@
             }
             if (s.startsWith("[realms]")) {
                 // Reconfig global setting
-                fw.write("max_retries = 2\n");
+                fw.write("max_retries = 3\n");
                 fw.write("kdc_timeout = " + BadKdc.toReal(5000) + "\n");
             } else if (s.trim().startsWith("kdc = ")) {
                 if (value != -1) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/SSLContextImpl/CustomizedCipherSuites.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,270 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+
+/*
+ * @test
+ * @bug 8162362
+ * @summary Cannot enable previously default enabled cipher suites
+ * @run main/othervm
+ *      CustomizedCipherSuites Default true
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ * @run main/othervm
+ *      -Djdk.tls.client.cipherSuites="unknown"
+ *      CustomizedCipherSuites Default true
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ * @run main/othervm
+ *      -Djdk.tls.client.cipherSuites=""
+ *      CustomizedCipherSuites Default true
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ * @run main/othervm
+ *      -Djdk.tls.client.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
+ *      CustomizedCipherSuites Default true
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ * @run main/othervm
+ *      -Djdk.tls.server.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
+ *      CustomizedCipherSuites Default false
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ * @run main/othervm
+ *      -Djdk.tls.client.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,SSL_RSA_WITH_DES_CBC_SHA"
+ *      CustomizedCipherSuites Default true
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ *      ""
+ * @run main/othervm
+ *      -Djdk.tls.server.cipherSuites="TLS_RSA_WITH_AES_128_CBC_SHA,unknown,SSL_RSA_WITH_DES_CBC_SHA"
+ *      CustomizedCipherSuites Default false
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ *      ""
+ * @run main/othervm
+ *      -Djdk.tls.server.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
+ *      CustomizedCipherSuites Default true
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ * @run main/othervm
+ *      -Djdk.tls.client.cipherSuites="SSL_RSA_WITH_DES_CBC_SHA"
+ *      CustomizedCipherSuites Default false
+ *      TLS_RSA_WITH_AES_128_CBC_SHA
+ *      SSL_RSA_WITH_DES_CBC_SHA
+ */
+
+import javax.net.ssl.*;
+
+/**
+ * Test the customized default cipher suites.
+ *
+ * This test is based on the behavior that SSL_RSA_WITH_DES_CBC_SHA is
+ * disabled by default, and TLS_RSA_WITH_AES_128_CBC_SHA is enabled by
+ * default in JDK.  If the behavior is changed in the future, please
+ * update the test cases above accordingly.
+ */
+public class CustomizedCipherSuites {
+
+    private static String contextProtocol;
+    private static boolean isClientMode;
+
+    private static String enabledCipherSuite;
+    private static String disabledCipherSuite;
+
+    public static void main(String[] args) throws Exception {
+
+        contextProtocol = trimQuotes(args[0]);
+        isClientMode = Boolean.parseBoolean(args[1]);
+        enabledCipherSuite = trimQuotes(args[2]);
+        disabledCipherSuite = trimQuotes(args[3]);
+
+        //
+        // Create instance of SSLContext with the specified protocol.
+        //
+        SSLContext context = SSLContext.getInstance(contextProtocol);
+
+        // Default SSLContext is initialized automatically.
+        if (!contextProtocol.equals("Default")) {
+            // Use default TK, KM and random.
+            context.init((KeyManager[])null, (TrustManager[])null, null);
+        }
+
+        // SSLContext default parameters is client mode in JDK.
+        if (isClientMode) {
+            //
+            // Check default parameters of the specified SSLContext protocol
+            //
+            SSLParameters parameters = context.getDefaultSSLParameters();
+            System.out.println("Checking SSLContext default parameters ...");
+            checkEnabledCiphers(parameters.getCipherSuites());
+        }
+
+        //
+        // Check supported parameters of the specified SSLContext protocol
+        //
+        SSLParameters parameters = context.getSupportedSSLParameters();
+        System.out.println("Checking SSLContext suppport parameters ...");
+        checkSupportedCiphers(parameters.getCipherSuites());
+
+
+        //
+        // Check the default cipher suites of SSLEngine.
+        //
+        SSLEngine engine = context.createSSLEngine();
+        engine.setUseClientMode(isClientMode);
+
+        System.out.println("Checking SSLEngine default cipher suites ...");
+        checkEnabledCiphers(engine.getEnabledCipherSuites());
+
+        //
+        // Check the supported cipher suites of SSLEngine.
+        //
+        System.out.println("Checking SSLEngine supported cipher suites ...");
+        checkSupportedCiphers(engine.getSupportedCipherSuites());
+
+        if (isClientMode) {
+            SSLSocketFactory factory = context.getSocketFactory();
+            // Use an unconnected socket.
+            try (SSLSocket socket = (SSLSocket)factory.createSocket()) {
+                //
+                // Check the default cipher suites of SSLSocket.
+                //
+                System.out.println(
+                        "Checking SSLSocket default cipher suites ...");
+                checkEnabledCiphers(socket.getEnabledCipherSuites());
+
+                //
+                // Check the supported cipher suites of SSLSocket.
+                //
+                System.out.println(
+                        "Checking SSLSocket supported cipher suites ...");
+                checkSupportedCiphers(socket.getSupportedCipherSuites());
+            }
+        } else {
+            SSLServerSocketFactory factory = context.getServerSocketFactory();
+            // Use an unbound server socket.
+            try (SSLServerSocket socket =
+                    (SSLServerSocket)factory.createServerSocket()) {
+                //
+                // Check the default cipher suites of SSLServerSocket.
+                //
+                System.out.println(
+                        "Checking SSLServerSocket default cipher suites ...");
+                checkEnabledCiphers(socket.getEnabledCipherSuites());
+
+                //
+                // Check the supported cipher suites of SSLServerSocket.
+                //
+                System.out.println(
+                        "Checking SSLServerSocket supported cipher suites ...");
+                checkSupportedCiphers(socket.getSupportedCipherSuites());
+            }
+        }
+
+        System.out.println("\t... Success");
+    }
+
+    private static void checkEnabledCiphers(
+            String[] ciphers) throws Exception {
+
+        if (ciphers.length == 0) {
+            throw new Exception("No default cipher suites");
+        }
+
+        boolean isMatch = false;
+        if (enabledCipherSuite.isEmpty()) {
+            // Don't check if not specify the expected cipher suite.
+            isMatch = true;
+        }
+
+        boolean isBroken = false;
+        for (String cipher : ciphers) {
+            System.out.println("\tdefault cipher suite " + cipher);
+            if (!enabledCipherSuite.isEmpty() &&
+                        cipher.equals(enabledCipherSuite)) {
+                isMatch = true;
+            }
+
+            if (!disabledCipherSuite.isEmpty() &&
+                        cipher.equals(disabledCipherSuite)) {
+                isBroken = true;
+            }
+        }
+
+        if (!isMatch) {
+            throw new Exception(
+                "Cipher suite " + enabledCipherSuite + " should be enabled");
+        }
+
+        if (isBroken) {
+            throw new Exception(
+                "Cipher suite " + disabledCipherSuite + " should be disabled");
+        }
+    }
+
+    private static void checkSupportedCiphers(
+            String[] ciphers) throws Exception {
+
+        if (ciphers.length == 0) {
+            throw new Exception("No supported cipher suites");
+        }
+
+        boolean hasEnabledCipherSuite = enabledCipherSuite.isEmpty();
+        boolean hasDisabledCipherSuite = disabledCipherSuite.isEmpty();
+        for (String cipher : ciphers) {
+            System.out.println("\tsupported cipher suite " + cipher);
+            if (!enabledCipherSuite.isEmpty() &&
+                        cipher.equals(enabledCipherSuite)) {
+                hasEnabledCipherSuite = true;
+            }
+
+            if (!disabledCipherSuite.isEmpty() &&
+                        cipher.equals(disabledCipherSuite)) {
+                hasDisabledCipherSuite = true;
+            }
+        }
+
+        if (!hasEnabledCipherSuite) {
+            throw new Exception(
+                "Cipher suite " + enabledCipherSuite + " should be supported");
+        }
+
+        if (!hasDisabledCipherSuite) {
+            throw new Exception(
+                "Cipher suite " + disabledCipherSuite + " should be supported");
+        }
+    }
+
+    private static String trimQuotes(String candidate) {
+        if (candidate != null && candidate.length() != 0) {
+            // Remove double quote marks from beginning/end of the string.
+            if (candidate.length() > 1 && candidate.charAt(0) == '"' &&
+                    candidate.charAt(candidate.length() - 1) == '"') {
+                return candidate.substring(1, candidate.length() - 1);
+            }
+        }
+
+        return candidate;
+    }
+}
--- a/jdk/test/sun/security/tools/keytool/StartDateTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/jdk/test/sun/security/tools/keytool/StartDateTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -49,23 +49,31 @@
 
         new File("jks").delete();
 
-        run("-keystore jks -storetype jks -storepass changeit -keypass changeit -alias me " +
-                "-keyalg rsa -genkeypair -dname CN=Haha -startdate +1y");
-        cal.setTime(getIssueDate());
+        run("one", "+1y");
+        cal.setTime(getIssueDate("one"));
         System.out.println(cal);
         if (cal.get(Calendar.YEAR) != year + 1) {
             throw new Exception("Function check #1 fails");
         }
 
-        run("-keystore jks -storetype jks -storepass changeit -keypass changeit -alias me " +
-                "-selfcert -startdate +1m");
-        cal.setTime(getIssueDate());
+        run("two", "+1m");
+        cal.setTime(getIssueDate("two"));
         System.out.println(cal);
         if (cal.get(Calendar.MONTH) != (month + 1) % 12) {
             throw new Exception("Function check #2 fails");
         }
 
-        new File("jks").delete();
+        run("three", "2009/10/11 12:34:56");
+        cal.setTime(getIssueDate("three"));
+        System.out.println(cal);
+        if (cal.get(Calendar.YEAR) != 2009 ||
+                cal.get(Calendar.MONTH) != Calendar.OCTOBER ||
+                cal.get(Calendar.DAY_OF_MONTH) != 11 ||
+                cal.get(Calendar.HOUR_OF_DAY) != 12 ||
+                cal.get(Calendar.MINUTE) != 34 ||
+                cal.get(Calendar.SECOND) != 56) {
+            throw new Exception("Function check #3 fails");
+        }
 
         // Part 2: Test format
         Method m = sun.security.tools.keytool.Main.class.getDeclaredMethod(
@@ -129,16 +137,23 @@
         }
     }
 
-    static void run(String s) throws Exception {
-        sun.security.tools.keytool.Main.main((s+" -debug").split(" "));
+    // The keytool command line template, alias and startdate TBD
+    static String[] cmd = ("-alias tbd -startdate tbd -keystore jks " +
+            "-storetype jks -storepass changeit -keypass changeit " +
+            "-keyalg rsa -genkeypair -dname CN=Haha -debug").split(" ");
+
+    static void run(String alias, String startDate) throws Exception {
+        cmd[1] = alias;
+        cmd[3] = startDate;
+        sun.security.tools.keytool.Main.main(cmd);
     }
 
-    static Date getIssueDate() throws Exception {
+    static Date getIssueDate(String alias) throws Exception {
         KeyStore ks = KeyStore.getInstance("jks");
         try (FileInputStream fis = new FileInputStream("jks")) {
             ks.load(fis, "changeit".toCharArray());
         }
-        X509Certificate cert = (X509Certificate)ks.getCertificate("me");
+        X509Certificate cert = (X509Certificate)ks.getCertificate(alias);
         return cert.getNotBefore();
     }
 }
--- a/langtools/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -373,3 +373,4 @@
 2764986661b6d339ba73af52d69d3506ce12e648 jdk-9+128
 e181909291981038b041ed4d22714c4760e049cd jdk-9+129
 3665ebc22a42c8f33777ee025ba0e300e6086a8c jdk-9+130
+aebfafc43714d5a27d5064d8a0011eaccde633cf jdk-9+131
--- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java	Fri Aug 19 12:17:32 2016 -0700
@@ -107,6 +107,8 @@
                 "layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod");
         ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$ServiceLoaderHelper",
                 "loadMethod");
+        ignoreFields("com.sun.tools.javac.util.JDK9Wrappers$VMHelper",
+                "vmClass", "getRuntimeArgumentsMethod");
         ignoreFields("com.sun.tools.javac.util.ModuleHelper",
                 "addExportsMethod", "getUnnamedModuleMethod", "getModuleMethod");
     }
--- a/langtools/src/java.compiler/share/classes/javax/tools/DocumentationTool.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/java.compiler/share/classes/javax/tools/DocumentationTool.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -57,7 +57,7 @@
      * use the tool's default method for reporting diagnostics
      *
      * @param docletClass a class providing the necessary methods required
-     * of a doclet
+     * of a doclet; a value of {@code null} means to use the standard doclet.
      *
      * @param options documentation tool options and doclet options,
      * {@code null} means no options
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java	Fri Aug 19 12:17:32 2016 -0700
@@ -179,10 +179,10 @@
             args.init("javac", options, classes, compilationUnits);
 
             // init multi-release jar handling
-            if (fileManager.isSupportedOption(Option.MULTIRELEASE.text) == 1) {
+            if (fileManager.isSupportedOption(Option.MULTIRELEASE.primaryName) == 1) {
                 Target target = Target.instance(context);
                 List<String> list = List.of(target.multiReleaseValue());
-                fileManager.handleOption(Option.MULTIRELEASE.text, list.iterator());
+                fileManager.handleOption(Option.MULTIRELEASE.primaryName, list.iterator());
             }
 
             return new JavacTaskImpl(context);
@@ -212,8 +212,9 @@
     public int isSupportedOption(String option) {
         Set<Option> recognizedOptions = Option.getJavacToolOptions();
         for (Option o : recognizedOptions) {
-            if (o.matches(option))
+            if (o.matches(option)) {
                 return o.hasArg() ? 1 : 0;
+            }
         }
         return -1;
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -51,6 +51,7 @@
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.jvm.Profile;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.platform.PlatformDescription;
 import com.sun.tools.javac.util.*;
 
@@ -59,8 +60,6 @@
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 
-import static com.sun.tools.javac.main.Option.*;
-
 import com.sun.tools.javac.util.Dependencies.CompletionCause;
 
 /**
@@ -200,10 +199,10 @@
         annotate = Annotate.instance(context);
 
         Options options = Options.instance(context);
-        verbose = options.isSet(VERBOSE);
+        verbose = options.isSet(Option.VERBOSE);
         cacheCompletionFailure = options.isUnset("dev");
         preferSource = "source".equals(options.get("-Xprefer"));
-        userPathsFirst = options.isSet(XXUSERPATHSFIRST);
+        userPathsFirst = options.isSet(Option.XXUSERPATHSFIRST);
         allowSigFiles = context.get(PlatformDescription.class) != null;
 
         completionFailureName =
@@ -211,7 +210,7 @@
             ? names.fromString(options.get("failcomplete"))
             : null;
 
-        moduleOverride = options.isSet(XMODULE) ? names.fromString(options.get(XMODULE))
+        moduleOverride = options.isSet(Option.XMODULE) ? names.fromString(options.get(Option.XMODULE))
                                                 : null;
 
         // Temporary, until more info is available from the module system.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Aug 19 12:17:32 2016 -0700
@@ -4282,6 +4282,9 @@
             case TOPLEVEL:
                 attribTopLevel(env);
                 break;
+            case PACKAGEDEF:
+                attribPackage(env.tree.pos(), ((JCPackageDecl) env.tree).packge);
+                break;
             default:
                 attribClass(env.tree.pos(), env.enclClass.sym);
         }
@@ -4300,6 +4303,20 @@
         }
     }
 
+    public void attribPackage(DiagnosticPosition pos, PackageSymbol p) {
+        try {
+            annotate.flush();
+            attribPackage(p);
+        } catch (CompletionFailure ex) {
+            chk.completionError(pos, ex);
+        }
+    }
+
+    void attribPackage(PackageSymbol p) {
+        Env<AttrContext> env = typeEnvs.get(p);
+        chk.checkDeprecatedAnnotation(((JCPackageDecl) env.tree).pid.pos(), p);
+    }
+
     public void attribModule(DiagnosticPosition pos, ModuleSymbol m) {
         try {
             annotate.flush();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Fri Aug 19 12:17:32 2016 -0700
@@ -3197,6 +3197,21 @@
             log.warning(LintCategory.DEP_ANN,
                     pos, "missing.deprecated.annotation");
         }
+        // Note: @Deprecated has no effect on local variables, parameters and package decls.
+        if (lint.isEnabled(LintCategory.DEPRECATION)) {
+            if (!syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) != null) {
+                switch (s.getKind()) {
+                    case LOCAL_VARIABLE:
+                    case PACKAGE:
+                    case PARAMETER:
+                    case RESOURCE_VARIABLE:
+                    case EXCEPTION_PARAMETER:
+                        log.warning(LintCategory.DEPRECATION, pos,
+                                "deprecated.annotation.has.no.effect", Kinds.kindName(s));
+                        break;
+                }
+            }
+        }
     }
 
     void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Aug 19 12:17:32 2016 -0700
@@ -3184,11 +3184,13 @@
     }
 
     public void visitAssignop(final JCAssignOp tree) {
-        JCTree lhsAccess = access(TreeInfo.skipParens(tree.lhs));
         final boolean boxingReq = !tree.lhs.type.isPrimitive() &&
             tree.operator.type.getReturnType().isPrimitive();
 
-        if (boxingReq || lhsAccess.hasTag(APPLY)) {
+        AssignopDependencyScanner depScanner = new AssignopDependencyScanner(tree);
+        depScanner.scan(tree.rhs);
+
+        if (boxingReq || depScanner.dependencyFound) {
             // boxing required; need to rewrite as x = (unbox typeof x)(x op y);
             // or if x == (typeof x)z then z = (unbox typeof x)((typeof x)z op y)
             // (but without recomputing x)
@@ -3238,6 +3240,41 @@
         }
     }
 
+    class AssignopDependencyScanner extends TreeScanner {
+
+        Symbol sym;
+        boolean dependencyFound = false;
+
+        AssignopDependencyScanner(JCAssignOp tree) {
+            this.sym = TreeInfo.symbol(tree.lhs);
+        }
+
+        @Override
+        public void scan(JCTree tree) {
+            if (tree != null && sym != null) {
+                tree.accept(this);
+            }
+        }
+
+        @Override
+        public void visitAssignop(JCAssignOp tree) {
+            if (TreeInfo.symbol(tree.lhs) == sym) {
+                dependencyFound = true;
+                return;
+            }
+            super.visitAssignop(tree);
+        }
+
+        @Override
+        public void visitUnary(JCUnary tree) {
+            if (TreeInfo.symbol(tree.arg) == sym) {
+                dependencyFound = true;
+                return;
+            }
+            super.visitUnary(tree);
+        }
+    }
+
     /** Lower a tree of the form e++ or e-- where e is an object type */
     JCExpression lowerBoxedPostop(final JCUnary tree) {
         // translate to tmp1=lval(e); tmp2=tmp1; tmp1 OP 1; tmp2
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Fri Aug 19 12:17:32 2016 -0700
@@ -147,7 +147,9 @@
     private final String addReadsOpt;
     private Map<ModuleSymbol, Set<RequiresDirective>> addReads;
     private final String addModsOpt;
+    private final Set<String> extraAddMods = new HashSet<>();
     private final String limitModsOpt;
+    private final Set<String> extraLimitMods = new HashSet<>();
 
     private Set<ModuleSymbol> rootModules = null;
 
@@ -182,10 +184,10 @@
         java_se = names.fromString("java.se");
         java_ = names.fromString("java.");
 
-        addExportsOpt = options.get(Option.XADDEXPORTS);
-        addReadsOpt = options.get(Option.XADDREADS);
-        addModsOpt = options.get(Option.ADDMODS);
-        limitModsOpt = options.get(Option.LIMITMODS);
+        addExportsOpt = options.get(Option.ADD_EXPORTS);
+        addReadsOpt = options.get(Option.ADD_READS);
+        addModsOpt = options.get(Option.ADD_MODULES);
+        limitModsOpt = options.get(Option.LIMIT_MODULES);
     }
 
     int depth = -1;
@@ -195,8 +197,16 @@
         System.err.println(msg);
     }
 
+    public void addExtraAddModules(String... extras) {
+        extraAddMods.addAll(Arrays.asList(extras));
+    }
+
+    public void addExtraLimitModules(String... extras) {
+        extraLimitMods.addAll(Arrays.asList(extras));
+    }
+
     boolean inInitModules;
-    public void initModules(List<JCCompilationUnit> trees, Collection<String> extraAddMods, Collection<String> extraLimitMods) {
+    public void initModules(List<JCCompilationUnit> trees) {
         Assert.check(!inInitModules);
         try {
             inInitModules = true;
@@ -205,7 +215,7 @@
                 Assert.checkNull(rootModules);
                 Assert.checkNull(allModules);
                 this.rootModules = modules;
-                setupAllModules(extraAddMods, extraLimitMods); //initialize the module graph
+                setupAllModules(); //initialize the module graph
                 Assert.checkNonNull(allModules);
                 inInitModules = false;
             }, null);
@@ -862,7 +872,7 @@
         return allModules;
     }
 
-    private void setupAllModules(Collection<String> extraAddMods, Collection<String> extraLimitMods) {
+    private void setupAllModules() {
         Assert.checkNonNull(rootModules);
         Assert.checkNull(allModules);
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Fri Aug 19 12:17:32 2016 -0700
@@ -232,7 +232,7 @@
         OptionHelper helper = new GrumpyHelper(log) {
             @Override
             public String get(Option option) {
-                return options.get(option.getText());
+                return options.get(option);
             }
 
             @Override
@@ -251,23 +251,15 @@
             }
         };
 
-        for (Option o: javacFileManagerOptions) {
-            if (o.matches(current))  {
-                if (o.hasArg()) {
-                    if (remaining.hasNext()) {
-                        if (!o.process(helper, current, remaining.next()))
-                            return true;
-                    }
-                } else {
-                    if (!o.process(helper, current))
-                        return true;
-                }
-                // operand missing, or process returned true
-                throw new IllegalArgumentException(current);
-            }
+        Option o = Option.lookup(current, javacFileManagerOptions);
+        if (o == null) {
+            return false;
         }
 
-        return false;
+        if (!o.handleOption(helper, current, remaining))
+            throw new IllegalArgumentException(current);
+
+        return true;
     }
     // where
         private static final Set<Option> javacFileManagerOptions =
@@ -275,11 +267,8 @@
 
     @Override @DefinedBy(Api.COMPILER)
     public int isSupportedOption(String option) {
-        for (Option o : javacFileManagerOptions) {
-            if (o.matches(option))
-                return o.hasArg() ? 1 : 0;
-        }
-        return -1;
+        Option o = Option.lookup(option, javacFileManagerOptions);
+        return (o == null) ? -1 : o.hasArg() ? 1 : 0;
     }
 
     protected String multiReleaseValue;
@@ -316,7 +305,7 @@
             try {
                 ok = ok & handleOption(e.getKey(), e.getValue());
             } catch (IllegalArgumentException ex) {
-                log.error(Errors.IllegalArgumentForOption(e.getKey().getText(), ex.getMessage()));
+                log.error(Errors.IllegalArgumentForOption(e.getKey().getPrimaryName(), ex.getMessage()));
                 ok = false;
             }
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Fri Aug 19 12:17:32 2016 -0700
@@ -84,7 +84,7 @@
 
 import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
 
-import static com.sun.tools.javac.main.Option.BOOTCLASSPATH;
+import static com.sun.tools.javac.main.Option.BOOT_CLASS_PATH;
 import static com.sun.tools.javac.main.Option.DJAVA_ENDORSED_DIRS;
 import static com.sun.tools.javac.main.Option.DJAVA_EXT_DIRS;
 import static com.sun.tools.javac.main.Option.ENDORSEDDIRS;
@@ -580,8 +580,7 @@
     private class ClassPathLocationHandler extends SimpleLocationHandler {
 
         ClassPathLocationHandler() {
-            super(StandardLocation.CLASS_PATH,
-                    Option.CLASSPATH, Option.CP);
+            super(StandardLocation.CLASS_PATH, Option.CLASS_PATH);
         }
 
         @Override
@@ -649,7 +648,7 @@
 
         BootClassPathLocationHandler() {
             super(StandardLocation.PLATFORM_CLASS_PATH,
-                    Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH,
+                    Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH,
                     Option.XBOOTCLASSPATH_PREPEND,
                     Option.XBOOTCLASSPATH_APPEND,
                     Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
@@ -669,7 +668,7 @@
 
             option = canonicalize(option);
             optionValues.put(option, value);
-            if (option == BOOTCLASSPATH) {
+            if (option == BOOT_CLASS_PATH) {
                 optionValues.remove(XBOOTCLASSPATH_PREPEND);
                 optionValues.remove(XBOOTCLASSPATH_APPEND);
             }
@@ -682,7 +681,7 @@
         private Option canonicalize(Option option) {
             switch (option) {
                 case XBOOTCLASSPATH:
-                    return Option.BOOTCLASSPATH;
+                    return Option.BOOT_CLASS_PATH;
                 case DJAVA_ENDORSED_DIRS:
                     return Option.ENDORSEDDIRS;
                 case DJAVA_EXT_DIRS:
@@ -713,7 +712,7 @@
         SearchPath computePath() throws IOException {
             SearchPath path = new SearchPath();
 
-            String bootclasspathOpt = optionValues.get(BOOTCLASSPATH);
+            String bootclasspathOpt = optionValues.get(BOOT_CLASS_PATH);
             String endorseddirsOpt = optionValues.get(ENDORSEDDIRS);
             String extdirsOpt = optionValues.get(EXTDIRS);
             String xbootclasspathPrependOpt = optionValues.get(XBOOTCLASSPATH_PREPEND);
@@ -773,14 +772,14 @@
         private Collection<Path> systemClasses() throws IOException {
             // Return "modules" jimage file if available
             if (Files.isRegularFile(thisSystemModules)) {
-                return addAdditionalBootEntries(Collections.singleton(thisSystemModules));
+                return Collections.singleton(thisSystemModules);
             }
 
             // Exploded module image
             Path modules = javaHome.resolve("modules");
             if (Files.isDirectory(modules.resolve("java.base"))) {
                 try (Stream<Path> listedModules = Files.list(modules)) {
-                    return addAdditionalBootEntries(listedModules.collect(Collectors.toList()));
+                    return listedModules.collect(Collectors.toList());
                 }
             }
 
@@ -788,26 +787,6 @@
             return null;
         }
 
-        //ensure bootclasspath prepends/appends are reflected in the systemClasses
-        private Collection<Path> addAdditionalBootEntries(Collection<Path> modules) throws IOException {
-            String files = System.getProperty("sun.boot.class.path");
-            if (files == null)
-                return modules;
-
-            Set<Path> paths = new LinkedHashSet<>();
-
-            // The JVM no longer supports -Xbootclasspath/p:, so any interesting
-            // entries should be appended to the set of modules.
-
-            paths.addAll(modules);
-
-            for (String s : files.split(Pattern.quote(File.pathSeparator))) {
-                paths.add(getPath(s));
-            }
-
-            return paths;
-        }
-
         private void lazy() {
             if (searchPath == null) {
                 try {
@@ -1161,7 +1140,7 @@
 
         ModuleSourcePathLocationHandler() {
             super(StandardLocation.MODULE_SOURCE_PATH,
-                    Option.MODULESOURCEPATH);
+                    Option.MODULE_SOURCE_PATH);
         }
 
         @Override
@@ -1493,16 +1472,16 @@
         BasicLocationHandler[] handlers = {
             new BootClassPathLocationHandler(),
             new ClassPathLocationHandler(),
-            new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCEPATH),
-            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSORPATH),
-            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSORMODULEPATH),
+            new SimpleLocationHandler(StandardLocation.SOURCE_PATH, Option.SOURCE_PATH),
+            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_PATH, Option.PROCESSOR_PATH),
+            new SimpleLocationHandler(StandardLocation.ANNOTATION_PROCESSOR_MODULE_PATH, Option.PROCESSOR_MODULE_PATH),
             new OutputLocationHandler(StandardLocation.CLASS_OUTPUT, Option.D),
             new OutputLocationHandler(StandardLocation.SOURCE_OUTPUT, Option.S),
             new OutputLocationHandler(StandardLocation.NATIVE_HEADER_OUTPUT, Option.H),
             new ModuleSourcePathLocationHandler(),
             // TODO: should UPGRADE_MODULE_PATH be merged with SYSTEM_MODULES?
-            new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADEMODULEPATH),
-            new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULEPATH, Option.MP),
+            new ModulePathLocationHandler(StandardLocation.UPGRADE_MODULE_PATH, Option.UPGRADE_MODULE_PATH),
+            new ModulePathLocationHandler(StandardLocation.MODULE_PATH, Option.MODULE_PATH),
             new SystemModulesLocationHandler(),
         };
 
@@ -1518,29 +1497,42 @@
 
     boolean handleOption(Option option, String value) {
         switch (option) {
-            case XPATCH:
-                Map<String, SearchPath> map = new LinkedHashMap<>();
-                int eq = value.indexOf('=');
-                if (eq > 0) {
-                    String mName = value.substring(0, eq);
-                    SearchPath mPatchPath = new SearchPath()
-                            .addFiles(value.substring(eq + 1));
-                    boolean ok = true;
-                    for (Path p: mPatchPath) {
-                        Path mi = p.resolve("module-info.class");
-                        if (Files.exists(mi)) {
-                            log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(mi));
-                            ok = false;
+            case PATCH_MODULE:
+                if (value == null) {
+                    patchMap = null;
+                } else {
+                    // Allow an extended syntax for --patch-module consisting of a series
+                    // of values separated by NULL characters. This is to facilitate
+                    // supporting deferred file manager options on the command line.
+                    // See Option.PATCH_MODULE for the code that composes these multiple
+                    // values.
+                    for (String v : value.split("\0")) {
+                        int eq = v.indexOf('=');
+                        if (eq > 0) {
+                            String mName = v.substring(0, eq);
+                            SearchPath mPatchPath = new SearchPath()
+                                    .addFiles(v.substring(eq + 1));
+                            boolean ok = true;
+                            for (Path p : mPatchPath) {
+                                Path mi = p.resolve("module-info.class");
+                                if (Files.exists(mi)) {
+                                    log.error(Errors.LocnModuleInfoNotAllowedOnPatchPath(mi));
+                                    ok = false;
+                                }
+                            }
+                            if (ok) {
+                                if (patchMap == null) {
+                                    patchMap = new LinkedHashMap<>();
+                                }
+                                patchMap.put(mName, mPatchPath);
+                            }
+                        } else {
+                            // Should not be able to get here;
+                            // this should be caught and handled in Option.PATCH_MODULE
+                            log.error(Errors.LocnInvalidArgForXpatch(value));
                         }
                     }
-                    if (ok && !mPatchPath.isEmpty()) {
-                        map.computeIfAbsent(mName, (_x) -> new SearchPath())
-                                .addAll(mPatchPath);
-                    }
-                } else {
-                    log.error(Errors.LocnInvalidArgForXpatch(value));
                 }
-                patchMap = map;
                 return true;
             default:
                 LocationHandler h = handlersForOption.get(option);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Aug 19 12:17:32 2016 -0700
@@ -55,6 +55,7 @@
 import com.sun.tools.javac.file.PathFileObject;
 import com.sun.tools.javac.jvm.ClassFile.NameAndType;
 import com.sun.tools.javac.jvm.ClassFile.Version;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -67,7 +68,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.Option.*;
+import static com.sun.tools.javac.main.Option.PARAMETERS;
 
 /** This class provides operations to read a classfile into an internal
  *  representation. The internal representation is anchored in a
@@ -236,7 +237,7 @@
         log = Log.instance(context);
 
         Options options = Options.instance(context);
-        verbose         = options.isSet(VERBOSE);
+        verbose         = options.isSet(Option.VERBOSE);
 
         Source source = Source.instance(context);
         allowSimplifiedVarargs = source.allowSimplifiedVarargs();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java	Fri Aug 19 12:17:32 2016 -0700
@@ -63,6 +63,7 @@
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
@@ -143,7 +144,7 @@
 
         @Override
         public boolean handleFileManagerOption(Option option, String value) {
-            options.put(option.getText(), value);
+            options.put(option, value);
             deferredFileManagerOptions.put(option, value);
             return true;
         }
@@ -164,6 +165,11 @@
         }
 
         @Override
+        public void error(JCDiagnostic.Error error) {
+            Arguments.this.error(error);
+        }
+
+        @Override
         public void addFile(Path p) {
             files.add(p);
         }
@@ -193,12 +199,15 @@
         fileObjects = null;
         classNames = new LinkedHashSet<>();
         processArgs(List.from(args), Option.getJavaCompilerOptions(), cmdLineHelper, true, false);
+        if (errors) {
+            log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
+        }
     }
 
     private final OptionHelper apiHelper = new GrumpyHelper(null) {
         @Override
         public String get(Option option) {
-            return options.get(option.getText());
+            return options.get(option);
         }
 
         @Override
@@ -297,8 +306,8 @@
         String platformString = options.get(Option.RELEASE);
 
         checkOptionAllowed(platformString == null,
-                option -> error("err.release.bootclasspath.conflict", option.getText()),
-                Option.BOOTCLASSPATH, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
+                option -> error("err.release.bootclasspath.conflict", option.getPrimaryName()),
+                Option.BOOT_CLASS_PATH, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
                 Option.XBOOTCLASSPATH_PREPEND,
                 Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
                 Option.EXTDIRS, Option.DJAVA_EXT_DIRS,
@@ -360,39 +369,29 @@
             }
 
             Option option = null;
+
+            // first, check the provided set of javac options
             if (arg.startsWith("-")) {
-                for (Option o : allowableOpts) {
-                    if (o.matches(arg)) {
-                        option = o;
-                        break;
-                    }
-                }
+                option = Option.lookup(arg, allowableOpts);
             } else if (allowOperands && Option.SOURCEFILE.matches(arg)) {
                 option = Option.SOURCEFILE;
             }
 
-            if (option == null) {
-                if (fm != null && fm.handleOption(arg, argIter)) {
-                    continue;
+            if (option != null) {
+                if (!option.handleOption(helper, arg, argIter)) {
+                    return false;
                 }
-                error("err.invalid.flag", arg);
-                return false;
+                continue;
             }
 
-            if (option.hasArg()) {
-                if (!argIter.hasNext()) {
-                    error("err.req.arg", arg);
-                    return false;
-                }
-                String operand = argIter.next();
-                if (option.process(helper, arg, operand)) {
-                    return false;
-                }
-            } else {
-                if (option.process(helper, arg)) {
-                    return false;
-                }
+            // check file manager option
+            if (fm != null && fm.handleOption(arg, argIter)) {
+                continue;
             }
+
+            // none of the above
+            error("err.invalid.flag", arg);
+            return false;
         }
 
         return true;
@@ -407,13 +406,13 @@
      */
     public boolean validate() {
         JavaFileManager fm = getFileManager();
-        if (options.isSet(Option.M)) {
+        if (options.isSet(Option.MODULE)) {
             if (!fm.hasLocation(StandardLocation.CLASS_OUTPUT)) {
                 log.error(Errors.OutputDirMustBeSpecifiedWithDashMOption);
             } else if (!fm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
                 log.error(Errors.ModulesourcepathMustBeSpecifiedWithDashMOption);
             } else {
-                java.util.List<String> modules = Arrays.asList(options.get(Option.M).split(","));
+                java.util.List<String> modules = Arrays.asList(options.get(Option.MODULE).split(","));
                 try {
                     for (String module : modules) {
                         Location sourceLoc = fm.getModuleLocation(StandardLocation.MODULE_SOURCE_PATH, module);
@@ -449,17 +448,20 @@
                 || options.isSet(Option.X)
                 || options.isSet(Option.VERSION)
                 || options.isSet(Option.FULLVERSION)
-                || options.isSet(Option.M))
+                || options.isSet(Option.MODULE))
                 return true;
 
             if (emptyAllowed)
                 return true;
 
-            if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
-                error("err.no.source.files.classes");
-            } else {
-                error("err.no.source.files");
+            if (!errors) {
+                if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
+                    error("err.no.source.files.classes");
+                } else {
+                    error("err.no.source.files");
+                }
             }
+
             return false;
         }
 
@@ -542,12 +544,12 @@
 
             // This check is only effective in command line mode,
             // where the file manager options are added to options
-            if (options.get(Option.BOOTCLASSPATH) != null) {
+            if (options.get(Option.BOOT_CLASS_PATH) != null) {
                 error("err.profile.bootclasspath.conflict");
             }
         }
 
-        if (options.isSet(Option.SOURCEPATH) && options.isSet(Option.MODULESOURCEPATH)) {
+        if (options.isSet(Option.SOURCE_PATH) && options.isSet(Option.MODULE_SOURCE_PATH)) {
             error("err.sourcepath.modulesourcepath.conflict");
         }
 
@@ -578,17 +580,17 @@
 
         final Target t = target;
         checkOptionAllowed(t.compareTo(Target.JDK1_8) <= 0,
-                option -> error("err.option.not.allowed.with.target", option.getText(), t.name),
-                Option.BOOTCLASSPATH,
+                option -> error("err.option.not.allowed.with.target", option.getPrimaryName(), t.name),
+                Option.BOOT_CLASS_PATH,
                 Option.XBOOTCLASSPATH_PREPEND, Option.XBOOTCLASSPATH, Option.XBOOTCLASSPATH_APPEND,
                 Option.ENDORSEDDIRS, Option.DJAVA_ENDORSED_DIRS,
                 Option.EXTDIRS, Option.DJAVA_EXT_DIRS);
 
         checkOptionAllowed(t.compareTo(Target.JDK1_9) >= 0,
-                option -> error("err.option.not.allowed.with.target", option.getText(), t.name),
-                Option.MODULESOURCEPATH, Option.UPGRADEMODULEPATH,
-                Option.SYSTEM, Option.MODULEPATH, Option.ADDMODS, Option.LIMITMODS,
-                Option.XPATCH);
+                option -> error("err.option.not.allowed.with.target", option.getPrimaryName(), t.name),
+                Option.MODULE_SOURCE_PATH, Option.UPGRADE_MODULE_PATH,
+                Option.SYSTEM, Option.MODULE_PATH, Option.ADD_MODULES, Option.LIMIT_MODULES,
+                Option.PATCH_MODULE);
 
         if (fm.hasLocation(StandardLocation.MODULE_SOURCE_PATH)) {
             if (!options.isSet(Option.PROC, "only")
@@ -608,7 +610,7 @@
         if (obsoleteOptionFound)
             log.warning(LintCategory.OPTIONS, "option.obsolete.suppression");
 
-        String addExports = options.get(Option.XADDEXPORTS);
+        String addExports = options.get(Option.ADD_EXPORTS);
         if (addExports != null) {
             // Each entry must be of the form module/package=target-list where target-list is a
             // comma-separated list of module or ALL-UNNAMED.
@@ -636,7 +638,7 @@
             });
         }
 
-        String addReads = options.get(Option.XADDREADS);
+        String addReads = options.get(Option.ADD_READS);
         if (addReads != null) {
             // Each entry must be of the form module=source-list where source-list is a
             // comma separated list of module or ALL-UNNAMED.
@@ -724,7 +726,7 @@
             for (String s: xdoclintCustom.split("\\s+")) {
                 if (s.isEmpty())
                     continue;
-                doclintOpts.add(s.replace(Option.XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
+                doclintOpts.add(DocLint.XMSGS_CUSTOM_PREFIX + s);
             }
         }
 
@@ -735,14 +737,13 @@
 
         if (checkPackages != null) {
             for (String s : checkPackages.split("\\s+")) {
-                doclintOpts.add(s.replace(Option.XDOCLINT_PACKAGE.text, DocLint.XCHECK_PACKAGE));
+                doclintOpts.add(DocLint.XCHECK_PACKAGE + s);
             }
         }
 
         // standard doclet normally generates H1, H2,
         // so for now, allow user comments to assume that
         doclintOpts.add(DocLint.XIMPLICIT_HEADERS + "2");
-
         return List.from(doclintOpts.toArray(new String[doclintOpts.size()]));
     }
 
@@ -771,6 +772,22 @@
         }
     }
 
+    void error(JCDiagnostic.Error error) {
+        errors = true;
+        switch (errorMode) {
+            case ILLEGAL_ARGUMENT: {
+                String msg = log.localize(error);
+                throw new PropagatedException(new IllegalArgumentException(msg));
+            }
+            case ILLEGAL_STATE: {
+                String msg = log.localize(error);
+                throw new PropagatedException(new IllegalStateException(msg));
+            }
+            case LOG:
+                report(error);
+        }
+    }
+
     void error(String key, Object... args) {
         errors = true;
         switch (errorMode) {
@@ -784,7 +801,6 @@
             }
             case LOG:
                 report(key, args);
-                log.printLines(PrefixKind.JAVAC, "msg.usage", ownName);
         }
     }
 
@@ -797,6 +813,11 @@
         log.printRawLines(ownName + ": " + log.localize(PrefixKind.JAVAC, key, args));
     }
 
+    private void report(JCDiagnostic.Error error) {
+        // Would be good to have support for -XDrawDiagnostics here
+        log.printRawLines(ownName + ": " + log.localize(error));
+    }
+
     private JavaFileManager getFileManager() {
         if (fileManager == null)
             fileManager = context.get(JavaFileManager.class);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Aug 19 12:17:32 2016 -0700
@@ -892,14 +892,21 @@
 
         // 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.text + "-" + LintCategory.OPTIONS.option, "true");
-        options.remove(XLINT_CUSTOM.text + LintCategory.OPTIONS.option);
+        options.put(XLINT_CUSTOM.primaryName + "-" + LintCategory.OPTIONS.option, "true");
+        options.remove(XLINT_CUSTOM.primaryName + LintCategory.OPTIONS.option);
 
         start_msec = now();
 
         try {
             initProcessAnnotations(processors);
 
+            for (String className : classnames) {
+                int sep = className.indexOf('/');
+                if (sep != -1) {
+                    modules.addExtraAddModules(className.substring(0, sep));
+                }
+            }
+
             // These method calls must be chained to avoid memory leaks
             processAnnotations(
                 enterTrees(
@@ -1010,7 +1017,7 @@
     }
 
     public List<JCCompilationUnit> initModules(List<JCCompilationUnit> roots) {
-        modules.initModules(roots, Collections.emptySet(), Collections.emptySet());
+        modules.initModules(roots);
         if (roots.isEmpty()) {
             enterDone = true;
         }
@@ -1258,8 +1265,8 @@
     static boolean explicitAnnotationProcessingRequested(Options options) {
         return
             options.isSet(PROCESSOR) ||
-            options.isSet(PROCESSORPATH) ||
-            options.isSet(PROCESSORMODULEPATH) ||
+            options.isSet(PROCESSOR_PATH) ||
+            options.isSet(PROCESSOR_MODULE_PATH) ||
             options.isSet(PROC, "only") ||
             options.isSet(XPRINT);
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -176,12 +176,13 @@
         log = Log.instance(context);
 
         if (argv.length == 0) {
-            Option.HELP.process(new OptionHelper.GrumpyHelper(log) {
+            OptionHelper h = new OptionHelper.GrumpyHelper(log) {
                 @Override
                 public String getOwnName() { return ownName; }
                 @Override
                 public void put(String name, String value) { }
-            }, "-help");
+            };
+            Option.HELP.process(h, "-help");
             return Result.CMDERR;
         }
 
@@ -266,10 +267,10 @@
         }
 
         // init multi-release jar handling
-        if (fileManager.isSupportedOption(Option.MULTIRELEASE.text) == 1) {
+        if (fileManager.isSupportedOption(Option.MULTIRELEASE.primaryName) == 1) {
             Target target = Target.instance(context);
             List<String> list = List.of(target.multiReleaseValue());
-            fileManager.handleOption(Option.MULTIRELEASE.text, list.iterator());
+            fileManager.handleOption(Option.MULTIRELEASE.primaryName, list.iterator());
         }
 
         // init JavaCompiler
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Fri Aug 19 12:17:32 2016 -0700
@@ -30,9 +30,14 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.text.Collator;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.EnumSet;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.ServiceLoader;
 import java.util.Set;
@@ -51,6 +56,9 @@
 import com.sun.tools.javac.jvm.Target;
 import com.sun.tools.javac.platform.PlatformProvider;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.util.Assert;
+import com.sun.tools.javac.util.JDK9Wrappers;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Log.PrefixKind;
 import com.sun.tools.javac.util.Log.WriterKind;
@@ -62,10 +70,13 @@
 import static com.sun.tools.javac.main.Option.OptionKind.*;
 
 /**
- * Options for javac. The specific Option to handle a command-line option
- * is identified by searching the members of this enum in order, looking for
- * the first {@link #matches match}. The action for an Option is performed
- * by calling {@link #process process}, and by providing a suitable
+ * Options for javac.
+ * The specific Option to handle a command-line option can be found by calling
+ * {@link #lookup}, which search some or all of the members of this enum in order,
+ * looking for the first {@link #matches match}.
+ * The action for an Option is performed {@link #handleOption}, which determines
+ * whether an argument is needed and where to find it;
+ * {@code handleOption} then calls {@link #process process} providing a suitable
  * {@link OptionHelper} to provide access the compiler state.
  *
  * <p><b>This is NOT part of any supported API.
@@ -89,17 +100,12 @@
 
     XLINT("-Xlint", "opt.Xlint", EXTENDED, BASIC),
 
-    XLINT_CUSTOM("-Xlint:", EXTENDED, BASIC, ANYOF, getXLintChoices()) {
-        private static final String LINT_KEY_FORMAT = "         %-19s %s";
+    XLINT_CUSTOM("-Xlint:", "opt.arg.Xlint", "opt.Xlint.custom", EXTENDED, BASIC, ANYOF, getXLintChoices()) {
+        private final String LINT_KEY_FORMAT = LARGE_INDENT + "  %-" +
+                (DEFAULT_SYNOPSIS_WIDTH + SMALL_INDENT.length() - LARGE_INDENT.length() - 2) + "s %s";
         @Override
-        void help(Log log, OptionKind kind) {
-            if (this.kind != kind)
-                return;
-
-            log.printRawLines(WriterKind.STDOUT,
-                              String.format(HELP_LINE_FORMAT,
-                                            log.localize(PrefixKind.JAVAC, "opt.Xlint.subopts"),
-                                            log.localize(PrefixKind.JAVAC, "opt.Xlint.suboptlist")));
+        protected void help(Log log) {
+            super.help(log);
             log.printRawLines(WriterKind.STDOUT,
                               String.format(LINT_KEY_FORMAT,
                                             "all",
@@ -125,14 +131,14 @@
         @Override
         public boolean matches(String option) {
             return DocLint.isValidOption(
-                    option.replace(XDOCLINT_CUSTOM.text, DocLint.XMSGS_CUSTOM_PREFIX));
+                    option.replace(XDOCLINT_CUSTOM.primaryName, DocLint.XMSGS_CUSTOM_PREFIX));
         }
 
         @Override
         public boolean process(OptionHelper helper, String option) {
             String prev = helper.get(XDOCLINT_CUSTOM);
             String next = (prev == null) ? option : (prev + " " + option);
-            helper.put(XDOCLINT_CUSTOM.text, next);
+            helper.put(XDOCLINT_CUSTOM.primaryName, next);
             return false;
         }
     },
@@ -141,14 +147,14 @@
         @Override
         public boolean matches(String option) {
             return DocLint.isValidOption(
-                    option.replace(XDOCLINT_PACKAGE.text, DocLint.XCHECK_PACKAGE));
+                    option.replace(XDOCLINT_PACKAGE.primaryName, DocLint.XCHECK_PACKAGE));
         }
 
         @Override
         public boolean process(OptionHelper helper, String option) {
             String prev = helper.get(XDOCLINT_PACKAGE);
             String next = (prev == null) ? option : (prev + " " + option);
-            helper.put(XDOCLINT_PACKAGE.text, next);
+            helper.put(XDOCLINT_PACKAGE.primaryName, next);
             return false;
         }
     },
@@ -173,35 +179,55 @@
         }
     },
 
-    CLASSPATH("-classpath", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
+    CLASS_PATH("--class-path -classpath -cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER),
+
+    SOURCE_PATH("--source-path -sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
+
+    MODULE_SOURCE_PATH("--module-source-path -modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER),
+
+    MODULE_PATH("--module-path -p -modulepath -mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER),
 
-    CP("-cp", "opt.arg.path", "opt.classpath", STANDARD, FILEMANAGER) {
+    UPGRADE_MODULE_PATH("--upgrade-module-path -upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER),
+
+    SYSTEM("--system -system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER),
+
+    PATCH_MODULE("--patch-module -Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER) {
+        // The deferred filemanager diagnostics mechanism assumes a single value per option,
+        // but --patch-module can be used multiple times, once per module. Therefore we compose
+        // a value for the option containing the last value specified for each module, and separate
+        // the the module=path pairs by an invalid path character, NULL.
+        // The standard file manager code knows to split apart the NULL-separated components.
         @Override
         public boolean process(OptionHelper helper, String option, String arg) {
-            return super.process(helper, "-classpath", arg);
+            if (!arg.contains("=")) { // could be more strict regeex, e.g. "(?i)[a-z0-9_.]+=.*"
+                helper.error(Errors.LocnInvalidArgForXpatch(arg));
+            }
+
+            String previous = helper.get(this);
+            if (previous == null) {
+                return super.process(helper, option, arg);
+            }
+
+            Map<String,String> map = new LinkedHashMap<>();
+            for (String s : previous.split("\0")) {
+                int sep = s.indexOf('=');
+                map.put(s.substring(0, sep), s.substring(sep + 1));
+            }
+
+            int sep = arg.indexOf('=');
+            map.put(arg.substring(0, sep), arg.substring(sep + 1));
+
+            StringBuilder sb = new StringBuilder();
+            map.forEach((m, p) -> {
+                if (sb.length() > 0)
+                    sb.append('\0');
+                sb.append(m).append('=').append(p);
+            });
+            return super.process(helper, option, sb.toString());
         }
     },
 
-    SOURCEPATH("-sourcepath", "opt.arg.path", "opt.sourcepath", STANDARD, FILEMANAGER),
-
-    MODULESOURCEPATH("-modulesourcepath", "opt.arg.mspath", "opt.modulesourcepath", STANDARD, FILEMANAGER),
-
-    MODULEPATH("-modulepath", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER),
-
-    MP("-mp", "opt.arg.path", "opt.modulepath", STANDARD, FILEMANAGER) {
-        @Override
-        public boolean process(OptionHelper helper, String option, String arg) {
-            return super.process(helper, "-modulepath", arg);
-        }
-    },
-
-    UPGRADEMODULEPATH("-upgrademodulepath", "opt.arg.path", "opt.upgrademodulepath", STANDARD, FILEMANAGER),
-
-    SYSTEM("-system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER),
-
-    XPATCH("-Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER),
-
-    BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
+    BOOT_CLASS_PATH("--boot-class-path -bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
         @Override
         public boolean process(OptionHelper helper, String option, String arg) {
             helper.remove("-Xbootclasspath/p:");
@@ -228,7 +254,7 @@
     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);
+            return EXTDIRS.process(helper, "-extdirs", arg);
         }
     },
 
@@ -237,7 +263,7 @@
     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);
+            return ENDORSEDDIRS.process(helper, "-endorseddirs", arg);
         }
     },
 
@@ -245,9 +271,9 @@
 
     PROCESSOR("-processor", "opt.arg.class.list", "opt.processor", STANDARD, BASIC),
 
-    PROCESSORPATH("-processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
+    PROCESSOR_PATH("--processor-path -processorpath", "opt.arg.path", "opt.processorpath", STANDARD, FILEMANAGER),
 
-    PROCESSORMODULEPATH("-processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER),
+    PROCESSOR_MODULE_PATH("--processor-module-path -processormodulepath", "opt.arg.path", "opt.processormodulepath", STANDARD, FILEMANAGER),
 
     PARAMETERS("-parameters","opt.parameters", STANDARD, BASIC),
 
@@ -285,12 +311,9 @@
         }
     },
 
-    RELEASE("-release", "opt.arg.release", "opt.release", STANDARD, BASIC) {
+    RELEASE("--release -release", "opt.arg.release", "opt.release", STANDARD, BASIC) {
         @Override
-        void help(Log log, OptionKind kind) {
-            if (this.kind != kind)
-                return;
-
+        protected void help(Log log) {
             Iterable<PlatformProvider> providers =
                     ServiceLoader.load(PlatformProvider.class, Arguments.class.getClassLoader());
             Set<String> platforms = StreamSupport.stream(providers.spliterator(), false)
@@ -307,10 +330,7 @@
                 delim = ", ";
             }
 
-            log.printRawLines(WriterKind.STDOUT,
-                    String.format(HELP_LINE_FORMAT,
-                        super.helpSynopsis(log),
-                        log.localize(PrefixKind.JAVAC, descrKey, targets.toString())));
+            super.help(log, log.localize(PrefixKind.JAVAC, descrKey, targets.toString()));
         }
     },
 
@@ -346,21 +366,20 @@
         }
     },
 
-    HELP("-help", "opt.help", STANDARD, INFO) {
+    // Note: -h is already taken for "native header output directory".
+    HELP("--help -help", "opt.help", STANDARD, INFO) {
         @Override
         public boolean process(OptionHelper helper, String option) {
             Log log = helper.getLog();
             String ownName = helper.getOwnName();
             log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.header", ownName);
-            for (Option o: getJavaCompilerOptions()) {
-                o.help(log, OptionKind.STANDARD);
-            }
+            showHelp(log, OptionKind.STANDARD);
             log.printNewline(WriterKind.STDOUT);
             return super.process(helper, option);
         }
     },
 
-    A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, true) {
+    A("-A", "opt.arg.key.equals.value", "opt.A", STANDARD, BASIC, ArgKind.ADJACENT) {
         @Override
         public boolean matches(String arg) {
             return arg.startsWith("-A");
@@ -385,7 +404,8 @@
                 helper.error("err.invalid.A.key", option);
                 return true;
             }
-            return process(helper, option, option);
+            helper.put(option, option);
+            return false;
         }
     },
 
@@ -393,9 +413,7 @@
         @Override
         public boolean process(OptionHelper helper, String option) {
             Log log = helper.getLog();
-            for (Option o: getJavaCompilerOptions()) {
-                o.help(log, OptionKind.EXTENDED);
-            }
+            showHelp(log, OptionKind.EXTENDED);
             log.printNewline(WriterKind.STDOUT);
             log.printLines(WriterKind.STDOUT, PrefixKind.JAVAC, "msg.usage.nonstandard.footer");
             return super.process(helper, option);
@@ -404,7 +422,7 @@
 
     // 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, true) {
+    J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) {
         @Override
         public boolean process(OptionHelper helper, String option) {
             throw new AssertionError
@@ -484,7 +502,7 @@
         public boolean process(OptionHelper helper, String option) {
             String p = option.substring(option.indexOf(':') + 1).trim();
             String prev = helper.get(PLUGIN);
-            helper.put(PLUGIN.text, (prev == null) ? p : prev + '\0' + p);
+            helper.put(PLUGIN.primaryName, (prev == null) ? p : prev + '\0' + p);
             return false;
         }
     },
@@ -517,7 +535,7 @@
         }
     },
 
-    DIAGS("-diags:", null, HIDDEN, BASIC, true) {
+    DIAGS("-diags:", null, HIDDEN, BASIC) {
         @Override
         public boolean process(OptionHelper helper, String option) {
             return HiddenGroup.DIAGS.process(helper, option);
@@ -531,11 +549,11 @@
     XD("-XD", null, HIDDEN, BASIC) {
         @Override
         public boolean matches(String s) {
-            return s.startsWith(text);
+            return s.startsWith(primaryName);
         }
         @Override
         public boolean process(OptionHelper helper, String option) {
-            return process(helper, option, option.substring(text.length()));
+            return process(helper, option, option.substring(primaryName.length()));
         }
 
         @Override
@@ -548,47 +566,45 @@
         }
     },
 
-    XADDEXPORTS("-XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) {
+    ADD_EXPORTS("--add-exports -XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) {
         @Override
-        public boolean process(OptionHelper helper, String option) {
-            String p = option.substring(option.indexOf(':') + 1).trim();
-            String prev = helper.get(XADDEXPORTS);
-            helper.put(XADDEXPORTS.text, (prev == null) ? p : prev + '\0' + p);
+        public boolean process(OptionHelper helper, String option, String arg) {
+            String prev = helper.get(ADD_EXPORTS);
+            helper.put(ADD_EXPORTS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
             return false;
         }
     },
 
-    XADDREADS("-XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) {
+    ADD_READS("--add-reads -XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) {
         @Override
-        public boolean process(OptionHelper helper, String option) {
-            String p = option.substring(option.indexOf(':') + 1).trim();
-            String prev = helper.get(XADDREADS);
-            helper.put(XADDREADS.text, (prev == null) ? p : prev + '\0' + p);
+        public boolean process(OptionHelper helper, String option, String arg) {
+            String prev = helper.get(ADD_READS);
+            helper.put(ADD_READS.primaryName, (prev == null) ? arg : prev + '\0' + arg);
             return false;
         }
     },
 
     XMODULE("-Xmodule:", "opt.arg.module", "opt.module", EXTENDED, BASIC) {
         @Override
-        public boolean process(OptionHelper helper, String option) {
+        public boolean process(OptionHelper helper, String option, String arg) {
             String prev = helper.get(XMODULE);
             if (prev != null) {
-                helper.error("err.option.too.many", XMODULE.text);
+                helper.error("err.option.too.many", XMODULE.primaryName);
             }
-            String p = option.substring(option.indexOf(':') + 1);
-            helper.put(XMODULE.text, p);
+            helper.put(XMODULE.primaryName, arg);
             return false;
         }
     },
 
-    M("-m", "opt.arg.m", "opt.m", STANDARD, BASIC),
+    MODULE("--module -m", "opt.arg.m", "opt.m", STANDARD, BASIC),
 
-    ADDMODS("-addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC),
-    LIMITMODS("-limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC),
+    ADD_MODULES("--add-modules -addmods", "opt.arg.addmods", "opt.addmods", STANDARD, BASIC),
+
+    LIMIT_MODULES("--limit-modules -limitmods", "opt.arg.limitmods", "opt.limitmods", STANDARD, BASIC),
 
     // 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, true) {
+    AT("@", "opt.arg.file", "opt.AT", STANDARD, INFO, ArgKind.ADJACENT) {
         @Override
         public boolean process(OptionHelper helper, String option) {
             throw new AssertionError("the @ flag should be caught by CommandLine.");
@@ -629,9 +645,78 @@
         }
     },
 
-    MULTIRELEASE("-multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER);
+    MULTIRELEASE("--multi-release -multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER),
+
+    INHERIT_RUNTIME_ENVIRONMENT("--inherit-runtime-environment", "opt.inherit_runtime_environment",
+            EXTENDED, BASIC) {
+        @Override
+        public boolean process(OptionHelper helper, String option) {
+            try {
+                Class.forName(JDK9Wrappers.VMHelper.VM_CLASSNAME);
+                String[] runtimeArgs = JDK9Wrappers.VMHelper.getRuntimeArguments();
+                for (String arg : runtimeArgs) {
+                    // Handle any supported runtime options; ignore all others.
+                    // The runtime arguments always use the single token form, e.g. "--name=value".
+                    for (Option o : getSupportedRuntimeOptions()) {
+                        if (o.matches(arg)) {
+                            o.handleOption(helper, arg, Collections.emptyIterator());
+                            break;
+                        }
+                    }
+                }
+            } catch (ClassNotFoundException | SecurityException e) {
+                helper.error("err.cannot.access.runtime.env");
+            }
+            return false;
+        }
 
-    /** The kind of an Option. This is used by the -help and -X options. */
+        private Option[] getSupportedRuntimeOptions() {
+            Option[] supportedRuntimeOptions = {
+                ADD_EXPORTS,
+                ADD_MODULES,
+                LIMIT_MODULES,
+                MODULE_PATH,
+                UPGRADE_MODULE_PATH,
+                PATCH_MODULE
+            };
+            return supportedRuntimeOptions;
+        }
+    };
+
+    /**
+     * The kind of argument, if any, accepted by this option. The kind is augmented
+     * by characters in the name of the option.
+     */
+    public enum ArgKind {
+        /** This option does not take any argument. */
+        NONE,
+
+// Not currently supported
+//        /**
+//         * This option takes an optional argument, which may be provided directly after an '='
+//         * separator, or in the following argument position if that word does not itself appear
+//         * to be the name of an option.
+//         */
+//        OPTIONAL,
+
+        /**
+         * This option takes an argument.
+         * If the name of option ends with ':' or '=', the argument must be provided directly
+         * after that separator.
+         * Otherwise, if may appear after an '=' or in the following argument position.
+         */
+        REQUIRED,
+
+        /**
+         * This option takes an argument immediately after the option name, with no separator
+         * character.
+         */
+        ADJACENT
+    }
+
+    /**
+     * The kind of an Option. This is used by the -help and -X options.
+     */
     public enum OptionKind {
         /** A standard option, documented by -help. */
         STANDARD,
@@ -641,8 +726,10 @@
         HIDDEN,
     }
 
-    /** The group for an Option. This determines the situations in which the
-     *  option is applicable. */
+    /**
+     * 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. */
@@ -656,7 +743,9 @@
         OPERAND
     }
 
-    /** The kind of choice for "choice" options. */
+    /**
+     * The kind of choice for "choice" options.
+     */
     enum ChoiceKind {
         /** The expected value is exactly one of the set of choices. */
         ONEOF,
@@ -684,65 +773,113 @@
         }
     }
 
-    public final String text;
-
-    final OptionKind kind;
+    /**
+     * The "primary name" for this option.
+     * This is the name that is used to put values in the {@link Options} table.
+     */
+    public final String primaryName;
 
-    final OptionGroup group;
+    /**
+     * The set of names (primary name and aliases) for this option.
+     * Note that some names may end in a separator, to indicate that an argument must immediately
+     * follow the separator (and cannot appear in the following argument position.
+     */
+    public final String[] names;
 
-    /** Documentation key for arguments.
-     */
-    final String argsNameKey;
+    /** Documentation key for arguments. */
+    protected final String argsNameKey;
 
     /** Documentation key for description.
      */
-    final String descrKey;
+    protected final String descrKey;
+
+    /** The kind of this option. */
+    private final OptionKind kind;
+
+    /** The group for this option. */
+    private final OptionGroup group;
+
+    /** The kind of argument for this option. */
+    private final ArgKind argKind;
 
-    /** Suffix option (-foo=bar or -foo:bar)
+    /** The kind of choices for this option, if any. */
+    private final ChoiceKind choiceKind;
+
+    /** The choices for this option, if any, and whether or not the choices are hidden. */
+    private final Map<String,Boolean> choices;
+
+    /**
+     * Looks up the first option matching the given argument in the full set of options.
+     * @param arg the argument to be matches
+     * @return the first option that matches, or null if none.
      */
-    final boolean hasSuffix;
+    public static Option lookup(String arg) {
+        return lookup(arg, EnumSet.allOf(Option.class));
+    }
 
-    /** The kind of choices for this option, if any.
+    /**
+     * Looks up the first option matching the given argument within a set of options.
+     * @param arg the argument to be matches
+     * @return the first option that matches, or null if none.
      */
-    final ChoiceKind choiceKind;
+    public static Option lookup(String arg, Set<Option> options) {
+        for (Option option: options) {
+            if (option.matches(arg))
+                return option;
+        }
+        return null;
+    }
 
-    /** The choices for this option, if any, and whether or not the choices
-     *  are hidden
+    /**
+     * Writes the "command line help" for given kind of option to the log.
+     * @param log the log
+     * @param kind  the kind of options to select
      */
-    final Map<String,Boolean> choices;
+    private static void showHelp(Log log, OptionKind kind) {
+        Comparator<Option> comp = new Comparator<Option>() {
+            final Collator collator = Collator.getInstance(Locale.US);
+            { collator.setStrength(Collator.PRIMARY); }
 
+            @Override
+            public int compare(Option o1, Option o2) {
+                return collator.compare(o1.primaryName, o2.primaryName);
+            }
+        };
+
+        getJavaCompilerOptions()
+                .stream()
+                .filter(o -> o.kind == kind)
+                .sorted(comp)
+                .forEach(o -> {
+                    o.help(log);
+                });
+    }
 
     Option(String text, String descrKey,
             OptionKind kind, OptionGroup group) {
-        this(text, null, descrKey, kind, group, null, null, false);
-    }
-
-    Option(String text, String descrKey,
-            OptionKind kind, OptionGroup group,
-            boolean doHasSuffix) {
-        this(text, null, descrKey, kind, group, null, null, doHasSuffix);
+        this(text, null, descrKey, kind, group, null, null, ArgKind.NONE);
     }
 
     Option(String text, String argsNameKey, String descrKey,
             OptionKind kind, OptionGroup group) {
-        this(text, argsNameKey, descrKey, kind, group, null, null, false);
+        this(text, argsNameKey, descrKey, kind, group, null, null, ArgKind.REQUIRED);
     }
 
     Option(String text, String argsNameKey, String descrKey,
-            OptionKind kind, OptionGroup group, boolean doHasSuffix) {
-        this(text, argsNameKey, descrKey, kind, group, null, null, doHasSuffix);
+            OptionKind kind, OptionGroup group, ArgKind ak) {
+        this(text, argsNameKey, descrKey, kind, group, null, null, ak);
     }
 
-    Option(String text, OptionKind kind, OptionGroup group,
+    Option(String text, String argsNameKey, String descrKey, OptionKind kind, OptionGroup group,
             ChoiceKind choiceKind, Map<String,Boolean> choices) {
-        this(text, null, null, kind, group, choiceKind, choices, false);
+        this(text, argsNameKey, descrKey, kind, group, choiceKind, choices, ArgKind.REQUIRED);
     }
 
     Option(String text, String descrKey,
             OptionKind kind, OptionGroup group,
             ChoiceKind choiceKind, String... choices) {
         this(text, null, descrKey, kind, group, choiceKind,
-                createChoices(choices), false);
+                createChoices(choices), ArgKind.REQUIRED);
     }
     // where
         private static Map<String,Boolean> createChoices(String... choices) {
@@ -755,39 +892,60 @@
     private Option(String text, String argsNameKey, String descrKey,
             OptionKind kind, OptionGroup group,
             ChoiceKind choiceKind, Map<String,Boolean> choices,
-            boolean doHasSuffix) {
-        this.text = text;
+            ArgKind argKind) {
+        this.names = text.trim().split("\\s+");
+        Assert.check(names.length >= 1);
+        this.primaryName = names[0];
         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);
-        this.hasSuffix = doHasSuffix || lastChar == ':' || lastChar == '=';
+        this.argKind = argKind;
     }
 
-    public String getText() {
-        return text;
+    public String getPrimaryName() {
+        return primaryName;
     }
 
     public OptionKind getKind() {
         return kind;
     }
 
+    public ArgKind getArgKind() {
+        return argKind;
+    }
+
     public boolean hasArg() {
-        return argsNameKey != null && !hasSuffix;
+        return (argKind != ArgKind.NONE);
     }
 
     public boolean matches(String option) {
+        for (String name: names) {
+            if (matches(option, name))
+                return true;
+        }
+        return false;
+    }
+
+    private boolean matches(String option, String name) {
+        if (name.startsWith("--")) {
+            return option.equals(name)
+                    || hasArg() && option.startsWith(name + "=");
+        }
+
+        boolean hasSuffix = (argKind == ArgKind.ADJACENT)
+                || name.endsWith(":") || name.endsWith("=");
+
         if (!hasSuffix)
-            return option.equals(text);
+            return option.equals(name);
 
-        if (!option.startsWith(text))
+        if (!option.startsWith(name))
             return false;
 
         if (choices != null) {
-            String arg = option.substring(text.length());
+            String arg = option.substring(name.length());
             if (choiceKind == ChoiceKind.ONEOF)
                 return choices.keySet().contains(arg);
             else {
@@ -801,55 +959,161 @@
         return true;
     }
 
+    /**
+     * Handles an option.
+     * If an argument for the option is required, depending on spec of the option, it will be found
+     * as part of the current arg (following ':' or '=') or in the following argument.
+     * This is the recommended way to handle an option directly, instead of calling the underlying
+     * {@link #process process} methods.
+     * @param helper a helper to provide access to the environment
+     * @param arg the arg string that identified this option
+     * @param rest the remaining strings to be analysed
+     * @return true if the operation was successful, and false otherwise
+     * @implNote The return value is the opposite of that used by {@link #process}.
+     */
+    public boolean handleOption(OptionHelper helper, String arg, Iterator<String> rest) {
+        if (hasArg()) {
+            String operand;
+            int sep = findSeparator(arg);
+            if (getArgKind() == Option.ArgKind.ADJACENT) {
+                operand = arg.substring(primaryName.length());
+            } else if (sep > 0) {
+                operand = arg.substring(sep + 1);
+            } else {
+                if (!rest.hasNext()) {
+                    helper.error("err.req.arg", arg);
+                    return false;
+                }
+                operand = rest.next();
+            }
+            return !process(helper, arg, operand);
+        } else {
+            return !process(helper, arg);
+        }
+    }
+
+    /**
+     * Processes an option that either does not need an argument,
+     * or which contains an argument within it, following a separator.
+     * @param helper a helper to provide access to the environment
+     * @param option the option to be processed
+     * @return true if an error occurred
+     */
+    public boolean process(OptionHelper helper, String option) {
+        if (argKind == ArgKind.NONE) {
+            return process(helper, primaryName, option);
+        } else {
+            int sep = findSeparator(option);
+            return process(helper, primaryName, option.substring(sep + 1));
+        }
+    }
+
+    /**
+     * Processes an option by updating the environment via a helper object.
+     * @param helper a helper to provide access to the environment
+     * @param option the option to be processed
+     * @param arg the value to associate with the option, or a default value
+     *  to be used if the option does not otherwise take an argument.
+     * @return true if an error occurred
+     */
     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.remove(primaryName + s);
+                String opt = primaryName + arg;
                 helper.put(opt, opt);
                 // some clients like to see option (without trailing ":")
                 // set to arg
-                String nm = option.substring(0, option.length() - 1);
+                String nm = primaryName.substring(0, primaryName.length() - 1);
                 helper.put(nm, arg);
             } else {
                 // set option+word for each word in arg
                 for (String a: arg.split(",+")) {
-                    String opt = option + a;
+                    String opt = primaryName + a;
                     helper.put(opt, opt);
                 }
             }
         }
-        helper.put(option, arg);
+        helper.put(primaryName, arg);
         if (group == OptionGroup.FILEMANAGER)
             helper.handleFileManagerOption(this, 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);
+    /**
+     * Scans a word to find the first separator character, either colon or equals.
+     * @param word the word to be scanned
+     * @return the position of the first':' or '=' character in the word,
+     *  or -1 if none found
+     */
+    private static int findSeparator(String word) {
+        for (int i = 0; i < word.length(); i++) {
+            switch (word.charAt(i)) {
+                case ':': case '=':
+                    return i;
+            }
+        }
+        return -1;
+    }
+
+    /** The indent for the option synopsis. */
+    private static final String SMALL_INDENT = "  ";
+    /** The automatic indent for the description. */
+    private static final String LARGE_INDENT = "        ";
+    /** The space allowed for the synopsis, if the description is to be shown on the same line. */
+    private static final int DEFAULT_SYNOPSIS_WIDTH = 28;
+    /** The nominal maximum line length, when seeing if text will fit on a line. */
+    private static final int DEFAULT_MAX_LINE_LENGTH = 80;
+    /** The format for a single-line help entry. */
+    private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s";
+
+    /**
+     * Writes help text for this option to the log.
+     * @param log the log
+     */
+    protected void help(Log log) {
+        help(log, log.localize(PrefixKind.JAVAC, descrKey));
     }
 
-    private static final String HELP_LINE_FORMAT = "  %-26s %s";
-
-    void help(Log log, OptionKind kind) {
-        if (this.kind != kind)
-            return;
+    protected void help(Log log, String descr) {
+        String synopses = Arrays.stream(names)
+                .map(s -> helpSynopsis(s, log))
+                .collect(Collectors.joining(", "));
 
-        log.printRawLines(WriterKind.STDOUT,
-                String.format(HELP_LINE_FORMAT,
-                    helpSynopsis(log),
-                    log.localize(PrefixKind.JAVAC, descrKey)));
+        // If option synopses and description fit on a single line of reasonable length,
+        // display using COMPACT_FORMAT
+        if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH
+                && !descr.contains("\n")
+                && (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + descr.length() <= DEFAULT_MAX_LINE_LENGTH)) {
+            log.printRawLines(WriterKind.STDOUT, String.format(COMPACT_FORMAT, synopses, descr));
+            return;
+        }
 
+        // If option synopses fit on a single line of reasonable length, show that;
+        // otherwise, show 1 per line
+        if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) {
+            log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + synopses);
+        } else {
+            for (String name: names) {
+                log.printRawLines(WriterKind.STDOUT, SMALL_INDENT + helpSynopsis(name, log));
+            }
+        }
+
+        // Finally, show the description
+        log.printRawLines(WriterKind.STDOUT, LARGE_INDENT + descr.replace("\n", "\n" + LARGE_INDENT));
     }
 
-    private String helpSynopsis(Log log) {
+    /**
+     * Composes the initial synopsis of one of the forms for this option.
+     * @param name the name of this form of the option
+     * @param log the log used to localize the description of the arguments
+     * @return  the synopsis
+     */
+    private String helpSynopsis(String name, Log log) {
         StringBuilder sb = new StringBuilder();
-        sb.append(text);
+        sb.append(name);
         if (argsNameKey == null) {
             if (choices != null) {
                 String sep = "{";
@@ -863,10 +1127,9 @@
                 sb.append("}");
             }
         } else {
-            if (!hasSuffix)
+            if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT)
                 sb.append(" ");
             sb.append(log.localize(PrefixKind.JAVAC, argsNameKey));
-
         }
 
         return sb.toString();
@@ -915,24 +1178,35 @@
         return choices;
     }
 
+    /**
+     * Returns the set of options supported by the command line tool.
+     * @return the set of options.
+     */
     static Set<Option> getJavaCompilerOptions() {
         return EnumSet.allOf(Option.class);
     }
 
+    /**
+     * Returns the set of options supported by the built-in file manager.
+     * @return the set of options.
+     */
     public static Set<Option> getJavacFileManagerOptions() {
-        return getOptions(EnumSet.of(FILEMANAGER));
+        return getOptions(FILEMANAGER);
     }
 
+    /**
+     * Returns the set of options supported by this implementation of
+     * the JavaCompiler API, via {@link JavaCompiler#getTask}.
+     * @return the set of options.
+     */
     public static Set<Option> getJavacToolOptions() {
-        return getOptions(EnumSet.of(BASIC));
+        return getOptions(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);
+    private static Set<Option> getOptions(OptionGroup group) {
+        return Arrays.stream(Option.values())
+                .filter(o -> o.group == group)
+                .collect(Collectors.toCollection(() -> EnumSet.noneOf(Option.class)));
     }
 
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/OptionHelper.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/OptionHelper.java	Fri Aug 19 12:17:32 2016 -0700
@@ -27,6 +27,7 @@
 
 import java.nio.file.Path;
 
+import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Log.PrefixKind;
 
@@ -63,6 +64,9 @@
     /** Report an error. */
     abstract void error(String key, Object... args);
 
+    /** Report an error. */
+    abstract void error(JCDiagnostic.Error error);
+
     /** Record a file to be compiled. */
     abstract void addFile(Path p);
 
@@ -113,6 +117,11 @@
         }
 
         @Override
+        void error(JCDiagnostic.Error error) {
+            throw new IllegalArgumentException(log.localize(error));
+        }
+
+        @Override
         public void addFile(Path p) {
             throw new IllegalArgumentException(p.toString());
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Aug 19 12:17:32 2016 -0700
@@ -62,6 +62,7 @@
 import com.sun.tools.javac.comp.Modules;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.model.JavacTypes;
 import com.sun.tools.javac.platform.PlatformDescription;
@@ -89,7 +90,6 @@
 
 import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
-import static com.sun.tools.javac.main.Option.*;
 import static com.sun.tools.javac.comp.CompileStates.CompileState;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
 
@@ -196,17 +196,17 @@
         source = Source.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         options = Options.instance(context);
-        printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
-        printRounds = options.isSet(XPRINTROUNDS);
-        verbose = options.isSet(VERBOSE);
+        printProcessorInfo = options.isSet(Option.XPRINTPROCESSORINFO);
+        printRounds = options.isSet(Option.XPRINTROUNDS);
+        verbose = options.isSet(Option.VERBOSE);
         lint = Lint.instance(context).isEnabled(PROCESSING);
         compiler = JavaCompiler.instance(context);
-        if (options.isSet(PROC, "only") || options.isSet(XPRINT)) {
+        if (options.isSet(Option.PROC, "only") || options.isSet(Option.XPRINT)) {
             compiler.shouldStopPolicyIfNoError = CompileState.PROCESS;
         }
         fatalErrors = options.isSet("fatalEnterError");
         showResolveErrors = options.isSet("showResolveErrors");
-        werror = options.isSet(WERROR);
+        werror = options.isSet(Option.WERROR);
         fileManager = context.get(JavaFileManager.class);
         platformAnnotations = initPlatformAnnotations();
 
@@ -279,7 +279,7 @@
     private void initProcessorIterator(Iterable<? extends Processor> processors) {
         Iterator<? extends Processor> processorIterator;
 
-        if (options.isSet(XPRINT)) {
+        if (options.isSet(Option.XPRINT)) {
             try {
                 processorIterator = List.of(new PrintingProcessor()).iterator();
             } catch (Throwable t) {
@@ -297,7 +297,7 @@
                  * path for the named class.  Otherwise, use a service
                  * provider mechanism to create the processor iterator.
                  */
-                String processorNames = options.get(PROCESSOR);
+                String processorNames = options.get(Option.PROCESSOR);
                 if (fileManager.hasLocation(ANNOTATION_PROCESSOR_MODULE_PATH)) {
                     processorIterator = (processorNames == null) ?
                             new ServiceIterator(serviceLoader, log) :
@@ -363,7 +363,7 @@
                 ? standardFileManager.getLocationAsPaths(ANNOTATION_PROCESSOR_PATH)
                 : standardFileManager.getLocationAsPaths(CLASS_PATH);
 
-            if (needClassLoader(options.get(PROCESSOR), workingPath) )
+            if (needClassLoader(options.get(Option.PROCESSOR), workingPath) )
                 handleException(key, e);
 
         } else {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -1222,7 +1222,7 @@
 
 # 0: string
 compiler.err.locn.invalid.arg.for.xpatch=\
-    invalid argument for -Xpatch option: {0}
+    invalid argument for --patch-module option: {0}
 
 #####
 
@@ -1654,6 +1654,10 @@
 compiler.warn.missing.deprecated.annotation=\
     deprecated item is not annotated with @Deprecated
 
+# 0: symbol kind
+compiler.warn.deprecated.annotation.has.no.effect=\
+    @Deprecated annotation has no effect on this {0} declaration
+
 compiler.warn.invalid.archive.file=\
     Unexpected file on path: {0}
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -1,3 +1,28 @@
+#
+# Copyright (c) 2016, 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.
+#
+
 apple.laf.*: hidden
 apple.security.*: hidden
 com.apple.eawt.*: hidden
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -165,12 +165,12 @@
 javac.opt.Xlint.none=\
     Disable all warnings
 #L10N: do not localize: -Xlint
-javac.opt.Xlint.subopts=\
-    -Xlint:key,...
-javac.opt.Xlint.suboptlist=\n\
-\        Warnings to enable or disable, separated by comma.\n\
-\        Precede a key by '-' to disable the specified warning.\n\
-\        Supported keys are:
+javac.opt.arg.Xlint=\
+    <key>(,<key>)*
+javac.opt.Xlint.custom=\
+    Warnings to enable or disable, separated by comma.\n\
+    Precede a key by '-' to disable the specified warning.\n\
+    Supported keys are:
 javac.opt.Xlint.desc.auxiliaryclass=\
     Warn about an auxiliary class that is hidden in a source file, and is used from other files.
 
@@ -239,20 +239,19 @@
 
 # L10N: do not localize: accessibility html missing reference syntax
 # L10N: do not localize: public protected package private
-javac.opt.Xdoclint.custom=\n\
-\        Enable or disable specific checks for problems in javadoc comments,\n\
-\        where <group> is one of accessibility, html, missing, reference, or syntax,\n\
-\        and <access> is one of public, protected, package, or private.
+javac.opt.Xdoclint.custom=\
+    Enable or disable specific checks for problems in javadoc comments,\n\
+    where <group> is one of accessibility, html, missing, reference, or syntax,\n\
+    and <access> is one of public, protected, package, or private.
 
 javac.opt.Xdoclint.package.args = \
-    ([-]<packages>)
+    [-]<packages>(,[-]<package>)*
 
-javac.opt.Xdoclint.package.desc=\n\
-\        Enable or disable checks in specific packages. <packages> is a comma separated\n\
-\        list of package specifiers. Package specifier is either a qualified name of a package\n\
-\        or a package name prefix followed by '.*', which expands to all sub-packages of\n\
-\        the given package. Prefix the package specifier with '-' to disable checks for\n\
-\        the specified packages.
+javac.opt.Xdoclint.package.desc=\
+    Enable or disable checks in specific packages. Each <package> is either the\n\
+    qualified name of a package or a package name prefix followed by '.*', which\n\
+    expands to all sub-packages of the given package. Each <package> can be prefixed\n\
+    with '-' to disable checks for the specified package or packages.
 
 javac.opt.Xstdout=\
     Redirect standard output
@@ -274,34 +273,36 @@
     Read options and filenames from file
 javac.opt.diags=\
     Select a diagnostic mode
-javac.opt.addExports=\n\
-\        Specify a package to be considered as exported from its defining module\n\
-\        to additional modules, or to all unnamed modules if <other-module> is ALL-UNNAMED.
+javac.opt.addExports=\
+    Specify a package to be considered as exported from its defining module\n\
+    to additional modules, or to all unnamed modules if <other-module> is ALL-UNNAMED.
 javac.opt.arg.addExports=\
     <module>/<package>=<other-module>(,<other-module>)*
-javac.opt.addReads=\n\
-\        Specify additional modules to be considered as required by a given module.\n\
-\        <other-module> may be ALL-UNNAMED to require the unnamed module.
+javac.opt.addReads=\
+    Specify additional modules to be considered as required by a given module.\n\
+    <other-module> may be ALL-UNNAMED to require the unnamed module.
 javac.opt.arg.addReads=\
     <module>=<other-module>(,<other-module>)*
-javac.opt.patch=\n\
-\        Override or augment a module with classes and resources\n\
-\        in JAR files or directories
+javac.opt.patch=\
+    Override or augment a module with classes and resources\n\
+    in JAR files or directories
 javac.opt.arg.patch=\
     <module>=<file>(:<file>)*
 javac.opt.module=\
     Specify a module to which the classes being compiled belong.
 javac.opt.arg.module=\
-    <module-name>
-javac.opt.addmods=\n\
-\        Root modules to resolve in addition to the initial modules, or all modules\n\
-\        on the module path if <module> is ALL-MODULE-PATH.
+    <module>
+javac.opt.addmods=\
+    Root modules to resolve in addition to the initial modules, or all modules\n\
+    on the module path if <module> is ALL-MODULE-PATH.
 javac.opt.arg.addmods=\
     <module>(,<module>)*
 javac.opt.limitmods=\
     Limit the universe of observable modules
 javac.opt.arg.limitmods=\
     <module>(,<module>)*
+javac.opt.inherit_runtime_environment=\
+    Inherit module system configuration options from the runtime environment.
 
 ## errors
 
@@ -334,7 +335,7 @@
 javac.err.error.writing.file=\
     error writing {0}; {1}
 javac.err.sourcepath.modulesourcepath.conflict=\
-    cannot specify both -sourcepath and -modulesourcepath
+    cannot specify both --source-path and --module-source-path
 javac.warn.source.target.conflict=\
     source release {0} requires target release {1}
 javac.warn.target.default.source.conflict=\
@@ -347,6 +348,8 @@
     not a directory: {0}
 javac.err.file.not.file=\
     not a file: {0}
+javac.err.cannot.access.runtime.env=\
+    cannot access runtime environment
 
 ## messages
 
@@ -356,7 +359,7 @@
 
 javac.msg.usage=\
     Usage: {0} <options> <source files>\n\
-    use -help for a list of possible options
+    use --help for a list of possible options
 
 javac.msg.usage.nonstandard.footer=\
 These options are non-standard and subject to change without notice.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java	Fri Aug 19 12:17:32 2016 -0700
@@ -252,4 +252,40 @@
             }
         }
     }
+
+
+    /**
+     * Helper class for new method in jdk.internal.misc.VM.
+     */
+    public static final class VMHelper {
+        public static final String VM_CLASSNAME = "jdk.internal.misc.VM";
+
+        @SuppressWarnings("unchecked")
+        public static String[] getRuntimeArguments() {
+            try {
+                init();
+                Object result = getRuntimeArgumentsMethod.invoke(null);
+                return (String[])result;
+            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | SecurityException ex) {
+                throw new Abort(ex);
+            }
+        }
+
+        // -----------------------------------------------------------------------------------------
+
+        private static Class<?> vmClass = null;
+        private static Method getRuntimeArgumentsMethod = null;
+
+        private static void init() {
+            if (vmClass == null) {
+                try {
+                    vmClass = Class.forName(VM_CLASSNAME, false, null);
+                    getRuntimeArgumentsMethod = vmClass.getDeclaredMethod("getRuntimeArguments");
+                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException ex) {
+                    throw new Abort(ex);
+                }
+            }
+        }
+    }
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java	Fri Aug 19 12:17:32 2016 -0700
@@ -748,6 +748,14 @@
         return localize(PrefixKind.COMPILER_MISC, key, args);
     }
 
+    public String localize(JCDiagnostic.DiagnosticInfo diagInfo) {
+        if (useRawMessages) {
+            return diagInfo.key();
+        } else {
+            return messages.getLocalizedString(diagInfo.key(), diagInfo.args);
+        }
+    }
+
     /** Find a localized string in the resource bundle.
      *  @param key    The key for the localized string.
      *  @param args   Fields to substitute into the string.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/Options.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, 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 @@
      * Get the value for an option.
      */
     public String get(Option option) {
-        return values.get(option.text);
+        return values.get(option.primaryName);
     }
 
     /**
@@ -101,14 +101,14 @@
      * Check if the value for an option has been set.
      */
     public boolean isSet(Option option) {
-        return (values.get(option.text) != null);
+        return (values.get(option.primaryName) != null);
     }
 
     /**
      * Check if the value for a choice option has been set to a specific value.
      */
     public boolean isSet(Option option, String value) {
-        return (values.get(option.text + value) != null);
+        return (values.get(option.primaryName + value) != null);
     }
 
     /**
@@ -122,14 +122,14 @@
      * Check if the value for an option has not been set.
      */
     public boolean isUnset(Option option) {
-        return (values.get(option.text) == null);
+        return (values.get(option.primaryName) == null);
     }
 
     /**
      * Check if the value for a choice option has not been set to a specific value.
      */
     public boolean isUnset(Option option, String value) {
-        return (values.get(option.text + value) == null);
+        return (values.get(option.primaryName + value) == null);
     }
 
     public void put(String name, String value) {
@@ -137,7 +137,7 @@
     }
 
     public void put(Option option, String value) {
-        values.put(option.text, value);
+        values.put(option.primaryName, value);
     }
 
     public void putAll(Options options) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java	Fri Aug 19 12:17:32 2016 -0700
@@ -526,19 +526,27 @@
 
     private void showHelp() {
         log.println(getMessage("main.usage", progname));
+
         for (Option o: recognizedOptions) {
             if (o.isHidden())
                 continue;
             String name = o.aliases[0].substring(1); // there must always be at least one name
             log.println(getMessage("main.opt." + name));
         }
-        String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" };
+
+        String[] fmOptions = {
+            "--module-path", "--system",
+            "--class-path", "-classpath", "-cp",
+            "-bootclasspath"
+        };
+
         for (String o: fmOptions) {
             if (fileManager.isSupportedOption(o) == -1)
                 continue;
-            String name = o.substring(1);
+            String name = o.replaceAll("^-+", "").replaceAll("-+", "_");
             log.println(getMessage("main.opt." + name));
         }
+
         log.println(getMessage("main.usage.foot"));
     }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/Util.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/Util.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, 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
@@ -91,7 +91,6 @@
         log.println(s);
     }
 
-
     /*
      * Help for loading localized messages.
      */
@@ -117,18 +116,6 @@
     }
 
     /*
-     * Usage message.
-     */
-    public void usage() throws Exit {
-        log.println(getText("usage"));
-    }
-
-    public void version() throws Exit {
-        log.println(getText("javah.version",
-                                   System.getProperty("java.version"), null));
-    }
-
-    /*
      * Failure modes.
      */
     public void bug(String key) throws Exit {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/resources/l10n.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -69,58 +69,61 @@
         Warning: Tracing is no longer supported.  Instead, use\
         -verbose:jni option of the virtual machine.
 
-#
-# Usage message.
-#
-usage=\
-Usage: javah [options] <classes>\n\
-\n\
-where [options] include:\n\
-\n\t\
--help                 Print this help message and exit\n\t\
--classpath <path>     Path from which to load classes\n\t\
--cp <path>            Path from which to load classes\n\t\
--modulepath <path>    Path from which to load application modules\n\t\
--system <path>        JDK directory from which to load system modules\n\t\
--d <dir>              Output directory\n\t\
--o <file>             Output file (only one of -d or -o may be used)\n\t\
--jni                  Generate JNI-style header file (default)\n\t\
--version              Print version information\n\t\
--verbose              Enable verbose output\n\t\
--force                Always write output files\n\
-\n\
-<classes> are specified with their fully qualified names, optionally\n\
-prefixed by a module name followed by '/'. Examples:\n\
-    java.lang.Object\n\
-    java.base/java.io.File\n\
-
 main.usage=\
 Usage: \n\
 \  javah [options] <classes>\n\
 where [options] include:
+
 main.opt.o=\
-\  -o <file>                Output file (only one of -d or -o may be used)
+\  -o <file>                    Output file (only one of -d or -o may be used)
+
 main.opt.d=\
-\  -d <dir>                 Output directory
+\  -d <dir>                     Output directory
+
 main.opt.v=\
-\  -v  -verbose             Enable verbose output
+\  -v  -verbose                 Enable verbose output
+
 main.opt.h=\
-\  -h  --help  -?           Print this message
+\  -h  --help  -?               Print this message
+
 main.opt.version=\
-\  -version                 Print version information
+\  -version                     Print version information
+
 main.opt.jni=\
-\  -jni                     Generate JNI-style header file (default)
+\  -jni                         Generate JNI-style header file (default)
+
 main.opt.force=\
-\  -force                   Always write output files
+\  -force                       Always write output files
+
+main.opt.module_path=\
+\  --module-path <path>         Path from which to load application modules
+
+main.opt.upgrade_module_path=\
+\  --upgrade_module-path <path> Path from which to load application modules
+
 main.opt.classpath=\
-\  -classpath <path>        Path from which to load classes
+\  -classpath <path>            Path from which to load classes
+
+main.opt.class_path=\
+\  --class-path <path>          Path from which to load classes
+
 main.opt.cp=\
-\  -cp <path>               Path from which to load classes
+\  -cp <path>                   Path from which to load classes
+
 main.opt.bootclasspath=\
-\  -bootclasspath <path>    Path from which to load bootstrap classes
-main.usage.foot=\
-<classes> are specified with their fully qualified names\n\
-(for example, java.lang.Object).
+\  -bootclasspath <path>        Path from which to load bootstrap classes
+
+main.opt.system=\
+\  --system <jdk>               Specify where to find system modules
+
+main.usage.foot=\n\
+GNU-style options may use '=' instead whitespace to separate the name of an option\n\
+from its value.\n\
+\n\
+Each class must be specified by its fully qualified names, optionally\n\
+prefixed by a module name followed by '/'. Examples:\n\
+\    java.lang.Object\n\
+\    java.base/java.io.File\n\
 
 #
 # Version string.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Option.java	Fri Aug 19 12:17:32 2016 -0700
@@ -63,7 +63,7 @@
                 helper.sourceRoots(paths);
         }
     },
-    SOURCEPATH("-sourcepath", "Specify search path for sources.") {
+    SOURCE_PATH("--source-path", "Specify search path for sources.") {
         @Override
         protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
             List<Path> paths = getFileListArg(iter, helper);
@@ -71,7 +71,13 @@
                 helper.sourcepath(paths);
         }
     },
-    MODULEPATH("-modulepath", "Specify search path for modules.") {
+    SOURCEPATH("-sourcepath", "An alias for -sourcepath") {
+        @Override
+        protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
+            SOURCE_PATH.processMatching(iter, helper);
+        }
+    },
+    MODULE_PATH("--module-path", "Specify search path for modules.") {
         @Override
         protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
             List<Path> paths = getFileListArg(iter, helper);
@@ -79,7 +85,19 @@
                 helper.modulepath(paths);
         }
     },
-    CLASSPATH("-classpath", "Specify search path for classes.") {
+    MODULEPATH("-modulepath", "An alias for -modulepath") {
+        @Override
+        protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
+            MODULE_PATH.processMatching(iter, helper);
+        }
+    },
+    P("-p", "An alias for -modulepath") {
+        @Override
+        protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
+            MODULE_PATH.processMatching(iter, helper);
+        }
+    },
+    CLASS_PATH("--class-path", "Specify search path for classes.") {
         @Override
         protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
             List<Path> paths = getFileListArg(iter, helper);
@@ -87,10 +105,16 @@
                 helper.classpath(paths);
         }
     },
+    CLASSPATH("-classpath", "An alias for -classpath.") {
+        @Override
+        protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
+            CLASS_PATH.processMatching(iter, helper);
+        }
+    },
     CP("-cp", "An alias for -classpath") {
         @Override
         protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
-            CLASSPATH.processMatching(iter, helper);
+            CLASS_PATH.processMatching(iter, helper);
         }
     },
     X("-x", "Exclude files matching the given pattern") {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/options/Options.java	Fri Aug 19 12:17:32 2016 -0700
@@ -251,9 +251,9 @@
 
         // Source roots
         args.addSourceLocations(Option.SRC, sources);
-        args.addSourceLocations(Option.SOURCEPATH, sourceSearchPaths);
-        args.addSourceLocations(Option.CLASSPATH,  classSearchPaths);
-        args.addSourceLocations(Option.MODULEPATH, moduleSearchPaths);
+        args.addSourceLocations(Option.SOURCE_PATH, sourceSearchPaths);
+        args.addSourceLocations(Option.CLASS_PATH,  classSearchPaths);
+        args.addSourceLocations(Option.MODULE_PATH, moduleSearchPaths);
 
         // Boolean options
         if (permitSourcesInDefaultPackage)
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/javadoc/package-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/javadoc/package-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -150,5 +150,4 @@
 @see com.sun.javadoc.Doclet
 @see com.sun.javadoc.RootDoc
 */
-@Deprecated
 package com.sun.javadoc;
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocTool.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/JavadocTool.java	Fri Aug 19 12:17:32 2016 -0700
@@ -187,7 +187,7 @@
             // Parse file objects provide via the DocumentationTool API
             parse(fileObjects, classTrees, true);
 
-            modules.initModules(classTrees.toList(), Collections.emptySet(), Collections.emptySet());
+            modules.initModules(classTrees.toList());
 
             // Build up the complete list of any packages to be documented
             Location location = modules.multiModuleMode ? StandardLocation.MODULE_SOURCE_PATH
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Start.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/Start.java	Fri Aug 19 12:17:32 2016 -0700
@@ -45,6 +45,8 @@
 import com.sun.tools.javac.main.CommandLine;
 import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.file.BaseFileManager;
+import com.sun.tools.javac.main.OptionHelper;
+import com.sun.tools.javac.main.OptionHelper.GrumpyHelper;
 import com.sun.tools.javac.platform.PlatformDescription;
 import com.sun.tools.javac.platform.PlatformUtils;
 import com.sun.tools.javac.util.ClientCodeException;
@@ -173,7 +175,7 @@
     }
 
     void usage(boolean exit) {
-        usage("main.usage", "-help", null, exit);
+        usage("main.usage", "-help", "main.usage.foot", exit);
     }
 
     @Override
@@ -365,14 +367,14 @@
             ((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
         }
 
-        String platformString = compOpts.get("-release");
+        String platformString = compOpts.get("--release");
 
         if (platformString != null) {
             if (compOpts.isSet("-source")) {
                 usageError("main.release.bootclasspath.conflict", "-source");
             }
-            if (fileManagerOpts.containsKey(Option.BOOTCLASSPATH)) {
-                usageError("main.release.bootclasspath.conflict", Option.BOOTCLASSPATH.getText());
+            if (fileManagerOpts.containsKey(Option.BOOT_CLASS_PATH)) {
+                usageError("main.release.bootclasspath.conflict", Option.BOOT_CLASS_PATH.getPrimaryName());
             }
 
             PlatformDescription platformDescription =
@@ -555,4 +557,19 @@
         }
         options.append(args);
     }
+
+    @Override
+    OptionHelper getOptionHelper() {
+        return new GrumpyHelper(null) {
+            @Override
+            public String get(com.sun.tools.javac.main.Option option) {
+                return compOpts.get(option);
+            }
+
+            @Override
+            public void put(String name, String value) {
+                compOpts.put(name, value);
+            }
+        };
+    }
 }
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,6 +31,7 @@
 
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.OptionHelper;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Options;
 
@@ -50,21 +51,28 @@
     BOOTCLASSPATH("-bootclasspath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
+            helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
     CLASSPATH("-classpath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CLASSPATH, arg);
+            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
         }
     },
 
     CP("-cp", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CP, arg);
+            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
+        }
+    },
+
+    CLASS_PATH("--class-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
         }
     },
 
@@ -78,28 +86,49 @@
     SOURCEPATH("-sourcepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.SOURCEPATH, arg);
+            helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
+        }
+    },
+
+    SOURCE_PATH("--source-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
         }
     },
 
     SYSCLASSPATH("-sysclasspath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
+            helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
     MODULESOURCEPATH("-modulesourcepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.MODULESOURCEPATH, arg);
+            helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
+        }
+    },
+
+    MODULE_SOURCE_PATH("--module-source-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
         }
     },
 
     UPGRADEMODULEPATH("-upgrademodulepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.UPGRADEMODULEPATH, arg);
+            helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
+        }
+    },
+
+    UPGRADE_MODULE_PATH("--upgrade-module-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
         }
     },
 
@@ -110,10 +139,31 @@
         }
     },
 
+    SYSTEM_("--system", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.SYSTEM, arg);
+        }
+    },
+
     MODULEPATH("-modulepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.MODULEPATH, arg);
+            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
+        }
+    },
+
+    MODULE_PATH("--module-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
+        }
+    },
+
+    P("-p", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
         }
     },
 
@@ -124,6 +174,13 @@
         }
     },
 
+    ADD_MODULES("--add-modules", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
     LIMITMODS("-limitmods", true) {
         @Override
         public void process(Helper helper, String arg) {
@@ -131,6 +188,13 @@
         }
     },
 
+    LIMIT_MODULES("--limit-modules", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
     ENCODING("-encoding", true) {
         @Override
         public void process(Helper helper, String arg) {
@@ -139,13 +203,20 @@
         }
     },
 
-    RELEASE("-release", true) {
+    RELEASE("--release", true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setCompilerOpt(opt, arg);
         }
     },
 
+    RELEASE_OLD("-release", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setCompilerOpt("--release", arg);
+        }
+    },
+
     SOURCE("-source", true) {
         @Override
         public void process(Helper helper, String arg) {
@@ -167,6 +238,55 @@
         }
     },
 
+    XADDREADS("-XaddReads:", false) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_READS.process(helper.getOptionHelper(), arg);
+        }
+    },
+
+    ADD_READS("--add-reads", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_READS.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
+    ADDEXPORTS("-XaddExports:", false) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg);
+        }
+    },
+
+    ADD_EXPORTS("--add-exports", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
+    XMODULE("-Xmodule:", false) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.XMODULE.process(helper.getOptionHelper(), arg);
+        }
+    },
+
+    XPATCH("-Xpatch:", false) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.XMODULE.process(helper.getOptionHelper(), arg);
+        }
+    },
+
+    PATCH_MODULE("--patch-module", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
     // ----- doclet options -----
 
     DOCLET("-doclet", true), // handled in setDocletInvoker
@@ -362,6 +482,7 @@
         abstract void Xusage();
 
         abstract void usageError(String msg, Object... args);
+        abstract OptionHelper getOptionHelper();
 
         void addToList(ListBuffer<String> list, String str){
             StringTokenizer st = new StringTokenizer(str, ":");
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/package-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/package-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,5 +32,4 @@
  * {@code javax.tools.DocumentationTool}
  * for replacement functionality.
  */
-@Deprecated
 package com.sun.tools.javadoc;
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2016, 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
@@ -37,15 +37,28 @@
 \  -help                            Display command line options and exit\n\
 \  -doclet <class>                  Generate output via alternate doclet\n\
 \  -docletpath <path>               Specify where to find doclet class files\n\
-\  -sourcepath <pathlist>           Specify where to find source files\n\
-\  -classpath <pathlist>            Specify where to find user class files\n\
-\  -cp <pathlist>                   Specify where to find user class files\n\
+\  --module-source-path <path>      Specify where to find input source files for multiple modules\n\
+\  --upgrade-module-path <path>     Override location of upgradeable modules\n\
+\  --module-path <path>, -p <path>  Specify where to find application modules\n\
+\  --add-modules <module>(,<module>)*\n\
+\                                   Root modules to resolve in addition to the initial modules,\n\
+\                                   or all modules on the module path if <module> is ALL-MODULE-PATH.\n\
+\  --limit-modules <module>(,<module>)*\n\
+\                                   Limit the universe of observable modules\n\
+\  --source-path <path>             Specify where to find source files\n\
+\  -sourcepath <path>               Specify where to find source files\n\
+\  --class-path <path>              Specify where to find user class files\n\
+\  -classpath <path>                Specify where to find user class files\n\
+\  -cp <path>                       Specify where to find user class files\n\
 \  -exclude <pkglist>               Specify a list of packages to exclude\n\
 \  -subpackages <subpkglist>        Specify subpackages to recursively load\n\
 \  -breakiterator                   Compute first sentence with BreakIterator\n\
-\  -bootclasspath <pathlist>        Override location of class files loaded\n\
-\                                   by the bootstrap class loader\n\
+\  -bootclasspath <path>            Override location of platform class files\n\
+\                                   used for non-modular releases\n\
+\  --system <jdk>                   Override location of system modules used\n\
+\                                   for modular releases.\n\
 \  -source <release>                Provide source compatibility with specified release\n\
+\  --release <release>              Provide source compatibility with specified release\n\
 \  -extdirs <dirlist>               Override location of installed extensions\n\
 \  -verbose                         Output messages about what Javadoc is doing\n\
 \  -locale <name>                   Locale to be used, e.g. en_US or en_US_WIN\n\
@@ -54,9 +67,25 @@
 \  -J<flag>                         Pass <flag> directly to the runtime system\n\
 \  -X                               Print a synopsis of nonstandard options and exit\n
 
+main.usage.foot=\n\
+GNU-style options may use '=' instead whitespace to separate the name of an option\n\
+from its value.\n
+
 main.Xusage=\
 \  -Xmaxerrs <number>               Set the maximum number of errors to print\n\
-\  -Xmaxwarns <number>              Set the maximum number of warnings to print\n
+\  -Xmaxwarns <number>              Set the maximum number of warnings to print\n\
+\  --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
+\                                   Specify a package to be considered as exported from its \n\
+\                                   defining module to additional modules, or to all unnamed \n\
+\                                   modules if <other-module> is ALL-UNNAMED.\n\
+\  --add-reads <module>=<other-module>(,<other-module>)*\n\
+\                                   Specify additional modules to be considered as required by a\n\
+\                                   given module. <other-module> may be ALL-UNNAMED to require\n\
+\                                   the unnamed module.\n\
+\  -Xmodule:<module-name>           Specify a module to which the classes being compiled belong.\n\
+\  --patch-module <module>=<file>(:<file>)*\n\
+\                                   Override or augment a module with classes and resources\n\
+\                                   in JAR files or directories\n
 
 main.Xusage.foot=\
 These options are non-standard and subject to change without notice.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/doclets/StandardDoclet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -46,22 +46,27 @@
         htmlDoclet = new HtmlDoclet();
     }
 
+    @Override
     public void init(Locale locale, Reporter reporter) {
         htmlDoclet.init(locale, reporter);
     }
 
+    @Override
     public String getName() {
         return "Standard";
     }
 
+    @Override
     public Set<Doclet.Option> getSupportedOptions() {
         return htmlDoclet.getSupportedOptions();
     }
 
+    @Override
     public SourceVersion getSupportedSourceVersion() {
-        return htmlDoclet.sourceVersion();
+        return htmlDoclet.getSupportedSourceVersion();
     }
 
+    @Override
     public boolean run(DocletEnvironment docEnv) {
         return htmlDoclet.run(docEnv);
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -80,7 +80,7 @@
         Content typeParameters = getTypeParameters(member);
         if (!typeParameters.isEmpty()) {
             htmltree.addContent(typeParameters);
-            htmltree.addContent(writer.getSpace());
+            htmltree.addContent(Contents.SPACE);
         }
     }
 
@@ -157,7 +157,7 @@
                 param.asType()).varargs(isVarArg));
         tree.addContent(link);
         if(name(param).length() > 0) {
-            tree.addContent(writer.getSpace());
+            tree.addContent(Contents.SPACE);
             tree.addContent(name(param));
         }
     }
@@ -173,11 +173,11 @@
     protected void addReceiverAnnotations(ExecutableElement member, TypeMirror rcvrType,
             List<? extends AnnotationMirror> annotationMirrors, Content tree) {
         writer.addReceiverAnnotationInfo(member, rcvrType, annotationMirrors, tree);
-        tree.addContent(writer.getSpace());
+        tree.addContent(Contents.SPACE);
         tree.addContent(utils.getTypeName(rcvrType, false));
         LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, RECEIVER_TYPE, rcvrType);
         tree.addContent(writer.getTypeParameterLinks(linkInfo));
-        tree.addContent(writer.getSpace());
+        tree.addContent(Contents.SPACE);
         tree.addContent("this");
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -82,8 +82,7 @@
      */
     protected AbstractIndexWriter(ConfigurationImpl configuration,
                                   DocPath path,
-                                  IndexBuilder indexbuilder)
-                                  throws IOException {
+                                  IndexBuilder indexbuilder) {
         super(configuration, path);
         this.indexbuilder = indexbuilder;
     }
@@ -94,7 +93,7 @@
      * @return a content tree for the tree label
      */
     protected Content getNavLinkIndex() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.indexLabel);
         return li;
     }
 
@@ -216,10 +215,10 @@
     protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) {
         Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg)));
         si.setLabel(utils.getPackageName(pkg));
-        si.setCategory(getResource("doclet.Packages").toString());
+        si.setCategory(resources.getText("doclet.Packages"));
         Content dt = HtmlTree.DT(link);
         dt.addContent(" - ");
-        dt.addContent(getResource("doclet.package"));
+        dt.addContent(contents.package_);
         dt.addContent(" " + utils.getPackageName(pkg));
         dlTree.addContent(dt);
         Content dd = new HtmlTree(HtmlTag.DD);
@@ -238,7 +237,7 @@
                         LinkInfoImpl.Kind.INDEX, typeElement).strong(true));
         si.setContainingPackage(utils.getPackageName(utils.containingPackage(typeElement)));
         si.setLabel(utils.getSimpleName(typeElement));
-        si.setCategory(getResource("doclet.Types").toString());
+        si.setCategory(resources.getText("doclet.Types"));
         Content dt = HtmlTree.DT(link);
         dt.addContent(" - ");
         addClassInfo(typeElement, dt);
@@ -256,7 +255,7 @@
      * @param contentTree the content tree to which the class info will be added
      */
     protected void addClassInfo(TypeElement te, Content contentTree) {
-        contentTree.addContent(getResource("doclet.in",
+        contentTree.addContent(contents.getContent("doclet.in",
                 utils.getTypeElementName(te, false),
                 getPackageLink(utils.containingPackage(te),
                     utils.getPackageName(utils.containingPackage(te)))
@@ -286,7 +285,7 @@
         }  else {
             si.setLabel(name);
         }
-        si.setCategory(getResource("doclet.Members").toString());
+        si.setCategory(resources.getText("doclet.Members"));
         Content span = HtmlTree.SPAN(HtmlStyle.memberNameLink,
                 getDocLink(LinkInfoImpl.Kind.INDEX, member, name));
         Content dt = HtmlTree.DT(span);
@@ -304,11 +303,11 @@
         HtmlTree labelLink = HtmlTree.A(path, new StringContent(sii.getLabel()));
         Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink));
         dt.addContent(" - ");
-        dt.addContent(getResource("doclet.Search_tag_in", sii.getHolder()));
+        dt.addContent(contents.getContent("doclet.Search_tag_in", sii.getHolder()));
         dlTree.addContent(dt);
         Content dd = new HtmlTree(HtmlTag.DD);
         if (sii.getDescription().isEmpty()) {
-            dd.addContent(getSpace());
+            dd.addContent(Contents.SPACE);
         } else {
             dd.addContent(sii.getDescription());
         }
@@ -326,7 +325,7 @@
      */
     protected void addComment(Element element, Content contentTree) {
         List<? extends DocTree> tags;
-        Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+        Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.addStyle(HtmlStyle.block);
         if (utils.isDeprecated(element)) {
@@ -360,15 +359,15 @@
         TypeElement containing = utils.getEnclosingTypeElement(member);
         String classdesc = utils.getTypeElementName(containing, true) + " ";
         if (utils.isField(member)) {
-            Content resource = getResource(utils.isStatic(member)
+            Content resource = contents.getContent(utils.isStatic(member)
                     ? "doclet.Static_variable_in"
                     : "doclet.Variable_in", classdesc);
             contentTree.addContent(resource);
         } else if (utils.isConstructor(member)) {
             contentTree.addContent(
-                    getResource("doclet.Constructor_for", classdesc));
+                    contents.getContent("doclet.Constructor_for", classdesc));
         } else if (utils.isMethod(member)) {
-            Content resource = getResource(utils.isStatic(member)
+            Content resource = contents.getContent(utils.isStatic(member)
                     ? "doclet.Static_method_in"
                     : "doclet.Method_in", classdesc);
             contentTree.addContent(resource);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -33,13 +33,9 @@
 import javax.lang.model.element.Modifier;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
-import javax.lang.model.util.SimpleElementVisitor9;
 
 import com.sun.source.doctree.DocTree;
-import com.sun.tools.javac.util.DefinedBy;
-import com.sun.tools.javac.util.DefinedBy.Api;
 
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
@@ -48,6 +44,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
 import jdk.javadoc.internal.doclets.toolkit.taglets.DeprecatedTaglet;
 import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
@@ -73,6 +70,9 @@
     protected final ConfigurationImpl configuration;
     protected final Utils utils;
     protected final SubWriterHolderWriter writer;
+    protected final Contents contents;
+    protected final Resources resources;
+
     protected final TypeElement typeElement;
     protected Map<String, Integer> typeMap = new LinkedHashMap<>();
     protected Set<MethodTypes> methodTypes = EnumSet.noneOf(MethodTypes.class);
@@ -86,7 +86,9 @@
         this.writer = writer;
         this.nodepr = configuration.nodeprecated;
         this.typeElement = typeElement;
-        this.utils = writer.configuration.utils;
+        this.utils = configuration.utils;
+        this.contents = configuration.contents;
+        this.resources = configuration.resources;
     }
 
     public AbstractMemberWriter(SubWriterHolderWriter writer) {
@@ -258,7 +260,7 @@
         if (!set.isEmpty()) {
             String mods = set.stream().map(m -> m.toString()).collect(Collectors.joining(" "));
             htmltree.addContent(mods);
-            htmltree.addContent(writer.getSpace());
+            htmltree.addContent(Contents.SPACE);
         }
     }
 
@@ -286,7 +288,7 @@
         addModifier(member, code);
         if (type == null) {
             code.addContent(utils.isClass(member) ? "class" : "interface");
-            code.addContent(writer.getSpace());
+            code.addContent(Contents.SPACE);
         } else {
             List<? extends TypeParameterElement> list = utils.isExecutableElement(member)
                     ? ((ExecutableElement)member).getTypeParameters()
@@ -299,7 +301,7 @@
                 if (typeParameters.charCount() > 10) {
                     code.addContent(new HtmlTree(HtmlTag.BR));
                 } else {
-                    code.addContent(writer.getSpace());
+                    code.addContent(Contents.SPACE);
                 }
                 code.addContent(
                         writer.getLink(new LinkInfoImpl(configuration,
@@ -394,6 +396,7 @@
     * @param ped The <code>ProgramElement</code> being checked.
     * return true if the <code>ProgramElement</code> is being inherited and
     * false otherwise.
+     *@return true if inherited
     */
     protected boolean isInherited(Element ped){
         return (!utils.isPrivate(ped) &&
@@ -413,7 +416,7 @@
     protected void addDeprecatedAPI(Collection<Element> deprmembers, String headingKey,
             String tableSummary, List<String> tableHeader, Content contentTree) {
         if (deprmembers.size() > 0) {
-            Content caption = writer.getTableCaption(configuration.getResource(headingKey));
+            Content caption = writer.getTableCaption(configuration.getContent(headingKey));
             Content table = (configuration.isOutputHtml5())
                     ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
                     : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
@@ -536,7 +539,7 @@
 
     protected void serialWarning(Element e, String key, String a1, String a2) {
         if (configuration.serialwarn) {
-            configuration.getDocletSpecificMsg().warning(e, key, a1, a2);
+            configuration.messages.warning(e, key, a1, a2);
         }
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -66,7 +66,7 @@
      * @param filename Name of the module index file to be generated.
      */
     public AbstractModuleIndexWriter(ConfigurationImpl configuration,
-                                      DocPath filename) throws IOException {
+                                      DocPath filename) {
         super(configuration, filename);
         modules = configuration.modulePackages;
     }
@@ -259,7 +259,7 @@
      * @return a Content object to be added to the documentation tree
      */
     protected Content getNavLinkContents() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel);
         return li;
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -65,7 +65,7 @@
      * @param filename Name of the package index file to be generated.
      */
     public AbstractPackageIndexWriter(ConfigurationImpl configuration,
-                                      DocPath filename) throws IOException {
+                                      DocPath filename) {
         super(configuration, filename);
         packages = configuration.packages;
     }
@@ -191,7 +191,7 @@
      * @return a Content object to be added to the documentation tree
      */
     protected Content getNavLinkContents() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel);
         return li;
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -71,8 +71,7 @@
      * @throws DocletAbortException
      */
     protected AbstractTreeWriter(ConfigurationImpl configuration,
-                                 DocPath filename, ClassTree classtree)
-                                 throws IOException {
+                                 DocPath filename, ClassTree classtree) {
         super(configuration, filename);
         this.classtree = classtree;
     }
@@ -121,7 +120,7 @@
                            HtmlTree div, boolean isEnums) {
         if (!sset.isEmpty()) {
             TypeElement firstTypeElement = sset.first();
-            Content headingContent = getResource(heading);
+            Content headingContent = contents.getContent(heading);
             Content sectionHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
                     headingContent);
             HtmlTree htmlTree;
@@ -162,7 +161,7 @@
                             isFirst = false;
                             if (utils.isInterface(typeElement)) {
                                 contentTree.addContent(" (");
-                                contentTree.addContent(getResource("doclet.also"));
+                                contentTree.addContent(contents.also);
                                 contentTree.addContent(" extends ");
                             } else {
                                 contentTree.addContent(" (implements ");
@@ -196,7 +195,7 @@
      * @return a content tree for the tree label
      */
     protected Content getNavLinkTree() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.treeLabel);
         return li;
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -35,6 +35,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -78,8 +79,7 @@
      * @throws DocletAbortException
      */
     public AllClassesFrameWriter(ConfigurationImpl configuration,
-                                 DocPath filename, IndexBuilder indexbuilder)
-                              throws IOException {
+                                 DocPath filename, IndexBuilder indexbuilder) {
         super(configuration, filename);
         this.indexbuilder = indexbuilder;
     }
@@ -100,15 +100,13 @@
             allclassgen = new AllClassesFrameWriter(configuration,
                                                     filename, indexbuilder);
             allclassgen.buildAllClassesFile(true);
-            allclassgen.close();
             filename = DocPaths.ALLCLASSES_NOFRAME;
             allclassgen = new AllClassesFrameWriter(configuration,
                                                     filename, indexbuilder);
             allclassgen.buildAllClassesFile(false);
-            allclassgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.
-                     error("doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                            exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -122,7 +120,7 @@
         String label = configuration.getText("doclet.All_Classes");
         Content body = getBody(false, getWindowTitle(label));
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
-                HtmlStyle.bar, allclassesLabel);
+                HtmlStyle.bar, contents.allClassesLabel);
         body.addContent(heading);
         Content ul = new HtmlTree(HtmlTag.UL);
         // Generate the class links and add it to the tdFont tree.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeFieldWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -111,7 +111,7 @@
             memberDetailsTree.addContent(writer.getMarkerAnchor(
                     SectionName.ANNOTATION_TYPE_FIELD_DETAIL));
             Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
-                    writer.fieldDetailsLabel);
+                    contents.fieldDetailsLabel);
             memberDetailsTree.addContent(heading);
             writer.printedAnnotationFieldHeading = true;
         }
@@ -142,7 +142,7 @@
                 writer.getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.Kind.MEMBER, getType(member)));
         pre.addContent(link);
-        pre.addContent(writer.getSpace());
+        pre.addContent(Contents.SPACE);
         if (configuration.linksource) {
             Content memberName = new StringContent(name(member));
             writer.addSrcLink(member, memberName, pre);
@@ -193,18 +193,11 @@
     }
 
     /**
-     * Close the writer.
-     */
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
      * {@inheritDoc}
      */
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Field_Summary"));
+                contents.fieldSummaryLabel);
         memberTree.addContent(label);
     }
 
@@ -221,7 +214,7 @@
      * {@inheritDoc}
      */
     public Content getCaption() {
-        return configuration.getResource("doclet.Fields");
+        return configuration.getContent("doclet.Fields");
     }
 
     /**
@@ -296,9 +289,9 @@
         if (link) {
             return writer.getHyperLink(
                     SectionName.ANNOTATION_TYPE_FIELD_SUMMARY,
-                    writer.getResource("doclet.navField"));
+                    contents.navField);
         } else {
-            return writer.getResource("doclet.navField");
+            return contents.navField;
         }
     }
 
@@ -309,9 +302,9 @@
         if (link) {
             liNav.addContent(writer.getHyperLink(
                     SectionName.ANNOTATION_TYPE_FIELD_DETAIL,
-                    writer.getResource("doclet.navField")));
+                    contents.navField));
         } else {
-            liNav.addContent(writer.getResource("doclet.navField"));
+            liNav.addContent(contents.navField);
         }
     }
     private TypeMirror getType(Element member) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,8 +25,6 @@
 
 package jdk.javadoc.internal.doclets.formats.html;
 
-import java.io.*;
-
 import java.util.Arrays;
 import java.util.List;
 
@@ -96,7 +94,7 @@
             ExecutableElement ee = (ExecutableElement)member;
             AnnotationValue value = ee.getDefaultValue();
             if (value != null) {
-                Content dt = HtmlTree.DT(writer.getResource("doclet.Default"));
+                Content dt = HtmlTree.DT(contents.default_);
                 Content dl = HtmlTree.DL(dt);
                 Content dd = HtmlTree.DD(new StringContent(value.toString()));
                 dl.addContent(dd);
@@ -108,16 +106,9 @@
     /**
      * {@inheritDoc}
      */
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Annotation_Type_Optional_Member_Summary"));
+                contents.annotateTypeOptionalMemberSummaryLabel);
         memberTree.addContent(label);
     }
 
@@ -125,16 +116,16 @@
      * {@inheritDoc}
      */
     public String getTableSummary() {
-        return configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"),
-                configuration.getText("doclet.annotation_type_optional_members"));
+        return resources.getText("doclet.Member_Table_Summary",
+                resources.getText("doclet.Annotation_Type_Optional_Member_Summary"),
+                resources.getText("doclet.annotation_type_optional_members"));
     }
 
     /**
      * {@inheritDoc}
      */
     public Content getCaption() {
-        return configuration.getResource("doclet.Annotation_Type_Optional_Members");
+        return configuration.getContent("doclet.Annotation_Type_Optional_Members");
     }
 
     /**
@@ -163,9 +154,9 @@
         if (link) {
             return writer.getHyperLink(
                     SectionName.ANNOTATION_TYPE_OPTIONAL_ELEMENT_SUMMARY,
-                    writer.getResource("doclet.navAnnotationTypeOptionalMember"));
+                    contents.navAnnotationTypeOptionalMember);
         } else {
-            return writer.getResource("doclet.navAnnotationTypeOptionalMember");
+            return contents.navAnnotationTypeOptionalMember;
         }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -111,7 +111,7 @@
             memberDetailsTree.addContent(writer.getMarkerAnchor(
                     SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL));
             Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
-                    writer.annotationTypeDetailsLabel);
+                    contents.annotationTypeDetailsLabel);
             memberDetailsTree.addContent(heading);
             writer.printedAnnotationHeading = true;
         }
@@ -143,7 +143,7 @@
                 writer.getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.Kind.MEMBER, getType(member)));
         pre.addContent(link);
-        pre.addContent(writer.getSpace());
+        pre.addContent(Contents.SPACE);
         if (configuration.linksource) {
             Content memberName = new StringContent(name(member));
             writer.addSrcLink(member, memberName, pre);
@@ -194,18 +194,11 @@
     }
 
     /**
-     * Close the writer.
-     */
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
      * {@inheritDoc}
      */
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
+                contents.annotateTypeRequiredMemberSummaryLabel);
         memberTree.addContent(label);
     }
 
@@ -222,7 +215,7 @@
      * {@inheritDoc}
      */
     public Content getCaption() {
-        return configuration.getResource("doclet.Annotation_Type_Required_Members");
+        return configuration.getContent("doclet.Annotation_Type_Required_Members");
     }
 
     /**
@@ -297,9 +290,9 @@
         if (link) {
             return writer.getHyperLink(
                     SectionName.ANNOTATION_TYPE_REQUIRED_ELEMENT_SUMMARY,
-                    writer.getResource("doclet.navAnnotationTypeRequiredMember"));
+                    contents.navAnnotationTypeRequiredMember);
         } else {
-            return writer.getResource("doclet.navAnnotationTypeRequiredMember");
+            return contents.navAnnotationTypeRequiredMember;
         }
     }
 
@@ -310,9 +303,9 @@
         if (link) {
             liNav.addContent(writer.getHyperLink(
                     SectionName.ANNOTATION_TYPE_ELEMENT_DETAIL,
-                    writer.getResource("doclet.navAnnotationTypeMember")));
+                    contents.navAnnotationTypeMember));
         } else {
-            liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
+            liNav.addContent(contents.navAnnotationTypeMember);
         }
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -98,7 +98,7 @@
     @Override
     protected Content getNavLinkModule() {
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(annotationType),
-                moduleLabel);
+                contents.moduleLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -111,7 +111,7 @@
     @Override
     protected Content getNavLinkPackage() {
         Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
-                packageLabel);
+                contents.packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -123,7 +123,7 @@
      */
     @Override
     protected Content getNavLinkClass() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.classLabel);
         return li;
     }
 
@@ -134,7 +134,7 @@
      */
     @Override
     protected Content getNavLinkClassUse() {
-        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
+        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), contents.useLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -150,11 +150,11 @@
         if (prev != null) {
             Content prevLink = getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.Kind.CLASS, utils.asTypeElement(prev))
-                    .label(prevclassLabel).strong(true));
+                    .label(contents.prevClassLabel).strong(true));
             li = HtmlTree.LI(prevLink);
         }
         else
-            li = HtmlTree.LI(prevclassLabel);
+            li = HtmlTree.LI(contents.prevClassLabel);
         return li;
     }
 
@@ -169,11 +169,11 @@
         if (next != null) {
             Content nextLink = getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.Kind.CLASS, utils.asTypeElement(next))
-                    .label(nextclassLabel).strong(true));
+                    .label(contents.nextClassLabel).strong(true));
             li = HtmlTree.LI(nextLink);
         }
         else
-            li = HtmlTree.LI(nextclassLabel);
+            li = HtmlTree.LI(contents.nextClassLabel);
         return li;
     }
 
@@ -320,13 +320,13 @@
         List<? extends DocTree> deprs = utils.getBlockTags(annotationType, DocTree.Kind.DEPRECATED);
         if (utils.isDeprecated(annotationType)) {
             CommentHelper ch = utils.getCommentHelper(annotationType);
-            Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+            Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
             Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
             if (!deprs.isEmpty()) {
 
                 List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
                 if (!commentTags.isEmpty()) {
-                    div.addContent(getSpace());
+                    div.addContent(Contents.SPACE);
                     addInlineDeprecatedComment(annotationType, deprs.get(0), div);
                 }
             }
@@ -340,7 +340,7 @@
     @Override
     protected Content getNavLinkTree() {
         Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
-                treeLabel, "", "");
+                contents.treeLabel, "", "");
         Content li = HtmlTree.LI(treeLinkContent);
         return li;
     }
@@ -368,8 +368,8 @@
      * @throws java.lang.Exception
      */
     protected Content getNavSummaryLinks() throws Exception {
-        Content li = HtmlTree.LI(summaryLabel);
-        li.addContent(getSpace());
+        Content li = HtmlTree.LI(contents.summaryLabel);
+        li.addContent(Contents.SPACE);
         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
@@ -406,7 +406,7 @@
         AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
                 getMemberSummaryWriter(type));
         if (writer == null) {
-            liNav.addContent(getResource(label));
+            liNav.addContent(contents.getContent(label));
         } else {
             liNav.addContent(writer.getNavSummaryLink(null,
                     ! builder.getVisibleMemberMap(type).noVisibleMembers()));
@@ -420,8 +420,8 @@
      * @throws java.lang.Exception
      */
     protected Content getNavDetailLinks() throws Exception {
-        Content li = HtmlTree.LI(detailLabel);
-        li.addContent(getSpace());
+        Content li = HtmlTree.LI(contents.detailLabel);
+        li.addContent(Contents.SPACE);
         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
@@ -438,7 +438,7 @@
         if (writerField != null) {
             writerField.addNavDetailLink(!utils.getAnnotationFields(annotationType).isEmpty(), liNavField);
         } else {
-            liNavField.addContent(getResource("doclet.navField"));
+            liNavField.addContent(contents.navField);
         }
         addNavGap(liNavField);
         ulNav.addContent(liNavField);
@@ -451,7 +451,7 @@
             writerRequired.addNavDetailLink(!annotationType.getAnnotationMirrors().isEmpty(), liNavReq);
             ulNav.addContent(liNavReq);
         } else {
-            Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
+            Content liNav = HtmlTree.LI(contents.navAnnotationTypeMember);
             ulNav.addContent(liNav);
         }
         return ulNav;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -47,6 +47,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
@@ -226,11 +227,10 @@
         try {
             clsgen = new ClassUseWriter(configuration, mapper, path, typeElement);
             clsgen.generateClassUseFile();
-            clsgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.
-                error("doclet.exception_encountered",
-                      exc.toString(), path.getPath());
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
+                    exc.toString(), path.getPath());
             throw new DocletAbortException(exc);
         }
     }
@@ -245,7 +245,7 @@
         if (pkgSet.size() > 0) {
             addClassUse(div);
         } else {
-            div.addContent(getResource("doclet.ClassUse_No.usage.of.0",
+            div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0",
                     utils.getFullyQualifiedName(typeElement)));
         }
         if (configuration.allowTag(HtmlTag.MAIN)) {
@@ -287,7 +287,7 @@
      * @param contentTree the content tree to which the packages elements will be added
      */
     protected void addPackageList(Content contentTree) throws IOException {
-        Content caption = getTableCaption(configuration.getResource(
+        Content caption = getTableCaption(configuration.getContent(
                 "doclet.ClassUse_Packages.that.use.0",
                 getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
@@ -320,7 +320,7 @@
                 pkgToPackageAnnotations.isEmpty()) {
             return;
         }
-        Content caption = getTableCaption(configuration.getResource(
+        Content caption = getTableCaption(configuration.getContent(
                 "doclet.ClassUse_PackageAnnotation",
                 getLink(new LinkInfoImpl(configuration,
                         LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement))));
@@ -360,10 +360,10 @@
             HtmlTree htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                     ? HtmlTree.SECTION(markerAnchor)
                     : HtmlTree.LI(HtmlStyle.blockList, markerAnchor);
-            Content link = getResource("doclet.ClassUse_Uses.of.0.in.1",
-                                       getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
-                                                                typeElement)),
-                                       getPackageLink(pkg, utils.getPackageName(pkg)));
+            Content link = contents.getContent("doclet.ClassUse_Uses.of.0.in.1",
+                    getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER,
+                            typeElement)),
+                    getPackageLink(pkg, utils.getPackageName(pkg)));
             Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
             htmlTree.addContent(heading);
             addClassUse(pkg, htmlTree);
@@ -404,67 +404,67 @@
             LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement));
         Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg));
         classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg),
-                configuration.getResource("doclet.ClassUse_Annotation", classLink,
+                configuration.getContent("doclet.ClassUse_Annotation", classLink,
                 pkgLink), classUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg),
-                configuration.getResource("doclet.ClassUse_TypeParameter", classLink,
+                configuration.getContent("doclet.ClassUse_TypeParameter", classLink,
                 pkgLink), classUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToSubclass.get(pkg),
-                configuration.getResource("doclet.ClassUse_Subclass", classLink,
+                configuration.getContent("doclet.ClassUse_Subclass", classLink,
                 pkgLink), subclassUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToSubinterface.get(pkg),
-                configuration.getResource("doclet.ClassUse_Subinterface", classLink,
+                configuration.getContent("doclet.ClassUse_Subinterface", classLink,
                 pkgLink), subinterfaceUseTableSummary, contentTree);
         classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg),
-                configuration.getResource("doclet.ClassUse_ImplementingClass", classLink,
+                configuration.getContent("doclet.ClassUse_ImplementingClass", classLink,
                 pkgLink), classUseTableSummary, contentTree);
         fieldSubWriter.addUseInfo(pkgToField.get(pkg),
-                configuration.getResource("doclet.ClassUse_Field", classLink,
+                configuration.getContent("doclet.ClassUse_Field", classLink,
                 pkgLink), fieldUseTableSummary, contentTree);
         fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg),
-                configuration.getResource("doclet.ClassUse_FieldAnnotations", classLink,
+                configuration.getContent("doclet.ClassUse_FieldAnnotations", classLink,
                 pkgLink), fieldUseTableSummary, contentTree);
         fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg),
-                configuration.getResource("doclet.ClassUse_FieldTypeParameter", classLink,
+                configuration.getContent("doclet.ClassUse_FieldTypeParameter", classLink,
                 pkgLink), fieldUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodAnnotations", classLink,
+                configuration.getContent("doclet.ClassUse_MethodAnnotations", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodParameterAnnotations", classLink,
+                configuration.getContent("doclet.ClassUse_MethodParameterAnnotations", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodTypeParameter", classLink,
+                configuration.getContent("doclet.ClassUse_MethodTypeParameter", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodReturn", classLink,
+                configuration.getContent("doclet.ClassUse_MethodReturn", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodReturnTypeParameter", classLink,
+                configuration.getContent("doclet.ClassUse_MethodReturnTypeParameter", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodArgs", classLink,
+                configuration.getContent("doclet.ClassUse_MethodArgs", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodArgsTypeParameters", classLink,
+                configuration.getContent("doclet.ClassUse_MethodArgsTypeParameters", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg),
-                configuration.getResource("doclet.ClassUse_MethodThrows", classLink,
+                configuration.getContent("doclet.ClassUse_MethodThrows", classLink,
                 pkgLink), methodUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg),
-                configuration.getResource("doclet.ClassUse_ConstructorAnnotations", classLink,
+                configuration.getContent("doclet.ClassUse_ConstructorAnnotations", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg),
-                configuration.getResource("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
+                configuration.getContent("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg),
-                configuration.getResource("doclet.ClassUse_ConstructorArgs", classLink,
+                configuration.getContent("doclet.ClassUse_ConstructorArgs", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg),
-                configuration.getResource("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
+                configuration.getContent("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
         constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg),
-                configuration.getResource("doclet.ClassUse_ConstructorThrows", classLink,
+                configuration.getContent("doclet.ClassUse_ConstructorThrows", classLink,
                 pkgLink), constructorUseTableSummary, contentTree);
     }
 
@@ -490,7 +490,7 @@
             bodyTree.addContent(htmlTree);
         }
         ContentBuilder headContent = new ContentBuilder();
-        headContent.addContent(getResource("doclet.ClassUse_Title", cltype));
+        headContent.addContent(contents.getContent("doclet.ClassUse_Title", cltype));
         headContent.addContent(new HtmlTree(HtmlTag.BR));
         headContent.addContent(clname);
         Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
@@ -512,7 +512,7 @@
     @Override
     protected Content getNavLinkModule() {
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
-                moduleLabel);
+                contents.moduleLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -524,7 +524,7 @@
      */
     protected Content getNavLinkPackage() {
         Content linkContent =
-                getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), packageLabel);
+                getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_SUMMARY), contents.packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -548,7 +548,7 @@
      * @return a content tree for the use link
      */
     protected Content getNavLinkClassUse() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel);
         return li;
     }
 
@@ -559,8 +559,8 @@
      */
     protected Content getNavLinkTree() {
         Content linkContent = utils.isEnclosingPackageIncluded(typeElement)
-                ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), treeLabel)
-                : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), treeLabel);
+                ? getHyperLink(DocPath.parent.resolve(DocPaths.PACKAGE_TREE), contents.treeLabel)
+                : getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_TREE), contents.treeLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -112,7 +112,7 @@
     @Override
     protected Content getNavLinkModule() {
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(typeElement),
-                moduleLabel);
+                contents.moduleLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -125,7 +125,7 @@
     @Override
     protected Content getNavLinkPackage() {
         Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
-                packageLabel);
+                contents.packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -137,7 +137,7 @@
      */
     @Override
     protected Content getNavLinkClass() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.classLabel);
         return li;
     }
 
@@ -148,7 +148,7 @@
      */
     @Override
     protected Content getNavLinkClassUse() {
-        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), useLabel);
+        Content linkContent = getHyperLink(DocPaths.CLASS_USE.resolve(filename), contents.useLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -164,11 +164,11 @@
         if (prev != null) {
             Content prevLink = getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.Kind.CLASS, prev)
-                    .label(prevclassLabel).strong(true));
+                    .label(contents.prevClassLabel).strong(true));
             li = HtmlTree.LI(prevLink);
         }
         else
-            li = HtmlTree.LI(prevclassLabel);
+            li = HtmlTree.LI(contents.prevClassLabel);
         return li;
     }
 
@@ -183,11 +183,11 @@
         if (next != null) {
             Content nextLink = getLink(new LinkInfoImpl(configuration,
                     LinkInfoImpl.Kind.CLASS, next)
-                    .label(nextclassLabel).strong(true));
+                    .label(contents.nextClassLabel).strong(true));
             li = HtmlTree.LI(nextLink);
         }
         else
-            li = HtmlTree.LI(nextclassLabel);
+            li = HtmlTree.LI(contents.nextClassLabel);
         return li;
     }
 
@@ -210,18 +210,18 @@
         div.addStyle(HtmlStyle.header);
         ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(typeElement);
         if (mdle != null && !mdle.isUnnamed()) {
-            Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, moduleLabel);
+            Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel);
             Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel);
-            moduleNameDiv.addContent(getSpace());
+            moduleNameDiv.addContent(Contents.SPACE);
             moduleNameDiv.addContent(getModuleLink(mdle,
                     new StringContent(mdle.getQualifiedName().toString())));
             div.addContent(moduleNameDiv);
         }
         PackageElement pkg = utils.containingPackage(typeElement);
         if (!pkg.isUnnamed()) {
-            Content classPackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInClass, packageLabel);
+            Content classPackageLabel = HtmlTree.SPAN(HtmlStyle.packageLabelInClass, contents.packageLabel);
             Content pkgNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classPackageLabel);
-            pkgNameDiv.addContent(getSpace());
+            pkgNameDiv.addContent(Contents.SPACE);
             Content pkgNameContent = getPackageLink(pkg,
                     new StringContent(utils.getPackageName(pkg)));
             pkgNameDiv.addContent(pkgNameContent);
@@ -469,8 +469,7 @@
             }
             Set<TypeElement> subclasses = classtree.directSubClasses(typeElement, false);
             if (!subclasses.isEmpty()) {
-                Content label = getResource(
-                        "doclet.Subclasses");
+                Content label = contents.subclassesLabel;
                 Content dt = HtmlTree.DT(label);
                 Content dl = HtmlTree.DL(dt);
                 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBCLASSES,
@@ -488,8 +487,7 @@
         if (utils.isInterface(typeElement)) {
             Set<TypeElement> subInterfaces = classtree.allSubClasses(typeElement, false);
             if (!subInterfaces.isEmpty()) {
-                Content label = getResource(
-                        "doclet.Subinterfaces");
+                Content label = contents.subinterfacesLabel;
                 Content dt = HtmlTree.DT(label);
                 Content dl = HtmlTree.DL(dt);
                 dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUBINTERFACES,
@@ -513,8 +511,7 @@
         }
         Set<TypeElement> implcl = classtree.implementingClasses(typeElement);
         if (!implcl.isEmpty()) {
-            Content label = getResource(
-                    "doclet.Implementing_Classes");
+            Content label = contents.implementingClassesLabel;
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
             dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_CLASSES,
@@ -531,8 +528,7 @@
         SortedSet<TypeMirror> interfaces = new TreeSet<>(utils.makeTypeMirrorClassUseComparator());
         interfaces.addAll(utils.getAllInterfaces(typeElement));
         if (utils.isClass(typeElement) && !interfaces.isEmpty()) {
-            Content label = getResource(
-                    "doclet.All_Implemented_Interfaces");
+            Content label = contents.allImplementedInterfacesLabel;
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
             dl.addContent(getClassLinks(LinkInfoImpl.Kind.IMPLEMENTED_INTERFACES, interfaces));
@@ -550,7 +546,7 @@
         interfaces.addAll(utils.getAllInterfaces(typeElement));
 
         if (utils.isInterface(typeElement) && !interfaces.isEmpty()) {
-            Content label = getResource("doclet.All_Superinterfaces");
+            Content label = contents.allSuperinterfacesLabel;
             Content dt = HtmlTree.DT(label);
             Content dl = HtmlTree.DL(dt);
             dl.addContent(getClassLinks(LinkInfoImpl.Kind.SUPER_INTERFACES, interfaces));
@@ -569,10 +565,10 @@
         new SimpleElementVisitor8<Void, Void>() {
             @Override @DefinedBy(Api.LANGUAGE_MODEL)
             public Void visitType(TypeElement e, Void p) {
-                String label = utils.isInterface(e)
-                        ? "doclet.Enclosing_Interface"
-                        : "doclet.Enclosing_Class";
-                Content dt = HtmlTree.DT(getResource(label));
+                Content label = utils.isInterface(e)
+                        ? contents.enclosingInterfaceLabel
+                        : contents.enclosingClassLabel;
+                Content dt = HtmlTree.DT(label);
                 Content dl = HtmlTree.DL(dt);
                 Content dd = new HtmlTree(HtmlTag.DD);
                 dd.addContent(getLink(new LinkInfoImpl(configuration,
@@ -590,10 +586,10 @@
     @Override
     public void addFunctionalInterfaceInfo (Content classInfoTree) {
         if (isFunctionalInterface()) {
-            Content dt = HtmlTree.DT(getResource("doclet.Functional_Interface"));
+            Content dt = HtmlTree.DT(contents.functionalInterface);
             Content dl = HtmlTree.DL(dt);
             Content dd = new HtmlTree(HtmlTag.DD);
-            dd.addContent(getResource("doclet.Functional_Interface_Message"));
+            dd.addContent(contents.functionalInterfaceMessage);
             dl.addContent(dd);
             classInfoTree.addContent(dl);
         }
@@ -619,14 +615,14 @@
         classInfoTree.addContent(hr);
         List<? extends DocTree> deprs = utils.getBlockTags(typeElement, DocTree.Kind.DEPRECATED);
         if (utils.isDeprecated(typeElement)) {
-            Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+            Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
             Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
             if (!deprs.isEmpty()) {
                 CommentHelper ch = utils.getCommentHelper(typeElement);
                 DocTree dt = deprs.get(0);
                 List<? extends DocTree> commentTags = ch.getBody(configuration, dt);
                 if (!commentTags.isEmpty()) {
-                    div.addContent(getSpace());
+                    div.addContent(Contents.SPACE);
                     addInlineDeprecatedComment(typeElement, deprs.get(0), div);
                 }
             }
@@ -671,7 +667,7 @@
     @Override
     protected Content getNavLinkTree() {
         Content treeLinkContent = getHyperLink(DocPaths.PACKAGE_TREE,
-                treeLabel, "", "");
+                contents.treeLabel, "", "");
         Content li = HtmlTree.LI(treeLinkContent);
         return li;
     }
@@ -697,8 +693,8 @@
      * @return the content tree for the navigation summary links
      */
     protected Content getNavSummaryLinks() throws Exception {
-        Content li = HtmlTree.LI(summaryLabel);
-        li.addContent(getSpace());
+        Content li = HtmlTree.LI(contents.summaryLabel);
+        li.addContent(Contents.SPACE);
         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
@@ -713,7 +709,7 @@
             AbstractMemberWriter writer =
                 ((AbstractMemberWriter) memberSummaryBuilder.getMemberSummaryWriter(kind));
             if (writer == null) {
-                liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
+                liNav.addContent(contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
             } else {
                 writer.addNavSummaryLink(
                         memberSummaryBuilder.members(kind),
@@ -734,8 +730,8 @@
      * @throws java.lang.Exception
      */
     protected Content getNavDetailLinks() throws Exception {
-        Content li = HtmlTree.LI(detailLabel);
-        li.addContent(getSpace());
+        Content li = HtmlTree.LI(contents.detailLabel);
+        li.addContent(Contents.SPACE);
         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
                 configuration.getBuilderFactory().getMemberSummaryBuilder(this);
@@ -751,7 +747,7 @@
                 continue;
             }
             if (writer == null) {
-                liNav.addContent(getResource(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
+                liNav.addContent(contents.getContent(VisibleMemberMap.Kind.getNavLinkLabels(kind)));
             } else {
                 writer.addNavDetailLink(memberSummaryBuilder.members(kind), liNav);
             }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -40,23 +40,22 @@
 
 import com.sun.source.util.DocTreePath;
 import com.sun.tools.doclint.DocLint;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
 import com.sun.tools.javac.code.Symbol.PackageSymbol;
 
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
 import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
-import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
 import static javax.tools.Diagnostic.Kind.*;
@@ -208,10 +207,7 @@
      */
     public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
 
-    /**
-     * Unique Resource Handler for this package.
-     */
-    public final MessageRetriever standardmessage;
+    public final Resources resources;
 
     /**
      * First file to appear in the right-hand frame in the generated
@@ -236,13 +232,21 @@
 
     protected Set<Character> tagSearchIndexKeys;
 
+    protected Contents contents;
+
+    protected Messages messages;
+
     /**
      * Constructor. Initializes resource for the
      * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
      */
     public ConfigurationImpl() {
-        standardmessage = new MessageRetriever(this,
-            "jdk.javadoc.internal.doclets.formats.html.resources.standard");
+        resources = new Resources(this,
+                Configuration.sharedResourceBundleName,
+                "jdk.javadoc.internal.doclets.formats.html.resources.standard");
+
+        messages = new Messages(this);
+        contents = new Contents(this);
     }
 
     private final String versionRBName = "jdk.javadoc.internal.tool.resources.version";
@@ -269,6 +273,16 @@
         }
     }
 
+    @Override
+    public Resources getResources() {
+        return resources;
+    }
+
+    @Override
+    public Messages getMessages() {
+        return messages;
+    }
+
     protected boolean validateOptions() {
         // check shared options
         if (!generalValidOptions()) {
@@ -393,14 +407,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    public MessageRetriever getDocletSpecificMsg() {
-        return standardmessage;
-    }
-
-    /**
      * Decide the page which will appear first in the right-hand frame. It will
      * be "overview-summary.html" if "-overview" option is used or no
      * "-overview" but the number of packages is more than one. It will be
@@ -479,10 +485,11 @@
     }
 
     /**
-     * Return the path of the overview file and null if it does not exist.
+     * Return the path of the overview file or null if it does not exist.
      *
-     * @return the path of the overview file and null if it does not exist.
+     * @return the path of the overview file or null if it does not exist.
      */
+    @Override
     public JavaFileObject getOverviewPath() {
         if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
             StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
@@ -510,10 +517,63 @@
     }
 
     @Override
-    public Content newContent() {
-        return new ContentBuilder();
+    public String getText(String key) {
+        return resources.getText(key);
+    }
+
+    @Override
+    public String getText(String key, String... args) {
+        return resources.getText(key, (Object[]) args);
+    }
+
+   /**
+     * {@inheritdoc}
+     */
+    @Override
+    public Content getContent(String key) {
+        return contents.getContent(key);
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o   string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    @Override
+    public Content getContent(String key, Object o) {
+        return contents.getContent(key, o);
     }
 
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o1 resource argument
+     * @param o2 resource argument
+     * @return a content tree for the text
+     */
+    @Override
+    public Content getContent(String key, Object o1, Object o2) {
+        return contents.getContent(key, o1, o2);
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o0  string or content argument added to configuration text
+     * @param o1  string or content argument added to configuration text
+     * @param o2  string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    @Override
+    public Content getContent(String key, Object o0, Object o1, Object o2) {
+        return contents.getContent(key, o0, o1, o2);
+    }
+
+
     @Override
     public Location getLocationForPackage(PackageElement pd) {
         JavaFileManager fm = getFileManager();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -87,8 +87,7 @@
      * @param configuration the configuration used in this run
      *        of the standard doclet.
      */
-    public ConstantsSummaryWriterImpl(ConfigurationImpl configuration)
-            throws IOException {
+    public ConstantsSummaryWriterImpl(ConfigurationImpl configuration) {
         super(configuration, DocPaths.CONSTANT_VALUES);
         this.configuration = configuration;
         constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
@@ -133,7 +132,7 @@
         if (pkg.isUnnamed()) {
             link = getHyperLink(getDocLink(
                     SectionName.UNNAMED_PACKAGE_ANCHOR),
-                    defaultPackageLabel, "", "");
+                    contents.defaultPackageLabel, "", "");
         } else {
             String parsedPackageName = utils.parsePackageName(pkg);
             Content packageNameContent = getPackageLabel(parsedPackageName);
@@ -150,13 +149,11 @@
      * {@inheritDoc}
      */
     public void addContentsList(Content contentTree, Content contentListTree) {
-        Content titleContent = getResource(
-                "doclet.Constants_Summary");
+        Content titleContent = contents.constantsSummaryTitle;
         Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
                 HtmlStyle.title, titleContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
-        Content headingContent = getResource(
-                "doclet.Contents");
+        Content headingContent = contents.contentsHeading;
         Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
                 headingContent);
         if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -191,7 +188,7 @@
         if (pkg.isUnnamed()) {
             summariesTree.addContent(getMarkerAnchor(
                     SectionName.UNNAMED_PACKAGE_ANCHOR));
-            pkgNameContent = defaultPackageLabel;
+            pkgNameContent = contents.defaultPackageLabel;
         } else {
             String parsedPackageName = utils.parsePackageName(pkg);
             summariesTree.addContent(getMarkerAnchor(parsedPackageName));
@@ -315,7 +312,7 @@
         for (Modifier mod : member.getModifiers()) {
             Content modifier = new StringContent(mod.toString());
             code.addContent(modifier);
-            code.addContent(getSpace());
+            code.addContent(Contents.SPACE);
         }
         Content type = getLink(new LinkInfoImpl(configuration,
                 LinkInfoImpl.Kind.CONSTANT_SUMMARY, member.asType()));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstructorWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -119,7 +119,7 @@
         constructorDetailsTree.addContent(writer.getMarkerAnchor(
                 SectionName.CONSTRUCTOR_DETAIL));
         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
-                writer.constructorDetailsLabel);
+                contents.constructorDetailsLabel);
         constructorDetailsTree.addContent(heading);
         return constructorDetailsTree;
     }
@@ -221,14 +221,6 @@
     }
 
     /**
-     * Close the writer.
-     */
-    @Override
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
      * Let the writer know whether a non public constructor was found.
      *
      * @param foundNonPubConstructor true if we found a non public constructor.
@@ -244,7 +236,7 @@
     @Override
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Constructor_Summary"));
+                contents.constructorSummaryLabel);
         memberTree.addContent(label);
     }
 
@@ -253,9 +245,9 @@
      */
     @Override
     public String getTableSummary() {
-        return configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Constructor_Summary"),
-                configuration.getText("doclet.constructors"));
+        return resources.getText("doclet.Member_Table_Summary",
+                resources.getText("doclet.Constructor_Summary"),
+                resources.getText("doclet.constructors"));
     }
 
     /**
@@ -263,7 +255,7 @@
      */
     @Override
     public Content getCaption() {
-        return configuration.getResource("doclet.Constructors");
+        return contents.constructors;
     }
 
     /**
@@ -273,11 +265,11 @@
     public List<String> getSummaryTableHeader(Element member) {
         List<String> header = new ArrayList<>();
         if (foundNonPubConstructor) {
-            header.add(configuration.getText("doclet.Modifier"));
+            header.add(resources.getText("doclet.Modifier"));
         }
-        header.add(configuration.getText("doclet.0_and_1",
-                configuration.getText("doclet.Constructor"),
-                configuration.getText("doclet.Description")));
+        header.add(resources.getText("doclet.0_and_1",
+                resources.getText("doclet.Constructor"),
+                resources.getText("doclet.Description")));
         return header;
     }
 
@@ -311,9 +303,9 @@
     protected Content getNavSummaryLink(TypeElement typeElement, boolean link) {
         if (link) {
             return writer.getHyperLink(SectionName.CONSTRUCTOR_SUMMARY,
-                    writer.getResource("doclet.navConstructor"));
+                    contents.navConstructor);
         } else {
-            return writer.getResource("doclet.navConstructor");
+            return contents.navConstructor;
         }
     }
 
@@ -325,9 +317,9 @@
         if (link) {
             liNav.addContent(writer.getHyperLink(
                     SectionName.CONSTRUCTOR_DETAIL,
-                    writer.getResource("doclet.navConstructor")));
+                    contents.navConstructor));
         } else {
-            liNav.addContent(writer.getResource("doclet.navConstructor"));
+            liNav.addContent(contents.navConstructor);
         }
     }
 
@@ -343,7 +335,7 @@
             } else if (utils.isPrivate(member)) {
                 code.addContent("private ");
             } else if (utils.isPublic(member)) {
-                code.addContent(writer.getSpace());
+                code.addContent(Contents.SPACE);
             } else {
                 code.addContent(
                         configuration.getText("doclet.Package_private"));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 1998, 2016, 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 jdk.javadoc.internal.doclets.formats.html;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
+import jdk.javadoc.internal.doclets.formats.html.markup.FixedStringContent;
+import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
+import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+/**
+ * Constants and factory methods for common fragments of content
+ * used by HtmlDoclet. The string content of these fragments is
+ * generally obtained from the {@link Resources resources} found
+ * in the doclet's configuration.
+ *
+ * @implNote
+ * Many constants are made available in this class, so that they are
+ * only created once per doclet-instance, instead of once per generated page.
+ */
+public class Contents {
+    public static final Content SPACE = RawHtml.nbsp;
+
+    public final Content allClassesLabel;
+    public final Content allImplementedInterfacesLabel;
+    public final Content allModulesLabel;
+    public final Content allPackagesLabel;
+    public final Content allSuperinterfacesLabel;
+    public final Content also;
+    public final Content annotateTypeOptionalMemberSummaryLabel;
+    public final Content annotateTypeRequiredMemberSummaryLabel;
+    public final Content annotationType;
+    public final Content annotationTypeDetailsLabel;
+    public final Content annotationTypeMemberDetail;
+    public final Content annotationTypes;
+    public final Content classLabel;
+    public final Content classes;
+    public final Content constantsSummaryTitle;
+    public final Content constructorDetailsLabel;
+    public final Content constructorSummaryLabel;
+    public final Content constructors;
+    public final Content contentsHeading;
+    public final Content defaultPackageLabel;
+    public final Content default_;
+    public final Content deprecatedAPI;
+    public final Content deprecatedLabel;
+    public final Content deprecatedPhrase;
+    public final Content descfrmClassLabel;
+    public final Content descfrmInterfaceLabel;
+    public final Content descriptionLabel;
+    public final Content detailLabel;
+    public final Content enclosingClassLabel;
+    public final Content enclosingInterfaceLabel;
+    public final Content enumConstantDetailLabel;
+    public final Content enumConstantSummary;
+    public final Content enum_;
+    public final Content enums;
+    public final Content errors;
+    public final Content exceptions;
+    public final Content fieldDetailsLabel;
+    public final Content fieldSummaryLabel;
+    public final Content fields;
+    public final Content framesLabel;
+    public final Content functionalInterface;
+    public final Content functionalInterfaceMessage;
+    public final Content helpLabel;
+    public final Content hierarchyForAllPackages;
+    public final Content implementation;
+    public final Content implementingClassesLabel;
+    public final Content inClass;
+    public final Content inInterface;
+    public final Content indexLabel;
+    public final Content interfaces;
+    public final Content interfacesItalic;
+    public final Content methodDetailLabel;
+    public final Content methodSummary;
+    public final Content methods;
+    public final Content moduleLabel;
+    public final Content moduleSubNavLabel;
+    public final Content modulesLabel;
+    public final Content navAnnotationTypeMember;
+    public final Content navAnnotationTypeOptionalMember;
+    public final Content navAnnotationTypeRequiredMember;
+    public final Content navConstructor;
+    public final Content navEnum;
+    public final Content navField;
+    public final Content navMethod;
+    public final Content navModuleDescription;
+    public final Content navModules;
+    public final Content navNested;
+    public final Content navPackages;
+    public final Content navProperty;
+    public final Content navServices;
+    public final Content nestedClassSummary;
+    public final Content nextClassLabel;
+    public final Content nextLabel;
+    public final Content nextLetter;
+    public final Content nextModuleLabel;
+    public final Content nextPackageLabel;
+    public final Content noFramesLabel;
+    public final Content noScriptMessage;
+    public final Content overridesLabel;
+    public final Content overviewLabel;
+    public final Content packageHierarchies;
+    public final Content packageLabel;
+    public final Content package_;
+    public final Content packagesLabel;
+    public final Content prevClassLabel;
+    public final Content prevLabel;
+    public final Content prevLetter;
+    public final Content prevModuleLabel;
+    public final Content prevPackageLabel;
+    public final Content properties;
+    public final Content propertyDetailsLabel;
+    public final Content propertySummary;
+    public final Content seeLabel;
+    public final Content serializedForm;
+    public final Content specifiedByLabel;
+    public final Content subclassesLabel;
+    public final Content subinterfacesLabel;
+    public final Content summaryLabel;
+    public final Content treeLabel;
+    public final Content useLabel;
+
+    private final Resources resources;
+
+    /**
+     * Creates a {@code Contents} object.
+     *
+     * @param configuration the configuration in which to find the
+     * resources used to look up resource keys, and other details.
+     */
+    Contents(ConfigurationImpl configuration) {
+        this.resources = configuration.getResources();
+
+        allClassesLabel = getNonBreakContent("doclet.All_Classes");
+        allImplementedInterfacesLabel = getContent("doclet.All_Implemented_Interfaces");
+        allModulesLabel = getNonBreakContent("doclet.All_Modules");
+        allPackagesLabel = getNonBreakContent("doclet.All_Packages");
+        allSuperinterfacesLabel = getContent("doclet.All_Superinterfaces");
+        also = getContent("doclet.also");
+        annotateTypeOptionalMemberSummaryLabel = getContent("doclet.Annotation_Type_Optional_Member_Summary");
+        annotateTypeRequiredMemberSummaryLabel = getContent("doclet.Annotation_Type_Required_Member_Summary");
+        annotationType = getContent("doclet.AnnotationType");
+        annotationTypeDetailsLabel = getContent("doclet.Annotation_Type_Member_Detail");
+        annotationTypeMemberDetail = getContent("doclet.Annotation_Type_Member_Detail");
+        annotationTypes = getContent("doclet.AnnotationTypes");
+        classLabel = getContent("doclet.Class");
+        classes = getContent("doclet.Classes");
+        constantsSummaryTitle = getContent("doclet.Constants_Summary");
+        constructorDetailsLabel = getContent("doclet.Constructor_Detail");
+        constructorSummaryLabel = getContent("doclet.Constructor_Summary");
+        constructors = getContent("doclet.Constructors");
+        contentsHeading = getContent("doclet.Contents");
+        defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME);
+        default_ = getContent("doclet.Default");
+        deprecatedAPI = getContent("doclet.Deprecated_API");
+        deprecatedLabel = getContent("doclet.navDeprecated");
+        deprecatedPhrase = getContent("doclet.Deprecated");
+        descfrmClassLabel = getContent("doclet.Description_From_Class");
+        descfrmInterfaceLabel = getContent("doclet.Description_From_Interface");
+        descriptionLabel = getContent("doclet.Description");
+        detailLabel = getContent("doclet.Detail");
+        enclosingClassLabel = getContent("doclet.Enclosing_Class");
+        enclosingInterfaceLabel = getContent("doclet.Enclosing_Interface");
+        enumConstantDetailLabel = getContent("doclet.Enum_Constant_Detail");
+        enumConstantSummary = getContent("doclet.Enum_Constant_Summary");
+        enum_ = getContent("doclet.Enum");
+        enums = getContent("doclet.Enums");
+        errors = getContent("doclet.Errors");
+        exceptions = getContent("doclet.Exceptions");
+        fieldDetailsLabel = getContent("doclet.Field_Detail");
+        fieldSummaryLabel = getContent("doclet.Field_Summary");
+        fields = getContent("doclet.Fields");
+        framesLabel = getContent("doclet.Frames");
+        functionalInterface = getContent("doclet.Functional_Interface");
+        functionalInterfaceMessage = getContent("doclet.Functional_Interface_Message");
+        helpLabel = getContent("doclet.Help");
+        hierarchyForAllPackages = getContent("doclet.Hierarchy_For_All_Packages");
+        implementation = getContent("doclet.Implementation");
+        implementingClassesLabel = getContent("doclet.Implementing_Classes");
+        inClass = getContent("doclet.in_class");
+        inInterface = getContent("doclet.in_interface");
+        indexLabel = getContent("doclet.Index");
+        interfaces = getContent("doclet.Interfaces");
+        interfacesItalic = getContent("doclet.Interfaces_Italic");
+        methodDetailLabel = getContent("doclet.Method_Detail");
+        methodSummary = getContent("doclet.Method_Summary");
+        methods = getContent("doclet.Methods");
+        moduleLabel = getContent("doclet.Module");
+        moduleSubNavLabel = getContent("doclet.Module_Sub_Nav");
+        modulesLabel = getContent("doclet.Modules");
+        navAnnotationTypeMember = getContent("doclet.navAnnotationTypeMember");
+        navAnnotationTypeOptionalMember = getContent("doclet.navAnnotationTypeOptionalMember");
+        navAnnotationTypeRequiredMember = getContent("doclet.navAnnotationTypeRequiredMember");
+        navConstructor = getContent("doclet.navConstructor");
+        navEnum = getContent("doclet.navEnum");
+        navField = getContent("doclet.navField");
+        navMethod = getContent("doclet.navMethod");
+        navModuleDescription = getContent("doclet.navModuleDescription");
+        navModules = getContent("doclet.navModules");
+        navNested = getContent("doclet.navNested");
+        navPackages = getContent("doclet.navPackages");
+        navProperty = getContent("doclet.navProperty");
+        navServices = getContent("doclet.navServices");
+        nestedClassSummary = getContent("doclet.Nested_Class_Summary");
+        nextClassLabel = getNonBreakContent("doclet.Next_Class");
+        nextLabel = getNonBreakContent("doclet.Next");
+        nextLetter = getContent("doclet.Next_Letter");
+        nextModuleLabel = getNonBreakContent("doclet.Next_Module");
+        nextPackageLabel = getNonBreakContent("doclet.Next_Package");
+        noFramesLabel = getNonBreakContent("doclet.No_Frames");
+        noScriptMessage = getContent("doclet.No_Script_Message");
+        overridesLabel = getContent("doclet.Overrides");
+        overviewLabel = getContent("doclet.Overview");
+        packageHierarchies = getContent("doclet.Package_Hierarchies");
+        packageLabel = getContent("doclet.Package");
+        package_ = getContent("doclet.package");
+        packagesLabel = getContent("doclet.Packages");
+        prevClassLabel = getNonBreakContent("doclet.Prev_Class");
+        prevLabel = getContent("doclet.Prev");
+        prevLetter = getContent("doclet.Prev_Letter");
+        prevModuleLabel = getNonBreakContent("doclet.Prev_Module");
+        prevPackageLabel = getNonBreakContent("doclet.Prev_Package");
+        properties = getContent("doclet.Properties");
+        propertyDetailsLabel = getContent("doclet.Property_Detail");
+        propertySummary = getContent("doclet.Property_Summary");
+        seeLabel = getContent("doclet.See");
+        serializedForm = getContent("doclet.Serialized_Form");
+        specifiedByLabel = getContent("doclet.Specified_By");
+        subclassesLabel = getContent("doclet.Subclasses");
+        subinterfacesLabel = getContent("doclet.Subinterfaces");
+        summaryLabel = getContent("doclet.Summary");
+        treeLabel = getContent("doclet.Tree");
+        useLabel = getContent("doclet.navClassUse");
+    }
+
+    /**
+     * Gets a {@code Content} object, containing the string for
+     * a given key in the doclet's resources.
+     *
+     * @param key the key for the desired string
+     * @return a content tree for the string
+     */
+    public Content getContent(String key) {
+        return new FixedStringContent(resources.getText(key));
+    }
+
+    /**
+     * Gets a {@code Content} object, containing the string for
+     * a given key in the doclet's resources, formatted with
+     * given arguments.
+     *
+     * @param key the key to look for in the configuration fil
+     * @param key the key for the desired string
+     * @param o0  string or content argument to be formatted into the result
+     * @return a content tree for the text
+     */
+    public Content getContent(String key, Object o0) {
+        return getContent(key, o0, null, null);
+    }
+
+    /**
+     * Gets a {@code Content} object, containing the string for
+     * a given key in the doclet's resources, formatted with
+     * given arguments.
+
+     * @param key the key for the desired string
+     * @param o0  string or content argument to be formatted into the result
+     * @param o1  string or content argument to be formatted into the result
+     * @return a content tree for the text
+     */
+    public Content getContent(String key, Object o0, Object o1) {
+        return getContent(key, o0, o1, null);
+    }
+
+    /**
+     * Gets a {@code Content} object, containing the string for
+     * a given key in the doclet's resources, formatted with
+     * given arguments.
+     *
+     * @param key the key for the desired string
+     * @param o0  string or content argument to be formatted into the result
+     * @param o1  string or content argument to be formatted into the result
+     * @param o2  string or content argument to be formatted into the result
+     * @return a content tree for the text
+     */
+    public Content getContent(String key, Object o0, Object o1, Object o2) {
+        Content c = new ContentBuilder();
+        Pattern p = Pattern.compile("\\{([012])\\}");
+        String text = resources.getText(key); // TODO: cache
+        Matcher m = p.matcher(text);
+        int start = 0;
+        while (m.find(start)) {
+            c.addContent(text.substring(start, m.start()));
+
+            Object o = null;
+            switch (m.group(1).charAt(0)) {
+                case '0': o = o0; break;
+                case '1': o = o1; break;
+                case '2': o = o2; break;
+            }
+
+            if (o == null) {
+                c.addContent("{" + m.group(1) + "}");
+            } else if (o instanceof String) {
+                c.addContent((String) o);
+            } else if (o instanceof Content) {
+                c.addContent((Content) o);
+            }
+
+            start = m.end();
+        }
+
+        c.addContent(text.substring(start));
+        return c;
+    }
+
+    /**
+     * Gets a {@code Content} object, containing the string for
+     * a given key in the doclet's resources, substituting
+     * <code>&nbsp;</code> for any space characters found in
+     * the named resource string.
+     *
+     * @param key the key for the desired string
+     * @return a content tree for the string
+     */
+    private Content getNonBreakContent(String key) {
+        String text = resources.getText(key); // TODO: cache
+        Content c = new ContentBuilder();
+        int start = 0;
+        int p;
+        while ((p = text.indexOf(" ", start)) != -1) {
+            c.addContent(text.substring(start, p));
+            c.addContent(RawHtml.nbsp);
+            start = p + 1;
+        }
+        c.addContent(text.substring(start));
+        return c; // TODO: should be made immutable
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -35,6 +35,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
@@ -243,10 +244,9 @@
                    new DeprecatedListWriter(configuration, filename);
             depr.generateDeprecatedListFile(
                    new DeprecatedAPIListBuilder(configuration));
-            depr.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -314,7 +314,7 @@
             DeprElementKind kind, Content contentTree) {
         if (builder.hasDocumentation(kind)) {
             Content li = HtmlTree.LI(getHyperLink(getAnchorName(kind),
-                    getResource(getHeadingKey(kind))));
+                    contents.getContent(getHeadingKey(kind))));
             contentTree.addContent(li);
         }
     }
@@ -326,11 +326,11 @@
      * @return a content tree for the contents list
      */
     public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
-        Content headContent = getResource("doclet.Deprecated_API");
+        Content headContent = contents.deprecatedAPI;
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
                 HtmlStyle.title, headContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
-        Content headingContent = getResource("doclet.Contents");
+        Content headingContent = contents.contentsHeading;
         div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
                 headingContent));
         Content ul = new HtmlTree(HtmlTag.UL);
@@ -379,7 +379,7 @@
      * @return a content tree for the deprecated label
      */
     protected Content getNavLinkDeprecated() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel);
         return li;
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/EnumConstantWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -95,7 +95,7 @@
         enumConstantsDetailsTree.addContent(writer.getMarkerAnchor(
                 SectionName.ENUM_CONSTANT_DETAIL));
         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
-                writer.enumConstantsDetailsLabel);
+                contents.enumConstantDetailLabel);
         enumConstantsDetailsTree.addContent(heading);
         return enumConstantsDetailsTree;
     }
@@ -185,17 +185,9 @@
      * {@inheritDoc}
      */
     @Override
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Enum_Constant_Summary"));
+                contents.enumConstantSummary);
         memberTree.addContent(label);
     }
 
@@ -204,9 +196,9 @@
      */
     @Override
     public String getTableSummary() {
-        return configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Enum_Constant_Summary"),
-                configuration.getText("doclet.enum_constants"));
+        return resources.getText("doclet.Member_Table_Summary",
+                resources.getText("doclet.Enum_Constant_Summary"),
+                resources.getText("doclet.enum_constants"));
     }
 
     /**
@@ -214,7 +206,7 @@
      */
     @Override
     public Content getCaption() {
-        return configuration.getResource("doclet.Enum_Constants");
+        return configuration.getContent("doclet.Enum_Constants");
     }
 
     /**
@@ -303,14 +295,14 @@
         if (link) {
             if (typeElement == null) {
                 return writer.getHyperLink(SectionName.ENUM_CONSTANT_SUMMARY,
-                        writer.getResource("doclet.navEnum"));
+                        contents.navEnum);
             } else {
                 return writer.getHyperLink(
                         SectionName.ENUM_CONSTANTS_INHERITANCE,
-                        configuration.getClassName(typeElement), writer.getResource("doclet.navEnum"));
+                        configuration.getClassName(typeElement), contents.navEnum);
             }
         } else {
-            return writer.getResource("doclet.navEnum");
+            return contents.navEnum;
         }
     }
 
@@ -322,9 +314,9 @@
         if (link) {
             liNav.addContent(writer.getHyperLink(
                     SectionName.ENUM_CONSTANT_DETAIL,
-                    writer.getResource("doclet.navEnum")));
+                    contents.navEnum));
         } else {
-            liNav.addContent(writer.getResource("doclet.navEnum"));
+            liNav.addContent(contents.navEnum);
         }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FieldWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -95,7 +95,7 @@
         fieldDetailsTree.addContent(writer.getMarkerAnchor(
                 SectionName.FIELD_DETAIL));
         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
-                writer.fieldDetailsLabel);
+                contents.fieldDetailsLabel);
         fieldDetailsTree.addContent(heading);
         return fieldDetailsTree;
     }
@@ -182,20 +182,12 @@
     }
 
     /**
-     * Close the writer.
-     */
-    @Override
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Field_Summary"));
+                contents.fieldSummaryLabel);
         memberTree.addContent(label);
     }
 
@@ -204,9 +196,9 @@
      */
     @Override
     public String getTableSummary() {
-        return configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Field_Summary"),
-                configuration.getText("doclet.fields"));
+        return resources.getText("doclet.Member_Table_Summary",
+                resources.getText("doclet.Field_Summary"),
+                resources.getText("doclet.fields"));
     }
 
     /**
@@ -214,7 +206,7 @@
      */
     @Override
     public Content getCaption() {
-        return configuration.getResource("doclet.Fields");
+        return contents.fields;
     }
 
     /**
@@ -223,9 +215,9 @@
     @Override
     public List<String> getSummaryTableHeader(Element member) {
         List<String> header = Arrays.asList(writer.getModifierTypeHeader(),
-            configuration.getText("doclet.0_and_1",
-                    configuration.getText("doclet.Field"),
-                    configuration.getText("doclet.Description")));
+            resources.getText("doclet.0_and_1",
+                    resources.getText("doclet.Field"),
+                    resources.getText("doclet.Description")));
         return header;
     }
 
@@ -259,7 +251,7 @@
                 : configuration.getText("doclet.Fields_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
-        labelHeading.addContent(writer.getSpace());
+        labelHeading.addContent(Contents.SPACE);
         labelHeading.addContent(classLink);
         inheritedTree.addContent(labelHeading);
     }
@@ -312,14 +304,14 @@
             if (typeElement == null) {
                 return writer.getHyperLink(
                         SectionName.FIELD_SUMMARY,
-                        writer.getResource("doclet.navField"));
+                        contents.navField);
             } else {
                 return writer.getHyperLink(
                         SectionName.FIELDS_INHERITANCE,
-                        configuration.getClassName(typeElement), writer.getResource("doclet.navField"));
+                        configuration.getClassName(typeElement), contents.navField);
             }
         } else {
-            return writer.getResource("doclet.navField");
+            return contents.navField;
         }
     }
 
@@ -331,9 +323,9 @@
         if (link) {
             liNav.addContent(writer.getHyperLink(
                     SectionName.FIELD_DETAIL,
-                    writer.getResource("doclet.navField")));
+                    contents.navField));
         } else {
-            liNav.addContent(writer.getResource("doclet.navField"));
+            liNav.addContent(contents.navField);
         }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,6 +32,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -68,7 +69,7 @@
      * @param filename File to be generated.
      * @throws java.io.IOException
      */
-    public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) throws IOException {
+    public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) {
         super(configuration, filename);
         noOfPackages = configuration.packages.size();
     }
@@ -87,10 +88,9 @@
             filename = DocPaths.INDEX;
             framegen = new FrameOutputWriter(configuration, filename);
             framegen.generateFrameFile();
-            framegen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -33,6 +33,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -58,7 +59,7 @@
      * @param filename File to be generated.
      */
     public HelpWriter(ConfigurationImpl configuration,
-                      DocPath filename) throws IOException {
+                      DocPath filename) {
         super(configuration, filename);
     }
 
@@ -76,10 +77,9 @@
             filename = DocPaths.HELP_DOC;
             helpgen = new HelpWriter(configuration, filename);
             helpgen.generateHelpFile();
-            helpgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -121,10 +121,10 @@
      */
     protected void addHelpFileContents(Content contentTree) {
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title,
-                getResource("doclet.Help_line_1"));
+                contents.getContent("doclet.Help_line_1"));
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
         Content line2 = HtmlTree.DIV(HtmlStyle.subTitle,
-                getResource("doclet.Help_line_2"));
+                contents.getContent("doclet.Help_line_2"));
         div.addContent(line2);
         if (configuration.allowTag(HtmlTag.MAIN)) {
             mainTree.addContent(div);
@@ -136,11 +136,11 @@
         ul.addStyle(HtmlStyle.blockList);
         if (configuration.createoverview) {
             Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Overview"));
+                contents.overviewLabel);
             htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                     ? HtmlTree.SECTION(overviewHeading)
                     : HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
-            Content line3 = getResource("doclet.Help_line_3",
+            Content line3 = contents.getContent("doclet.Help_line_3",
                     getHyperLink(DocPaths.OVERVIEW_SUMMARY,
                     configuration.getText("doclet.Overview")));
             Content overviewPara = HtmlTree.P(line3);
@@ -152,26 +152,26 @@
             }
         }
         Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Package"));
+                contents.packageLabel);
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(packageHead)
                 : HtmlTree.LI(HtmlStyle.blockList, packageHead);
-        Content line4 = getResource("doclet.Help_line_4");
+        Content line4 = contents.getContent("doclet.Help_line_4");
         Content packagePara = HtmlTree.P(line4);
         htmlTree.addContent(packagePara);
         HtmlTree ulPackage = new HtmlTree(HtmlTag.UL);
         ulPackage.addContent(HtmlTree.LI(
-                getResource("doclet.Interfaces_Italic")));
+                contents.interfacesItalic));
         ulPackage.addContent(HtmlTree.LI(
-                getResource("doclet.Classes")));
+                contents.classes));
         ulPackage.addContent(HtmlTree.LI(
-                getResource("doclet.Enums")));
+                contents.enums));
         ulPackage.addContent(HtmlTree.LI(
-                getResource("doclet.Exceptions")));
+                contents.exceptions));
         ulPackage.addContent(HtmlTree.LI(
-                getResource("doclet.Errors")));
+                contents.errors));
         ulPackage.addContent(HtmlTree.LI(
-                getResource("doclet.AnnotationTypes")));
+                contents.annotationTypes));
         htmlTree.addContent(ulPackage);
         if (configuration.allowTag(HtmlTag.SECTION)) {
             ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
@@ -179,46 +179,39 @@
             ul.addContent(htmlTree);
         }
         Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Help_line_5"));
+                contents.getContent("doclet.Help_line_5"));
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(classHead)
                 : HtmlTree.LI(HtmlStyle.blockList, classHead);
-        Content line6 = getResource("doclet.Help_line_6");
+        Content line6 = contents.getContent("doclet.Help_line_6");
         Content classPara = HtmlTree.P(line6);
         htmlTree.addContent(classPara);
         HtmlTree ul1 = new HtmlTree(HtmlTag.UL);
         ul1.addContent(HtmlTree.LI(
-                getResource("doclet.Help_line_7")));
+                contents.getContent("doclet.Help_line_7")));
         ul1.addContent(HtmlTree.LI(
-                getResource("doclet.Help_line_8")));
+                contents.getContent("doclet.Help_line_8")));
         ul1.addContent(HtmlTree.LI(
-                getResource("doclet.Help_line_9")));
+                contents.getContent("doclet.Help_line_9")));
         ul1.addContent(HtmlTree.LI(
-                getResource("doclet.Help_line_10")));
+                contents.getContent("doclet.Help_line_10")));
         ul1.addContent(HtmlTree.LI(
-                getResource("doclet.Help_line_11")));
+                contents.getContent("doclet.Help_line_11")));
         ul1.addContent(HtmlTree.LI(
-                getResource("doclet.Help_line_12")));
+                contents.getContent("doclet.Help_line_12")));
         htmlTree.addContent(ul1);
         HtmlTree ul2 = new HtmlTree(HtmlTag.UL);
-        ul2.addContent(HtmlTree.LI(
-                getResource("doclet.Nested_Class_Summary")));
-        ul2.addContent(HtmlTree.LI(
-                getResource("doclet.Field_Summary")));
-        ul2.addContent(HtmlTree.LI(
-                getResource("doclet.Constructor_Summary")));
-        ul2.addContent(HtmlTree.LI(
-                getResource("doclet.Method_Summary")));
+        ul2.addContent(HtmlTree.LI(contents.nestedClassSummary));
+        ul2.addContent(HtmlTree.LI(contents.fieldSummaryLabel));
+        ul2.addContent(HtmlTree.LI(contents.constructorSummaryLabel));
+        ul2.addContent(HtmlTree.LI(contents.methodSummary));
         htmlTree.addContent(ul2);
         HtmlTree ul3 = new HtmlTree(HtmlTag.UL);
-        ul3.addContent(HtmlTree.LI(
-                getResource("doclet.Field_Detail")));
-        ul3.addContent(HtmlTree.LI(
-                getResource("doclet.Constructor_Detail")));
-        ul3.addContent(HtmlTree.LI(
-                getResource("doclet.Method_Detail")));
+        ul3.addContent(HtmlTree.LI(contents.fieldDetailsLabel));
+        ul3.addContent(HtmlTree.LI(contents.constructorDetailsLabel));
+        ul3.addContent(HtmlTree.LI(contents.methodDetailLabel));
         htmlTree.addContent(ul3);
-        Content line13 = getResource("doclet.Help_line_13");
+        Content line13 = contents.getContent("doclet.Help_line_13");
         Content para = HtmlTree.P(line13);
         htmlTree.addContent(para);
         if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -228,24 +221,24 @@
         }
         //Annotation Types
         Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.AnnotationType"));
+                contents.annotationType);
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(aHead)
                 : HtmlTree.LI(HtmlStyle.blockList, aHead);
-        Content aline1 = getResource("doclet.Help_annotation_type_line_1");
+        Content aline1 = contents.getContent("doclet.Help_annotation_type_line_1");
         Content aPara = HtmlTree.P(aline1);
         htmlTree.addContent(aPara);
         HtmlTree aul = new HtmlTree(HtmlTag.UL);
         aul.addContent(HtmlTree.LI(
-                getResource("doclet.Help_annotation_type_line_2")));
+                contents.getContent("doclet.Help_annotation_type_line_2")));
         aul.addContent(HtmlTree.LI(
-                getResource("doclet.Help_annotation_type_line_3")));
+                contents.getContent("doclet.Help_annotation_type_line_3")));
         aul.addContent(HtmlTree.LI(
-                getResource("doclet.Annotation_Type_Required_Member_Summary")));
+                contents.annotateTypeRequiredMemberSummaryLabel));
         aul.addContent(HtmlTree.LI(
-                getResource("doclet.Annotation_Type_Optional_Member_Summary")));
+                contents.annotateTypeOptionalMemberSummaryLabel));
         aul.addContent(HtmlTree.LI(
-                getResource("doclet.Annotation_Type_Member_Detail")));
+                contents.annotationTypeMemberDetail));
         htmlTree.addContent(aul);
         if (configuration.allowTag(HtmlTag.SECTION)) {
             ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
@@ -254,22 +247,22 @@
         }
         //Enums
         Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Enum"));
+                contents.enum_);
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(enumHead)
                 : HtmlTree.LI(HtmlStyle.blockList, enumHead);
-        Content eline1 = getResource("doclet.Help_enum_line_1");
+        Content eline1 = contents.getContent("doclet.Help_enum_line_1");
         Content enumPara = HtmlTree.P(eline1);
         htmlTree.addContent(enumPara);
         HtmlTree eul = new HtmlTree(HtmlTag.UL);
         eul.addContent(HtmlTree.LI(
-                getResource("doclet.Help_enum_line_2")));
+                contents.getContent("doclet.Help_enum_line_2")));
         eul.addContent(HtmlTree.LI(
-                getResource("doclet.Help_enum_line_3")));
+                contents.getContent("doclet.Help_enum_line_3")));
         eul.addContent(HtmlTree.LI(
-                getResource("doclet.Enum_Constant_Summary")));
+                contents.enumConstantSummary));
         eul.addContent(HtmlTree.LI(
-                getResource("doclet.Enum_Constant_Detail")));
+                contents.enumConstantDetailLabel));
         htmlTree.addContent(eul);
         if (configuration.allowTag(HtmlTag.SECTION)) {
             ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
@@ -278,11 +271,11 @@
         }
         if (configuration.classuse) {
             Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                    getResource("doclet.Help_line_14"));
+                    contents.getContent("doclet.Help_line_14"));
             htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                     ? HtmlTree.SECTION(useHead)
                     : HtmlTree.LI(HtmlStyle.blockList, useHead);
-            Content line15 = getResource("doclet.Help_line_15");
+            Content line15 = contents.getContent("doclet.Help_line_15");
             Content usePara = HtmlTree.P(line15);
             htmlTree.addContent(usePara);
             if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -293,11 +286,11 @@
         }
         if (configuration.createtree) {
             Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                    getResource("doclet.Help_line_16"));
+                    contents.getContent("doclet.Help_line_16"));
             htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                     ? HtmlTree.SECTION(treeHead)
                     : HtmlTree.LI(HtmlStyle.blockList, treeHead);
-            Content line17 = getResource("doclet.Help_line_17_with_tree_link",
+            Content line17 = contents.getContent("doclet.Help_line_17_with_tree_link",
                     getHyperLink(DocPaths.OVERVIEW_TREE,
                     configuration.getText("doclet.Class_Hierarchy")),
                     HtmlTree.CODE(new StringContent("java.lang.Object")));
@@ -305,9 +298,9 @@
             htmlTree.addContent(treePara);
             HtmlTree tul = new HtmlTree(HtmlTag.UL);
             tul.addContent(HtmlTree.LI(
-                    getResource("doclet.Help_line_18")));
+                    contents.getContent("doclet.Help_line_18")));
             tul.addContent(HtmlTree.LI(
-                    getResource("doclet.Help_line_19")));
+                    contents.getContent("doclet.Help_line_19")));
             htmlTree.addContent(tul);
             if (configuration.allowTag(HtmlTag.SECTION)) {
                 ul.addContent(HtmlTree.LI(HtmlStyle.blockList, htmlTree));
@@ -318,11 +311,11 @@
         if (!(configuration.nodeprecatedlist ||
                   configuration.nodeprecated)) {
             Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                    getResource("doclet.Deprecated_API"));
+                    contents.deprecatedAPI);
             htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                     ? HtmlTree.SECTION(dHead)
                     : HtmlTree.LI(HtmlStyle.blockList, dHead);
-            Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
+            Content line20 = contents.getContent("doclet.Help_line_20_with_deprecated_api_link",
                     getHyperLink(DocPaths.DEPRECATED_LIST,
                     configuration.getText("doclet.Deprecated_API")));
             Content dPara = HtmlTree.P(line20);
@@ -343,11 +336,11 @@
                         configuration.getText("doclet.Index"));
             }
             Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                    getResource("doclet.Help_line_21"));
+                    contents.getContent("doclet.Help_line_21"));
             htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                     ? HtmlTree.SECTION(indexHead)
                     : HtmlTree.LI(HtmlStyle.blockList, indexHead);
-            Content line22 = getResource("doclet.Help_line_22", indexlink);
+            Content line22 = contents.getContent("doclet.Help_line_22", indexlink);
             Content indexPara = HtmlTree.P(line22);
             htmlTree.addContent(indexPara);
             if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -357,11 +350,11 @@
             }
         }
         Content prevHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Help_line_23"));
+                contents.getContent("doclet.Help_line_23"));
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(prevHead)
                 : HtmlTree.LI(HtmlStyle.blockList, prevHead);
-        Content line24 = getResource("doclet.Help_line_24");
+        Content line24 = contents.getContent("doclet.Help_line_24");
         Content prevPara = HtmlTree.P(line24);
         htmlTree.addContent(prevPara);
         if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -370,11 +363,11 @@
             ul.addContent(htmlTree);
         }
         Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Help_line_25"));
+                contents.getContent("doclet.Help_line_25"));
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(frameHead)
                 : HtmlTree.LI(HtmlStyle.blockList, frameHead);
-        Content line26 = getResource("doclet.Help_line_26");
+        Content line26 = contents.getContent("doclet.Help_line_26");
         Content framePara = HtmlTree.P(line26);
         htmlTree.addContent(framePara);
         if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -383,13 +376,13 @@
             ul.addContent(htmlTree);
         }
         Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.All_Classes"));
+                contents.allClassesLabel);
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(allclassesHead)
                 : HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
-        Content line27 = getResource("doclet.Help_line_27",
+        Content line27 = contents.getContent("doclet.Help_line_27",
                 getHyperLink(DocPaths.ALLCLASSES_NOFRAME,
-                configuration.getText("doclet.All_Classes")));
+                resources.getText("doclet.All_Classes")));
         Content allclassesPara = HtmlTree.P(line27);
         htmlTree.addContent(allclassesPara);
         if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -398,11 +391,11 @@
             ul.addContent(htmlTree);
         }
         Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Serialized_Form"));
+                contents.serializedForm);
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(sHead)
                 : HtmlTree.LI(HtmlStyle.blockList, sHead);
-        Content line28 = getResource("doclet.Help_line_28");
+        Content line28 = contents.getContent("doclet.Help_line_28");
         Content serialPara = HtmlTree.P(line28);
         htmlTree.addContent(serialPara);
         if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -411,13 +404,13 @@
             ul.addContent(htmlTree);
         }
         Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
-                getResource("doclet.Constants_Summary"));
+                contents.constantsSummaryTitle);
         htmlTree = (configuration.allowTag(HtmlTag.SECTION))
                 ? HtmlTree.SECTION(constHead)
                 : HtmlTree.LI(HtmlStyle.blockList, constHead);
-        Content line29 = getResource("doclet.Help_line_29",
+        Content line29 = contents.getContent("doclet.Help_line_29",
                 getHyperLink(DocPaths.CONSTANT_VALUES,
-                configuration.getText("doclet.Constants_Summary")));
+                resources.getText("doclet.Constants_Summary")));
         Content constPara = HtmlTree.P(line29);
         htmlTree.addContent(constPara);
         if (configuration.allowTag(HtmlTag.SECTION)) {
@@ -426,7 +419,7 @@
             ul.addContent(htmlTree);
         }
         Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
-        Content line30 = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase, getResource("doclet.Help_line_30"));
+        Content line30 = HtmlTree.SPAN(HtmlStyle.emphasizedPhrase, contents.getContent("doclet.Help_line_30"));
         divContent.addContent(line30);
         if (configuration.allowTag(HtmlTag.MAIN)) {
             mainTree.addContent(divContent);
@@ -443,7 +436,7 @@
      */
     @Override
     protected Content getNavLinkHelp() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.helpLabel);
         return li;
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,12 +32,12 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import com.sun.javadoc.PackageDoc;
 import jdk.javadoc.doclet.Doclet.Option;
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.doclet.Reporter;
 import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@@ -65,29 +65,27 @@
         configuration = new ConfigurationImpl();
     }
 
+    @Override // defined by Doclet
+    public String getName() {
+        return "Html";
+    }
+
     /**
      * The global configuration information for this run.
      */
-    public final ConfigurationImpl configuration;
+    private final ConfigurationImpl configuration;
+
+    private Messages messages;
 
 
     private static final DocPath DOCLET_RESOURCES = DocPath
             .create("/jdk/javadoc/internal/doclets/formats/html/resources");
 
+    @Override // defined by Doclet
     public void init(Locale locale, Reporter reporter) {
         configuration.reporter = reporter;
         configuration.locale = locale;
-    }
-
-    /**
-     * The "start" method as required by Javadoc.
-     *
-     * @param docEnv the root of the documentation tree.
-     * @see jdk.doclet.DocletEnvironment
-     * @return true if the doclet ran without encountering any errors.
-     */
-    public boolean run(DocletEnvironment docEnv) {
-        return startDoclet(docEnv);
+        messages = configuration.getMessages();
     }
 
     /**
@@ -95,6 +93,7 @@
      * Override this method to use a different
      * configuration.
      */
+    @Override // defined by AbstractDoclet
     public Configuration configuration() {
         return configuration;
     }
@@ -109,6 +108,7 @@
      *
      * @see jdk.doclet.RootDoc
      */
+    @Override // defined by AbstractDoclet
     protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
             throws Exception {
         super.generateOtherFiles(docEnv, classtree);
@@ -118,8 +118,7 @@
         }
 
         if (configuration.topFile.isEmpty()) {
-            configuration.standardmessage.
-                error("doclet.No_Non_Deprecated_Classes_To_Document");
+            messages.error("doclet.No_Non_Deprecated_Classes_To_Document");
             return;
         }
         boolean nodeprecated = configuration.nodeprecated;
@@ -225,6 +224,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override // defined by AbstractDoclet
     protected void generateClassFiles(SortedSet<TypeElement> arr, ClassTree classtree) {
         List<TypeElement> list = new ArrayList<>(arr);
         ListIterator<TypeElement> iterator = list.listIterator();
@@ -267,6 +267,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override // defined by AbstractDoclet
     protected void generateModuleFiles() throws Exception {
         if (configuration.showModules) {
             ModuleIndexFrameWriter.generate(configuration);
@@ -300,6 +301,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override // defined by AbstractDoclet
     protected void generatePackageFiles(ClassTree classtree) throws Exception {
         Set<PackageElement> packages = configuration.packages;
         if (packages.size() > 1) {
@@ -336,6 +338,7 @@
         }
     }
 
+    @Override // defined by Doclet
     public Set<Option> getSupportedOptions() {
         return configuration.getSupportedOptions();
     }
@@ -351,11 +354,11 @@
             if (toFile.isSameFile(fromfile))
                 return;
 
-            configuration.message.notice("doclet.Copying_File_0_To_File_1",
+            messages.notice("doclet.Copying_File_0_To_File_1",
                     fromfile.toString(), path.getPath());
             toFile.copyFile(fromfile);
         } catch (IOException exc) {
-            configuration.message.error("doclet.perform_copy_exception_encountered",
+            messages.error("doclet.perform_copy_exception_encountered",
                     exc.toString());
             throw new DocletAbortException(exc);
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -82,7 +82,9 @@
 import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
 import jdk.javadoc.internal.doclets.toolkit.taglets.DocRootTaglet;
 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@@ -145,6 +147,12 @@
 
     protected final Utils utils;
 
+    protected final Contents contents;
+
+    protected final Messages messages;
+
+    protected final Resources resources;
+
     /**
      * To check whether annotation heading is printed or not.
      */
@@ -174,10 +182,12 @@
      *
      * @param path File to be generated.
      */
-    public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path)
-            throws IOException {
+    public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path) {
         super(configuration, path);
         this.configuration = configuration;
+        this.contents = configuration.contents;
+        this.messages = configuration.messages;
+        this.resources = configuration.resources;
         this.utils = configuration.utils;
         this.path = path;
         this.pathToRoot = path.parent().invert();
@@ -249,19 +259,19 @@
      */
     public Content getAllClassesLinkScript(String id) {
         HtmlTree script = HtmlTree.SCRIPT();
-        String scriptCode = "<!--" + DocletConstants.NL +
-                "  allClassesLink = document.getElementById(\"" + id + "\");" + DocletConstants.NL +
-                "  if(window==top) {" + DocletConstants.NL +
-                "    allClassesLink.style.display = \"block\";" + DocletConstants.NL +
-                "  }" + DocletConstants.NL +
-                "  else {" + DocletConstants.NL +
-                "    allClassesLink.style.display = \"none\";" + DocletConstants.NL +
-                "  }" + DocletConstants.NL +
-                "  //-->" + DocletConstants.NL;
-        Content scriptContent = new RawHtml(scriptCode);
+        String scriptCode = "<!--\n" +
+                "  allClassesLink = document.getElementById(\"" + id + "\");\n" +
+                "  if(window==top) {\n" +
+                "    allClassesLink.style.display = \"block\";\n" +
+                "  }\n" +
+                "  else {\n" +
+                "    allClassesLink.style.display = \"none\";\n" +
+                "  }\n" +
+                "  //-->\n";
+        Content scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL));
         script.addContent(scriptContent);
         Content div = HtmlTree.DIV(script);
-        Content div_noscript = HtmlTree.DIV(getResource("doclet.No_Script_Message"));
+        Content div_noscript = HtmlTree.DIV(contents.noScriptMessage);
         Content noScript = HtmlTree.NOSCRIPT(div_noscript);
         div.addContent(noScript);
         return div;
@@ -404,7 +414,7 @@
                 HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
                 tdClassDescription.addStyle(HtmlStyle.colLast);
                 if (utils.isDeprecated(te)) {
-                    tdClassDescription.addContent(deprecatedLabel);
+                    tdClassDescription.addContent(contents.deprecatedLabel);
                     List<? extends DocTree> tags = utils.getDeprecatedTrees(te);
                     if (!tags.isEmpty()) {
                         addSummaryDeprecatedComment(te, tags.get(0), tdClassDescription);
@@ -535,7 +545,7 @@
             String allClassesId = "allclasses_";
             HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
             fixedNavDiv.addStyle(HtmlStyle.fixedNav);
-            Content skipNavLinks = configuration.getResource("doclet.Skip_navigation_links");
+            Content skipNavLinks = configuration.getContent("doclet.Skip_navigation_links");
             if (header) {
                 fixedNavDiv.addContent(HtmlConstants.START_OF_TOP_NAVBAR);
                 navDiv.addStyle(HtmlStyle.topNav);
@@ -617,8 +627,9 @@
             if (header && configuration.createindex) {
                 HtmlTree inputText = HtmlTree.INPUT("text", "search");
                 HtmlTree inputReset = HtmlTree.INPUT("reset", "reset");
-                Content searchTxt = configuration.getResource("doclet.search");
-                searchTxt.addContent(getSpace());
+                Content searchTxt = new ContentBuilder();
+                searchTxt.addContent(configuration.getContent("doclet.search"));
+                searchTxt.addContent(Contents.SPACE);
                 HtmlTree liInput = HtmlTree.LI(HtmlTree.SPAN(searchTxt));
                 liInput.addContent(inputText);
                 liInput.addContent(inputReset);
@@ -632,7 +643,7 @@
                 fixedNavDiv.addContent(subDiv);
                 fixedNavDiv.addContent(HtmlConstants.END_OF_TOP_NAVBAR);
                 tree.addContent(fixedNavDiv);
-                HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, getSpace());
+                HtmlTree paddingDiv = HtmlTree.DIV(HtmlStyle.navPadding, Contents.SPACE);
                 tree.addContent(paddingDiv);
             } else {
                 subDiv.addContent(getMarkerAnchor(SectionName.SKIP_NAVBAR_BOTTOM));
@@ -678,7 +689,7 @@
      */
     protected Content getNavLinkContents() {
         Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.OVERVIEW_SUMMARY),
-                overviewLabel, "", "");
+                contents.overviewLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -690,7 +701,7 @@
      * @return a content tree for the link
      */
     protected Content getNavLinkModule(ModuleElement mdle) {
-        Content linkContent = getModuleLink(mdle, moduleLabel);
+        Content linkContent = getModuleLink(mdle, contents.moduleLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -701,7 +712,7 @@
      * @return a content tree for the link
      */
     protected Content getNavLinkModule() {
-        Content li = HtmlTree.LI(moduleLabel);
+        Content li = HtmlTree.LI(contents.moduleLabel);
         return li;
     }
 
@@ -712,7 +723,7 @@
      * @return a content tree for the link
      */
     protected Content getNavLinkPackage(PackageElement pkg) {
-        Content linkContent = getPackageLink(pkg, packageLabel);
+        Content linkContent = getPackageLink(pkg, contents.packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -723,7 +734,7 @@
      * @return a content tree for the link
      */
     protected Content getNavLinkPackage() {
-        Content li = HtmlTree.LI(packageLabel);
+        Content li = HtmlTree.LI(contents.packageLabel);
         return li;
     }
 
@@ -733,7 +744,7 @@
      * @return a content tree for the link
      */
     protected Content getNavLinkClassUse() {
-        Content li = HtmlTree.LI(useLabel);
+        Content li = HtmlTree.LI(contents.useLabel);
         return li;
     }
 
@@ -746,10 +757,10 @@
     public Content getNavLinkPrevious(DocPath prev) {
         Content li;
         if (prev != null) {
-            li = HtmlTree.LI(getHyperLink(prev, prevLabel, "", ""));
+            li = HtmlTree.LI(getHyperLink(prev, contents.prevLabel, "", ""));
         }
         else
-            li = HtmlTree.LI(prevLabel);
+            li = HtmlTree.LI(contents.prevLabel);
         return li;
     }
 
@@ -763,10 +774,10 @@
     public Content getNavLinkNext(DocPath next) {
         Content li;
         if (next != null) {
-            li = HtmlTree.LI(getHyperLink(next, nextLabel, "", ""));
+            li = HtmlTree.LI(getHyperLink(next, contents.nextLabel, "", ""));
         }
         else
-            li = HtmlTree.LI(nextLabel);
+            li = HtmlTree.LI(contents.nextLabel);
         return li;
     }
 
@@ -778,7 +789,7 @@
      */
     protected Content getNavShowLists(DocPath link) {
         DocLink dl = new DocLink(link, path.getPath(), null);
-        Content framesContent = getHyperLink(dl, framesLabel, "", "_top");
+        Content framesContent = getHyperLink(dl, contents.framesLabel, "", "_top");
         Content li = HtmlTree.LI(framesContent);
         return li;
     }
@@ -799,7 +810,7 @@
      * @return a content tree for the link
      */
     protected Content getNavHideLists(DocPath link) {
-        Content noFramesContent = getHyperLink(link, noframesLabel, "", "_top");
+        Content noFramesContent = getHyperLink(link, contents.noFramesLabel, "", "_top");
         Content li = HtmlTree.LI(noFramesContent);
         return li;
     }
@@ -817,7 +828,7 @@
         DocPath docPath = packages.size() == 1 && utils.getSpecifiedClasses().isEmpty()
                 ? pathString(packages.get(0), DocPaths.PACKAGE_TREE)
                 : pathToRoot.resolve(DocPaths.OVERVIEW_TREE);
-        return HtmlTree.LI(getHyperLink(docPath, treeLabel, "", ""));
+        return HtmlTree.LI(getHyperLink(docPath, contents.treeLabel, "", ""));
     }
 
     /**
@@ -839,7 +850,7 @@
      * @return a content tree for the link
      */
     protected Content getNavLinkClass() {
-        Content li = HtmlTree.LI(classLabel);
+        Content li = HtmlTree.LI(contents.classLabel);
         return li;
     }
 
@@ -850,7 +861,7 @@
      */
     protected Content getNavLinkDeprecated() {
         Content linkContent = getHyperLink(pathToRoot.resolve(DocPaths.DEPRECATED_LIST),
-                deprecatedLabel, "", "");
+                contents.deprecatedLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -865,7 +876,7 @@
     protected Content getNavLinkClassIndex() {
         Content allClassesContent = getHyperLink(pathToRoot.resolve(
                 DocPaths.ALLCLASSES_NOFRAME),
-                allclassesLabel, "", "");
+                contents.allClassesLabel, "", "");
         Content li = HtmlTree.LI(allClassesContent);
         return li;
     }
@@ -880,7 +891,7 @@
                 (configuration.splitindex
                     ? DocPaths.INDEX_FILES.resolve(DocPaths.indexN(1))
                     : DocPaths.INDEX_ALL)),
-            indexLabel, "", "");
+            contents.indexLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -902,7 +913,7 @@
             helpfilenm = DocPath.create(file.getName());
         }
         Content linkContent = getHyperLink(pathToRoot.resolve(helpfilenm),
-                helpLabel, "", "");
+                contents.helpLabel, "", "");
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -913,9 +924,9 @@
      * @param liNav the content tree to which the gap will be added
      */
     protected void addNavGap(Content liNav) {
-        liNav.addContent(getSpace());
+        liNav.addContent(Contents.SPACE);
         liNav.addContent("|");
-        liNav.addContent(getSpace());
+        liNav.addContent(Contents.SPACE);
     }
 
     /**
@@ -954,7 +965,7 @@
      */
     public Content getTableCaption(Content title) {
         Content captionSpan = HtmlTree.SPAN(title);
-        Content space = getSpace();
+        Content space = Contents.SPACE;
         Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
         Content caption = HtmlTree.CAPTION(captionSpan);
         caption.addContent(tabSpan);
@@ -1014,7 +1025,7 @@
      */
     public Content getPackageName(PackageElement packageElement) {
         return packageElement == null || packageElement.isUnnamed()
-                ? defaultPackageLabel
+                ? contents.defaultPackageLabel
                 : getPackageLabel(packageElement.getQualifiedName());
     }
 
@@ -1040,7 +1051,7 @@
     protected void addPackageDeprecatedAPI(SortedSet<Element> deprPkgs, String headingKey,
             String tableSummary, List<String> tableHeader, Content contentTree) {
         if (deprPkgs.size() > 0) {
-            Content caption = getTableCaption(configuration.getResource(headingKey));
+            Content caption = getTableCaption(configuration.getContent(headingKey));
             Content table = (configuration.isOutputHtml5())
                     ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption)
                     : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption);
@@ -1551,7 +1562,7 @@
                     return classCrossLink;
                 } else {
                     // No cross link found so print warning
-                    configuration.getDocletSpecificMsg().warning(ch.getDocTreePath(see),
+                    messages.warning(ch.getDocTreePath(see),
                             "doclet.see.class_or_package_not_found",
                             "@" + tagName,
                             seetext);
@@ -1594,11 +1605,11 @@
                 if (this instanceof ClassWriterImpl) {
                     containing = ((ClassWriterImpl) this).getTypeElement();
                 } else if (!utils.isPublic(containing)) {
-                    configuration.getDocletSpecificMsg().warning(
+                    messages.warning(
                         ch.getDocTreePath(see), "doclet.see.class_or_package_not_accessible",
                         tagName, utils.getFullyQualifiedName(containing));
                 } else {
-                    configuration.getDocletSpecificMsg().warning(
+                    messages.warning(
                         ch.getDocTreePath(see), "doclet.see.class_or_package_not_found",
                         tagName, seetext);
                 }
@@ -1728,7 +1739,7 @@
             htmltree.addContent(div);
         }
         if (tags.isEmpty()) {
-            htmltree.addContent(getSpace());
+            htmltree.addContent(Contents.SPACE);
         }
     }
 
@@ -1917,7 +1928,7 @@
 
                 @Override @DefinedBy(Api.COMPILER_TREE)
                 public Boolean visitErroneous(ErroneousTree node, Content c) {
-                    configuration.getDocletSpecificMsg().warning(ch.getDocTreePath(node),
+                    messages.warning(ch.getDocTreePath(node),
                             "doclet.tag.invalid_usage", node);
                     result.addContent(new RawHtml(node.toString()));
                     return false;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/MethodWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,8 +25,6 @@
 
 package jdk.javadoc.internal.doclets.formats.html;
 
-import java.io.*;
-
 import java.util.Arrays;
 import java.util.List;
 import java.util.SortedSet;
@@ -111,7 +109,7 @@
         methodDetailsTree.addContent(writer.getMarkerAnchor(
                 SectionName.METHOD_DETAIL));
         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
-                writer.methodDetailsLabel);
+                contents.methodDetailLabel);
         methodDetailsTree.addContent(heading);
         return methodDetailsTree;
     }
@@ -190,9 +188,9 @@
                 Content codelLink = HtmlTree.CODE(link);
                 Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
                         utils.isClass(holder)
-                                ? writer.descfrmClassLabel
-                                : writer.descfrmInterfaceLabel);
-                descfrmLabel.addContent(writer.getSpace());
+                                ? contents.descfrmClassLabel
+                                : contents.descfrmInterfaceLabel);
+                descfrmLabel.addContent(Contents.SPACE);
                 descfrmLabel.addContent(codelLink);
                 methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
                 writer.addInlineComment(method, methodDocTree);
@@ -230,20 +228,12 @@
     }
 
     /**
-     * Close the writer.
-     */
-    @Override
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Method_Summary"));
+                contents.methodSummary);
         memberTree.addContent(label);
     }
 
@@ -252,9 +242,9 @@
      */
     @Override
     public String getTableSummary() {
-        return configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Method_Summary"),
-                configuration.getText("doclet.methods"));
+        return resources.getText("doclet.Member_Table_Summary",
+                resources.getText("doclet.Method_Summary"),
+                resources.getText("doclet.methods"));
     }
 
     /**
@@ -262,7 +252,7 @@
      */
     @Override
     public Content getCaption() {
-        return configuration.getResource("doclet.Methods");
+        return contents.methods;
     }
 
     /**
@@ -271,9 +261,9 @@
     @Override
     public List<String> getSummaryTableHeader(Element member) {
         List<String> header = Arrays.asList(writer.getModifierTypeHeader(),
-        configuration.getText("doclet.0_and_1",
-                   configuration.getText("doclet.Method"),
-                   configuration.getText("doclet.Description")));
+                resources.getText("doclet.0_and_1",
+                        resources.getText("doclet.Method"),
+                        resources.getText("doclet.Description")));
         return header;
     }
 
@@ -307,7 +297,7 @@
                 : configuration.getText("doclet.Methods_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
-        labelHeading.addContent(writer.getSpace());
+        labelHeading.addContent(Contents.SPACE);
         labelHeading.addContent(classLink);
         inheritedTree.addContent(labelHeading);
     }
@@ -329,7 +319,8 @@
         if (writer.configuration.nocomment) {
             return;
         }
-        Utils utils = writer.configuration().utils;
+        Utils utils = writer.utils;
+        Contents contents = writer.contents;
         TypeElement holder = utils.getEnclosingTypeElement(method);
         if (!(utils.isPublic(holder) ||
             utils.isLinkable(holder))) {
@@ -341,14 +332,14 @@
             //is not visible so don't document this.
             return;
         }
-        Content label = writer.overridesLabel;
+        Content label = contents.overridesLabel;
         LinkInfoImpl.Kind context = LinkInfoImpl.Kind.METHOD_OVERRIDES;
 
         if (method != null) {
             if (utils.isAbstract(holder) && utils.isAbstract(method)){
                 //Abstract method is implemented from abstract class,
                 //not overridden
-                label = writer.specifiedByLabel;
+                label = contents.specifiedByLabel;
                 context = LinkInfoImpl.Kind.METHOD_SPECIFIED_BY;
             }
             Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, label));
@@ -362,9 +353,9 @@
                     .where(writer.getName(writer.getAnchor(method))).label(method.getSimpleName()));
             Content codeMethLink = HtmlTree.CODE(methlink);
             Content dd = HtmlTree.DD(codeMethLink);
-            dd.addContent(writer.getSpace());
-            dd.addContent(writer.getResource("doclet.in_class"));
-            dd.addContent(writer.getSpace());
+            dd.addContent(Contents.SPACE);
+            dd.addContent(writer.contents.inClass);
+            dd.addContent(Contents.SPACE);
             dd.addContent(codeOverridenTypeLink);
             dl.addContent(dd);
         }
@@ -379,6 +370,7 @@
             return;
         }
         Utils utils = writer.utils;
+        Contents contents = writer.contents;
         ImplementedMethods implementedMethodsFinder =
                 new ImplementedMethods(method, writer.configuration);
         SortedSet<ExecutableElement> implementedMethods =
@@ -390,16 +382,16 @@
             Content intfaclink = writer.getLink(new LinkInfoImpl(
                     writer.configuration, LinkInfoImpl.Kind.METHOD_SPECIFIED_BY, intfac));
             Content codeIntfacLink = HtmlTree.CODE(intfaclink);
-            Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, writer.specifiedByLabel));
+            Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.overrideSpecifyLabel, contents.specifiedByLabel));
             dl.addContent(dt);
             Content methlink = writer.getDocLink(
                     LinkInfoImpl.Kind.MEMBER, implementedMeth,
                     implementedMeth.getSimpleName(), false);
             Content codeMethLink = HtmlTree.CODE(methlink);
             Content dd = HtmlTree.DD(codeMethLink);
-            dd.addContent(writer.getSpace());
-            dd.addContent(writer.getResource("doclet.in_interface"));
-            dd.addContent(writer.getSpace());
+            dd.addContent(Contents.SPACE);
+            dd.addContent(contents.inInterface);
+            dd.addContent(Contents.SPACE);
             dd.addContent(codeIntfacLink);
             dl.addContent(dd);
         }
@@ -417,7 +409,7 @@
             Content linkContent = writer.getLink(
                     new LinkInfoImpl(configuration, LinkInfoImpl.Kind.RETURN_TYPE, type));
             htmltree.addContent(linkContent);
-            htmltree.addContent(writer.getSpace());
+            htmltree.addContent(Contents.SPACE);
         }
     }
 
@@ -430,14 +422,14 @@
             if (typeElement == null) {
                 return writer.getHyperLink(
                         SectionName.METHOD_SUMMARY,
-                        writer.getResource("doclet.navMethod"));
+                        contents.navMethod);
             } else {
                 return writer.getHyperLink(
                         SectionName.METHODS_INHERITANCE,
-                        configuration.getClassName(typeElement), writer.getResource("doclet.navMethod"));
+                        configuration.getClassName(typeElement), contents.navMethod);
             }
         } else {
-            return writer.getResource("doclet.navMethod");
+            return contents.navMethod;
         }
     }
 
@@ -448,9 +440,9 @@
     protected void addNavDetailLink(boolean link, Content liNav) {
         if (link) {
             liNav.addContent(writer.getHyperLink(
-                    SectionName.METHOD_DETAIL, writer.getResource("doclet.navMethod")));
+                    SectionName.METHOD_DETAIL, contents.navMethod));
         } else {
-            liNav.addContent(writer.getResource("doclet.navMethod"));
+            liNav.addContent(contents.navMethod);
         }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -60,7 +60,7 @@
     /**
      * The module being documented.
      */
-    private ModuleElement mdle;
+    private final ModuleElement mdle;
 
     /**
      * The classes to be documented.  Use this to filter out classes
@@ -114,9 +114,8 @@
             }
             mdlgen.printHtmlDocument(
                     configuration.metakeywords.getMetaKeywordsForModule(moduleElement), false, body);
-            mdlgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
+            configuration.messages.error(
                     "doclet.exception_encountered",
                     exc.toString(), DocPaths.moduleTypeFrame(moduleElement).getPath());
             throw new DocletAbortException(exc);
@@ -148,12 +147,12 @@
                 annotationTypes.addAll(utils.getAnnotationTypes(pkg));
             }
         }
-        addClassKindListing(interfaces, getResource("doclet.Interfaces"), contentTree);
-        addClassKindListing(classes, getResource("doclet.Classes"), contentTree);
-        addClassKindListing(enums, getResource("doclet.Enums"), contentTree);
-        addClassKindListing(exceptions, getResource("doclet.Exceptions"), contentTree);
-        addClassKindListing(errors, getResource("doclet.Errors"), contentTree);
-        addClassKindListing(annotationTypes, getResource("doclet.AnnotationTypes"), contentTree);
+        addClassKindListing(interfaces, contents.interfaces, contentTree);
+        addClassKindListing(classes, contents.classes, contentTree);
+        addClassKindListing(enums, contents.enums, contentTree);
+        addClassKindListing(exceptions, contents.exceptions, contentTree);
+        addClassKindListing(errors, contents.errors, contentTree);
+        addClassKindListing(annotationTypes, contents.annotationTypes, contentTree);
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -39,6 +39,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -79,10 +80,9 @@
         try {
             modulegen = new ModuleIndexFrameWriter(configuration, filename);
             modulegen.buildModuleIndexFile("doclet.Window_Overview", false);
-            modulegen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -94,12 +94,12 @@
     protected void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
             String tableSummary, Content body) {
         Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true,
-                modulesLabel);
+                contents.modulesLabel);
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                 ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
                 : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(modulesLabel);
+        ul.setTitle(contents.modulesLabel);
         for (ModuleElement mdle: modules.keySet()) {
             ul.addContent(getModuleLink(mdle));
         }
@@ -150,7 +150,7 @@
      */
     protected void addAllClassesLink(Content ul) {
         Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
-                allclassesLabel, "", "packageFrame");
+                contents.allClassesLabel, "", "packageFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
     }
@@ -163,7 +163,7 @@
      */
     protected void addAllPackagesLink(Content ul) {
         Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME,
-                allpackagesLabel, "", "packageListFrame");
+                contents.allPackagesLabel, "", "packageListFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
     }
@@ -172,7 +172,7 @@
      * {@inheritDoc}
      */
     protected void addNavigationBarFooter(Content body) {
-        Content p = HtmlTree.P(getSpace());
+        Content p = HtmlTree.P(Contents.SPACE);
         body.addContent(p);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,12 +32,14 @@
 import javax.lang.model.element.PackageElement;
 
 import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -90,9 +92,9 @@
         try {
             mdlgen = new ModuleIndexWriter(configuration, filename);
             mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", true);
-            mdlgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
+            Messages messages = configuration.getMessages();
+            messages.error(
                         "doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
@@ -195,12 +197,13 @@
             subTitleDiv.addStyle(HtmlStyle.subTitle);
             addSummaryComment(configuration.overviewElement, subTitleDiv);
             Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
-            Content see = seeLabel;
+            Content see = new ContentBuilder();
+            see.addContent(contents.seeLabel);
             see.addContent(" ");
             Content descPara = HtmlTree.P(see);
             Content descLink = getHyperLink(getDocLink(
                     SectionName.OVERVIEW_DESCRIPTION),
-                    descriptionLabel, "", "");
+                    contents.descriptionLabel, "", "");
             descPara.addContent(descLink);
             div.addContent(descPara);
             if (configuration.allowTag(HtmlTag.MAIN)) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -41,6 +41,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -82,10 +83,9 @@
         try {
             modpackgen = new ModulePackageIndexFrameWriter(configuration, filename);
             modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle);
-            modpackgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -99,13 +99,13 @@
         Content profNameContent = new StringContent(mdle.getQualifiedName().toString());
         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
                 getTargetModuleLink("classFrame", profNameContent, mdle));
-        heading.addContent(getSpace());
-        heading.addContent(packagesLabel);
+        heading.addContent(Contents.SPACE);
+        heading.addContent(contents.packagesLabel);
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                 ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
                 : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(packagesLabel);
+        ul.setTitle(contents.packagesLabel);
         List<PackageElement> packages = new ArrayList<>(modules.get(mdle));
         for (PackageElement pkg : packages) {
             if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
@@ -124,13 +124,13 @@
         Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString());
         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
                 getTargetModuleLink("classFrame", moduleNameContent, mdle));
-        heading.addContent(getSpace());
-        heading.addContent(packagesLabel);
+        heading.addContent(Contents.SPACE);
+        heading.addContent(contents.packagesLabel);
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                 ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
                 : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(packagesLabel);
+        ul.setTitle(contents.packagesLabel);
         Set<PackageElement> modulePackages = configuration.modulePackages.get(mdle);
         for (PackageElement pkg: modulePackages) {
             if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
@@ -198,7 +198,7 @@
      */
     protected void addAllClassesLink(Content ul) {
         Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
-                allclassesLabel, "", "packageFrame");
+                contents.allClassesLabel, "", "packageFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
     }
@@ -211,7 +211,7 @@
      */
     protected void addAllPackagesLink(Content ul) {
         Content linkContent = getHyperLink(DocPaths.OVERVIEW_FRAME,
-                allpackagesLabel, "", "packageListFrame");
+                contents.allPackagesLabel, "", "packageListFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
     }
@@ -224,7 +224,7 @@
      */
     protected void addAllModulesLink(Content ul) {
         Content linkContent = getHyperLink(DocPaths.MODULE_OVERVIEW_FRAME,
-                allmodulesLabel, "", "packageListFrame");
+                contents.allModulesLabel, "", "packageListFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
     }
@@ -233,7 +233,7 @@
      * {@inheritDoc}
      */
     protected void addNavigationBarFooter(Content body) {
-        Content p = HtmlTree.P(getSpace());
+        Content p = HtmlTree.P(Contents.SPACE);
         body.addContent(p);
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -102,8 +102,7 @@
      * @param nextModule   Next module in the sorted array.
      */
     public ModuleWriterImpl(ConfigurationImpl configuration,
-            ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule)
-            throws IOException {
+            ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule) {
         super(configuration, DocPaths.moduleSummary(mdle));
         this.prevModule = prevModule;
         this.nextModule = nextModule;
@@ -129,8 +128,8 @@
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.addStyle(HtmlStyle.header);
         Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
-                HtmlStyle.title, moduleLabel);
-        tHeading.addContent(getSpace());
+                HtmlStyle.title, contents.moduleLabel);
+        tHeading.addContent(Contents.SPACE);
         Content moduleHead = new RawHtml(heading);
         tHeading.addContent(moduleHead);
         div.addContent(tHeading);
@@ -262,7 +261,7 @@
             HtmlTree li = new HtmlTree(HtmlTag.LI);
             li.addStyle(HtmlStyle.blockList);
             addSummaryHeader(HtmlConstants.START_OF_MODULES_SUMMARY, SectionName.MODULES,
-                    getResource("doclet.navModules"), li);
+                    contents.navModules, li);
             String text = configuration.getText("doclet.Requires_Summary");
             String tableSummary = configuration.getText("doclet.Member_Table_Summary",
                     configuration.getText("doclet.Requires_Summary"),
@@ -315,7 +314,7 @@
             HtmlTree li = new HtmlTree(HtmlTag.LI);
             li.addStyle(HtmlStyle.blockList);
             addSummaryHeader(HtmlConstants.START_OF_PACKAGES_SUMMARY, SectionName.PACKAGES,
-                    getResource("doclet.navPackages"), li);
+                    contents.navPackages, li);
             String text = configuration.getText("doclet.Exported_Packages_Summary");
             String tableSummary = configuration.getText("doclet.Member_Table_Summary",
                     configuration.getText("doclet.Exported_Packages_Summary"),
@@ -385,7 +384,7 @@
             HtmlTree li = new HtmlTree(HtmlTag.LI);
             li.addStyle(HtmlStyle.blockList);
             addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES,
-                    getResource("doclet.navServices"), li);
+                    contents.navServices, li);
             String text;
             String tableSummary;
             if (usesDirs != null && !usesDirs.isEmpty()) {
@@ -468,9 +467,9 @@
         HtmlTree tdType = HtmlTree.TD(HtmlStyle.colFirst, srvLinkContent);
         tdType.addContent(new HtmlTree(HtmlTag.BR));
         tdType.addContent("(");
-        HtmlTree implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, getResource("doclet.Implementation"));
+        HtmlTree implSpan = HtmlTree.SPAN(HtmlStyle.implementationLabel, contents.implementation);
         tdType.addContent(implSpan);
-        tdType.addContent(getSpace());
+        tdType.addContent(Contents.SPACE);
         tdType.addContent(implLinkContent);
         tdType.addContent(")");
         HtmlTree tdDesc = new HtmlTree(HtmlTag.TD);
@@ -530,25 +529,25 @@
      * @return the content tree for the navigation summary links
      */
     protected Content getNavSummaryLinks() throws Exception {
-        Content li = HtmlTree.LI(moduleSubNavLabel);
-        li.addContent(getSpace());
+        Content li = HtmlTree.LI(contents.moduleSubNavLabel);
+        li.addContent(Contents.SPACE);
         Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
         Content liNav = new HtmlTree(HtmlTag.LI);
         liNav.addContent(!utils.getBody(mdle).isEmpty() && !configuration.nocomment
-                ? getHyperLink(SectionName.MODULE_DESCRIPTION, getResource("doclet.navModuleDescription"))
-                : getResource("doclet.navModuleDescription"));
+                ? getHyperLink(SectionName.MODULE_DESCRIPTION, contents.navModuleDescription)
+                : contents.navModuleDescription);
         addNavGap(liNav);
         liNav.addContent(showDirectives(DirectiveKind.REQUIRES)
-                ? getHyperLink(SectionName.MODULES, getResource("doclet.navModules"))
-                : getResource("doclet.navModules"));
+                ? getHyperLink(SectionName.MODULES, contents.navModules)
+                : contents.navModules);
         addNavGap(liNav);
         liNav.addContent(showDirectives(DirectiveKind.EXPORTS)
-                ? getHyperLink(SectionName.PACKAGES, getResource("doclet.navPackages"))
-                : getResource("doclet.navPackages"));
+                ? getHyperLink(SectionName.PACKAGES, contents.navPackages)
+                : contents.navPackages);
         addNavGap(liNav);
         liNav.addContent((showDirectives(DirectiveKind.USES) || showDirectives(DirectiveKind.PROVIDES))
-                ? getHyperLink(SectionName.SERVICES, getResource("doclet.navServices"))
-                : getResource("doclet.navServices"));
+                ? getHyperLink(SectionName.SERVICES, contents.navServices)
+                : contents.navServices);
         ulNav.addContent(liNav);
         return ulNav;
     }
@@ -609,7 +608,7 @@
             deprs = utils.getDeprecatedTrees(pkg);
             HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
             deprDiv.addStyle(HtmlStyle.deprecatedContent);
-            Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+            Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
             deprDiv.addContent(deprPhrase);
             if (!deprs.isEmpty()) {
                 CommentHelper ch = utils.getCommentHelper(pkg);
@@ -629,7 +628,7 @@
      */
     @Override
     protected Content getNavLinkModule() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, moduleLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.moduleLabel);
         return li;
     }
 
@@ -641,10 +640,10 @@
     public Content getNavLinkPrevious() {
         Content li;
         if (prevModule == null) {
-            li = HtmlTree.LI(prevmoduleLabel);
+            li = HtmlTree.LI(contents.prevModuleLabel);
         } else {
             li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.moduleSummary(
-                    prevModule)), prevmoduleLabel, "", ""));
+                    prevModule)), contents.prevModuleLabel, "", ""));
         }
         return li;
     }
@@ -657,10 +656,10 @@
     public Content getNavLinkNext() {
         Content li;
         if (nextModule == null) {
-            li = HtmlTree.LI(nextmoduleLabel);
+            li = HtmlTree.LI(contents.nextModuleLabel);
         } else {
             li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.moduleSummary(
-                    nextModule)), nextmoduleLabel, "", ""));
+                    nextModule)), contents.nextModuleLabel, "", ""));
         }
         return li;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/NestedClassWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -84,20 +84,12 @@
     }
 
     /**
-     * Close the writer.
-     */
-    @Override
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Nested_Class_Summary"));
+                contents.nestedClassSummary);
         memberTree.addContent(label);
     }
 
@@ -106,9 +98,9 @@
      */
     @Override
     public String getTableSummary() {
-        return configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Nested_Class_Summary"),
-                configuration.getText("doclet.nested_classes"));
+        return resources.getText("doclet.Member_Table_Summary",
+                resources.getText("doclet.Nested_Class_Summary"),
+                resources.getText("doclet.nested_classes"));
     }
 
     /**
@@ -116,7 +108,7 @@
      */
     @Override
     public Content getCaption() {
-        return configuration.getResource("doclet.Nested_Classes");
+        return configuration.getContent("doclet.Nested_Classes");
     }
 
     /**
@@ -169,7 +161,7 @@
                 : configuration.getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
-        labelHeading.addContent(writer.getSpace());
+        labelHeading.addContent(Contents.SPACE);
         labelHeading.addContent(classLink);
         inheritedTree.addContent(labelHeading);
     }
@@ -221,14 +213,14 @@
             if (typeElement == null) {
                 return writer.getHyperLink(
                         SectionName.NESTED_CLASS_SUMMARY,
-                        writer.getResource("doclet.navNested"));
+                        contents.navNested);
             } else {
                 return writer.getHyperLink(
                         SectionName.NESTED_CLASSES_INHERITANCE,
-                        utils.getFullyQualifiedName(typeElement), writer.getResource("doclet.navNested"));
+                        utils.getFullyQualifiedName(typeElement), contents.navNested);
             }
         } else {
-            return writer.getResource("doclet.navNested");
+            return contents.navNested;
         }
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -38,6 +38,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -80,8 +81,7 @@
      * @param configuration the configuration of the doclet.
      * @param packageElement PackageElement under consideration.
      */
-    public PackageFrameWriter(ConfigurationImpl configuration, PackageElement packageElement)
-            throws IOException {
+    public PackageFrameWriter(ConfigurationImpl configuration, PackageElement packageElement) {
         super(configuration, DocPath.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME));
         this.packageElement = packageElement;
         if (utils.getSpecifiedPackages().isEmpty()) {
@@ -119,10 +119,9 @@
             }
             packgen.printHtmlDocument(
                     configuration.metakeywords.getMetaKeywords(packageElement), false, body);
-            packgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                    "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                     exc.toString(), DocPaths.PACKAGE_FRAME.getPath());
             throw new DocletAbortException(exc);
         }
@@ -139,30 +138,30 @@
         Configuration config = configuration;
         if (utils.isIncluded(packageElement)) {
             addClassKindListing(utils.getInterfaces(packageElement),
-                getResource("doclet.Interfaces"), contentTree);
+                contents.interfaces, contentTree);
             addClassKindListing(utils.getOrdinaryClasses(packageElement),
-                getResource("doclet.Classes"), contentTree);
+                contents.classes, contentTree);
             addClassKindListing(utils.getEnums(packageElement),
-                getResource("doclet.Enums"), contentTree);
+                contents.enums, contentTree);
             addClassKindListing(utils.getExceptions(packageElement),
-                getResource("doclet.Exceptions"), contentTree);
+                contents.exceptions, contentTree);
             addClassKindListing(utils.getErrors(packageElement),
-                getResource("doclet.Errors"), contentTree);
+                contents.errors, contentTree);
             addClassKindListing(utils.getAnnotationTypes(packageElement),
-                getResource("doclet.AnnotationTypes"), contentTree);
+                contents.annotationTypes, contentTree);
         } else {
             addClassKindListing(config.typeElementCatalog.interfaces(packageElement),
-                getResource("doclet.Interfaces"), contentTree);
+                contents.interfaces, contentTree);
             addClassKindListing(config.typeElementCatalog.ordinaryClasses(packageElement),
-                getResource("doclet.Classes"), contentTree);
+                contents.classes, contentTree);
             addClassKindListing(config.typeElementCatalog.enums(packageElement),
-                getResource("doclet.Enums"), contentTree);
+                contents.enums, contentTree);
             addClassKindListing(config.typeElementCatalog.exceptions(packageElement),
-                getResource("doclet.Exceptions"), contentTree);
+                contents.exceptions, contentTree);
             addClassKindListing(config.typeElementCatalog.errors(packageElement),
-                getResource("doclet.Errors"), contentTree);
+                contents.errors, contentTree);
             addClassKindListing(config.typeElementCatalog.annotationTypes(packageElement),
-                getResource("doclet.AnnotationTypes"), contentTree);
+                contents.annotationTypes, contentTree);
         }
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -37,6 +37,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -76,10 +77,9 @@
         try {
             packgen = new PackageIndexFrameWriter(configuration, filename);
             packgen.buildPackageIndexFile("doclet.Window_Overview", false);
-            packgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -91,12 +91,12 @@
     protected void addPackagesList(Collection<PackageElement> packages, String text,
             String tableSummary, Content body) {
         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
-                packagesLabel);
+                contents.packagesLabel);
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                 ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
                 : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
         HtmlTree ul = new HtmlTree(HtmlTag.UL);
-        ul.setTitle(packagesLabel);
+        ul.setTitle(contents.packagesLabel);
         for (PackageElement aPackage : packages) {
             // Do not list the package if -nodeprecated option is set and the
             // package is marked as deprecated.
@@ -161,7 +161,7 @@
      */
     protected void addAllClassesLink(Content ul) {
         Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME,
-                allclassesLabel, "", "packageFrame");
+                contents.allClassesLabel, "", "packageFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
     }
@@ -174,7 +174,7 @@
      */
     protected void addAllModulesLink(Content ul) {
         Content linkContent = getHyperLink(DocPaths.MODULE_OVERVIEW_FRAME,
-                allmodulesLabel, "", "packageListFrame");
+                contents.allModulesLabel, "", "packageListFrame");
         Content li = HtmlTree.LI(linkContent);
         ul.addContent(li);
     }
@@ -183,7 +183,7 @@
      * {@inheritDoc}
      */
     protected void addNavigationBarFooter(Content body) {
-        Content p = HtmlTree.P(getSpace());
+        Content p = HtmlTree.P(Contents.SPACE);
         body.addContent(p);
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,11 +31,13 @@
 import javax.lang.model.element.PackageElement;
 
 import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -103,10 +105,9 @@
         try {
             packgen = new PackageIndexWriter(configuration, filename);
             packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
-            packgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -189,12 +190,13 @@
             subTitleDiv.addStyle(HtmlStyle.subTitle);
             addSummaryComment(configuration.overviewElement, subTitleDiv);
             Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
-            Content see = seeLabel;
-            see.addContent(" ");
-            Content descPara = HtmlTree.P(see);
+            Content descBody = new ContentBuilder();
+            descBody.addContent(contents.seeLabel);
+            descBody.addContent(" ");
+            Content descPara = HtmlTree.P(descBody);
             Content descLink = getHyperLink(getDocLink(
                     SectionName.OVERVIEW_DESCRIPTION),
-                    descriptionLabel, "", "");
+                    contents.descriptionLabel, "", "");
             descPara.addContent(descLink);
             div.addContent(descPara);
             if (configuration.allowTag(HtmlTag.MAIN)) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -34,6 +34,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
@@ -112,10 +113,9 @@
             packgen = new PackageTreeWriter(configuration, path, pkg,
                 prev, next);
             packgen.generatePackageTreeFile();
-            packgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), path.getPath());
             throw new DocletAbortException(exc);
         }
@@ -130,7 +130,7 @@
         HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                 ? HtmlTree.MAIN()
                 : body;
-        Content headContent = getResource("doclet.Hierarchy_For_Package",
+        Content headContent = contents.getContent("doclet.Hierarchy_For_Package",
                 utils.getPackageName(packageElement));
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
                 HtmlStyle.title, headContent);
@@ -187,7 +187,7 @@
      */
     protected void addLinkToMainTree(Content div) {
         Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
-                getResource("doclet.Package_Hierarchies"));
+                contents.packageHierarchies);
         div.addContent(span);
         HtmlTree ul = new HtmlTree (HtmlTag.UL);
         ul.addStyle(HtmlStyle.horizontal);
@@ -231,7 +231,7 @@
     @Override
     protected Content getNavLinkModule() {
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
-                moduleLabel);
+                contents.moduleLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -243,7 +243,7 @@
      */
     protected Content getNavLinkPackage() {
         Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
-                packageLabel);
+                contents.packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -38,6 +38,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
@@ -108,11 +109,9 @@
         try {
             pkgusegen = new PackageUseWriter(configuration, mapper, filename, pkgElement);
             pkgusegen.generatePackageUseFile();
-            pkgusegen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                "doclet.exception_encountered",
-                exc.toString(), filename);
+            Messages messages = configuration.getMessages();
+            messages.error(exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
     }
@@ -125,7 +124,7 @@
         HtmlTree div = new HtmlTree(HtmlTag.DIV);
         div.addStyle(HtmlStyle.contentContainer);
         if (usingPackageToUsedClasses.isEmpty()) {
-            div.addContent(getResource("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement)));
+            div.addContent(contents.getContent("doclet.ClassUse_No.usage.of.0", utils.getPackageName(packageElement)));
         } else {
             addPackageUse(div);
         }
@@ -167,7 +166,7 @@
      * @param contentTree the content tree to which the package list will be added
      */
     protected void addPackageList(Content contentTree) throws IOException {
-        Content caption = getTableCaption(configuration.getResource(
+        Content caption = getTableCaption(configuration.getContent(
                 "doclet.ClassUse_Packages.that.use.0",
                 getPackageLink(packageElement, utils.getPackageName(packageElement))));
         Content table = (configuration.isOutputHtml5())
@@ -208,7 +207,7 @@
             }
             String tableSummary = configuration.getText("doclet.Use_Table_Summary",
                                                         configuration.getText("doclet.classes"));
-            Content caption = getTableCaption(configuration.getResource(
+            Content caption = getTableCaption(configuration.getContent(
                     "doclet.ClassUse_Classes.in.0.used.by.1",
                     getPackageLink(packageElement, utils.getPackageName(packageElement)),
                     getPackageLink(usingPackage, utils.getPackageName(usingPackage))));
@@ -265,7 +264,7 @@
         if (pkg != null && !pkg.isUnnamed()) {
             addSummaryComment(pkg, tdLast);
         } else {
-            tdLast.addContent(getSpace());
+            tdLast.addContent(Contents.SPACE);
         }
         contentTree.addContent(tdLast);
     }
@@ -289,7 +288,7 @@
             bodyTree.addContent(htmlTree);
         }
         ContentBuilder headContent = new ContentBuilder();
-        headContent.addContent(getResource("doclet.ClassUse_Title", packageText));
+        headContent.addContent(contents.getContent("doclet.ClassUse_Title", packageText));
         headContent.addContent(new HtmlTree(HtmlTag.BR));
         headContent.addContent(name);
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
@@ -311,7 +310,7 @@
     @Override
     protected Content getNavLinkModule() {
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
-                moduleLabel);
+                contents.moduleLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -323,7 +322,7 @@
      */
     protected Content getNavLinkPackage() {
         Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY,
-                packageLabel);
+                contents.packageLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -334,7 +333,7 @@
      * @return a content tree for the use link
      */
     protected Content getNavLinkClassUse() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel);
         return li;
     }
 
@@ -345,7 +344,7 @@
      */
     protected Content getNavLinkTree() {
         Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE,
-                treeLabel);
+                contents.treeLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -100,8 +100,7 @@
      * @param next            Next package in the sorted array.
      */
     public PackageWriterImpl(ConfigurationImpl configuration,
-            PackageElement packageElement, PackageElement prev, PackageElement next)
-            throws IOException {
+            PackageElement packageElement, PackageElement prev, PackageElement next) {
         super(configuration, DocPath
                 .forPackage(packageElement)
                 .resolve(DocPaths.PACKAGE_SUMMARY));
@@ -127,9 +126,9 @@
         div.addStyle(HtmlStyle.header);
         ModuleElement mdle = configuration.docEnv.getElementUtils().getModuleOf(packageElement);
         if (mdle != null && !mdle.isUnnamed()) {
-            Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, moduleLabel);
+            Content classModuleLabel = HtmlTree.SPAN(HtmlStyle.moduleLabelInClass, contents.moduleLabel);
             Content moduleNameDiv = HtmlTree.DIV(HtmlStyle.subTitle, classModuleLabel);
-            moduleNameDiv.addContent(getSpace());
+            moduleNameDiv.addContent(Contents.SPACE);
             moduleNameDiv.addContent(getModuleLink(mdle,
                     new StringContent(mdle.getQualifiedName().toString())));
             div.addContent(moduleNameDiv);
@@ -138,8 +137,8 @@
         addAnnotationInfo(packageElement, annotationContent);
         div.addContent(annotationContent);
         Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
-                HtmlStyle.title, packageLabel);
-        tHeading.addContent(getSpace());
+                HtmlStyle.title, contents.packageLabel);
+        tHeading.addContent(Contents.SPACE);
         Content packageHead = new StringContent(heading);
         tHeading.addContent(packageHead);
         div.addContent(tHeading);
@@ -149,11 +148,11 @@
             docSummaryDiv.addStyle(HtmlStyle.docSummary);
             addSummaryComment(packageElement, docSummaryDiv);
             div.addContent(docSummaryDiv);
-            Content space = getSpace();
+            Content space = Contents.SPACE;
             Content descLink = getHyperLink(getDocLink(
                     SectionName.PACKAGE_DESCRIPTION),
-                    descriptionLabel, "", "");
-            Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
+                    contents.descriptionLabel, "", "");
+            Content descPara = new HtmlTree(HtmlTag.P, contents.seeLabel, space, descLink);
             div.addContent(descPara);
         }
         if (configuration.allowTag(HtmlTag.MAIN)) {
@@ -184,7 +183,7 @@
             CommentHelper ch = utils.getCommentHelper(packageElement);
             HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV);
             deprDiv.addStyle(HtmlStyle.deprecatedContent);
-            Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+            Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
             deprDiv.addContent(deprPhrase);
             if (!deprs.isEmpty()) {
                 List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0));
@@ -233,7 +232,7 @@
                 HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
                 tdClassDescription.addStyle(HtmlStyle.colLast);
                 if (utils.isDeprecated(klass)) {
-                    tdClassDescription.addContent(deprecatedLabel);
+                    tdClassDescription.addContent(contents.deprecatedLabel);
                     List<? extends DocTree> tags = utils.getDeprecatedTrees(klass);
                     if (!tags.isEmpty()) {
                         addSummaryDeprecatedComment(klass, tags.get(0), tdClassDescription);
@@ -323,7 +322,7 @@
      */
     protected Content getNavLinkClassUse() {
         Content useLink = getHyperLink(DocPaths.PACKAGE_USE,
-                useLabel, "", "");
+                contents.useLabel, "", "");
         Content li = HtmlTree.LI(useLink);
         return li;
     }
@@ -336,11 +335,11 @@
     public Content getNavLinkPrevious() {
         Content li;
         if (prev == null) {
-            li = HtmlTree.LI(prevpackageLabel);
+            li = HtmlTree.LI(contents.prevPackageLabel);
         } else {
             DocPath path = DocPath.relativePath(packageElement, prev);
             li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
-                prevpackageLabel, "", ""));
+                contents.prevPackageLabel, "", ""));
         }
         return li;
     }
@@ -353,11 +352,11 @@
     public Content getNavLinkNext() {
         Content li;
         if (next == null) {
-            li = HtmlTree.LI(nextpackageLabel);
+            li = HtmlTree.LI(contents.nextPackageLabel);
         } else {
             DocPath path = DocPath.relativePath(packageElement, next);
             li = HtmlTree.LI(getHyperLink(path.resolve(DocPaths.PACKAGE_SUMMARY),
-                nextpackageLabel, "", ""));
+                contents.nextPackageLabel, "", ""));
         }
         return li;
     }
@@ -370,7 +369,7 @@
      */
     protected Content getNavLinkTree() {
         Content useLink = getHyperLink(DocPaths.PACKAGE_TREE,
-                treeLabel, "", "");
+                contents.treeLabel, "", "");
         Content li = HtmlTree.LI(useLink);
         return li;
     }
@@ -383,7 +382,7 @@
     @Override
     protected Content getNavLinkModule() {
         Content linkContent = getModuleLink(utils.elementUtils.getModuleOf(packageElement),
-                moduleLabel);
+                contents.moduleLabel);
         Content li = HtmlTree.LI(linkContent);
         return li;
     }
@@ -394,7 +393,7 @@
      * @return a content tree for the package link
      */
     protected Content getNavLinkPackage() {
-        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel);
+        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.packageLabel);
         return li;
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PropertyWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -94,7 +94,7 @@
         propertyDetailsTree.addContent(writer.getMarkerAnchor(
                 SectionName.PROPERTY_DETAIL));
         Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
-                writer.propertyDetailsLabel);
+                contents.propertyDetailsLabel);
         propertyDetailsTree.addContent(heading);
         return propertyDetailsTree;
     }
@@ -163,9 +163,9 @@
                 Content codeLink = HtmlTree.CODE(link);
                 Content descfrmLabel = HtmlTree.SPAN(HtmlStyle.descfrmTypeLabel,
                         utils.isClass(holder)
-                                ? writer.descfrmClassLabel
-                                : writer.descfrmInterfaceLabel);
-                descfrmLabel.addContent(writer.getSpace());
+                                ? contents.descfrmClassLabel
+                                : contents.descfrmInterfaceLabel);
+                descfrmLabel.addContent(Contents.SPACE);
                 descfrmLabel.addContent(codeLink);
                 propertyDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, descfrmLabel));
                 writer.addInlineComment(property, propertyDocTree);
@@ -203,20 +203,12 @@
     }
 
     /**
-     * Close the writer.
-     */
-    @Override
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
      * {@inheritDoc}
      */
     @Override
     public void addSummaryLabel(Content memberTree) {
         Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
-                writer.getResource("doclet.Property_Summary"));
+                contents.propertySummary);
         memberTree.addContent(label);
     }
 
@@ -225,9 +217,9 @@
      */
     @Override
     public String getTableSummary() {
-        return configuration.getText("doclet.Member_Table_Summary",
-                configuration.getText("doclet.Property_Summary"),
-                configuration.getText("doclet.properties"));
+        return resources.getText("doclet.Member_Table_Summary",
+                resources.getText("doclet.Property_Summary"),
+                resources.getText("doclet.properties"));
     }
 
     /**
@@ -235,7 +227,7 @@
      */
     @Override
     public Content getCaption() {
-        return configuration.getResource("doclet.Properties");
+        return contents.properties;
     }
 
     /**
@@ -282,7 +274,7 @@
                        : configuration.getText("doclet.Properties_Inherited_From_Interface"));
         Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
                 label);
-        labelHeading.addContent(writer.getSpace());
+        labelHeading.addContent(Contents.SPACE);
         labelHeading.addContent(classLink);
         inheritedTree.addContent(labelHeading);
     }
@@ -342,14 +334,14 @@
             if (typeElement == null) {
                 return writer.getHyperLink(
                 SectionName.PROPERTY_SUMMARY,
-                writer.getResource("doclet.navProperty"));
+                contents.navProperty);
             } else {
                 return writer.getHyperLink(
                 SectionName.PROPERTIES_INHERITANCE,
-                configuration.getClassName(typeElement), writer.getResource("doclet.navProperty"));
+                configuration.getClassName(typeElement), contents.navProperty);
             }
         } else {
-            return writer.getResource("doclet.navProperty");
+            return contents.navProperty;
         }
     }
 
@@ -361,9 +353,9 @@
         if (link) {
             liNav.addContent(writer.getHyperLink(
                     SectionName.PROPERTY_DETAIL,
-                    writer.getResource("doclet.navProperty")));
+                    contents.navProperty));
         } else {
-            liNav.addContent(writer.getResource("doclet.navProperty"));
+            liNav.addContent(contents.navProperty);
         }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -136,8 +136,8 @@
      */
     public Content getPackageHeader(String packageName) {
         Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
-                packageLabel);
-        heading.addContent(getSpace());
+                contents.packageLabel);
+        heading.addContent(Contents.SPACE);
         heading.addContent(packageName);
         return heading;
     }
@@ -183,9 +183,9 @@
 
         //Print the heading.
         Content className = superClassLink == null ?
-            configuration.getResource(
+            configuration.getContent(
             "doclet.Class_0_implements_serializable", classLink) :
-            configuration.getResource(
+            configuration.getContent(
             "doclet.Class_0_extends_implements_serializable", classLink,
             superClassLink);
         li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -33,6 +33,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -84,10 +85,9 @@
             indexgen = new SingleIndexWriter(configuration,
                                              filename, indexbuilder);
             indexgen.generateIndexFile();
-            indexgen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -150,7 +150,7 @@
             contentTree.addContent(
                     getHyperLink(getNameForIndex(unicode),
                             new StringContent(unicode)));
-            contentTree.addContent(getSpace());
+            contentTree.addContent(Contents.SPACE);
         }
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -40,6 +40,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
@@ -73,6 +74,7 @@
     private static final String NEW_LINE = DocletConstants.NL;
 
     private final ConfigurationImpl configuration;
+    private final Messages messages;
     private final Utils utils;
 
     private final DocletEnvironment docEnv;
@@ -88,6 +90,7 @@
     private SourceToHTMLConverter(ConfigurationImpl configuration, DocletEnvironment rd,
             DocPath outputdir) {
         this.configuration  = configuration;
+        this.messages = configuration.getMessages();
         this.utils = configuration.utils;
         this.docEnv = rd;
         this.outputdir = outputdir;
@@ -200,7 +203,7 @@
         Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
                 head, body);
         Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
-        configuration.message.notice("doclet.Generating_0", path.getPath());
+        messages.notice("doclet.Generating_0", path.getPath());
         DocFile df = DocFile.createFileForOutput(configuration, path);
         try (Writer w = df.openWriter()) {
             htmlDocument.write(w, true);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -32,11 +32,13 @@
 import java.util.ListIterator;
 import java.util.Set;
 import java.util.TreeSet;
+
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
@@ -115,11 +117,10 @@
                 if (!li.hasNext()) {
                     indexgen.createSearchIndexFiles();
                 }
-                indexgen.close();
             }
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename.getPath());
             throw new DocletAbortException(exc);
         }
@@ -178,7 +179,7 @@
             int j = i + 1;
             contentTree.addContent(getHyperLink(DocPaths.indexN(j),
                     new StringContent(indexElements.get(i).toString())));
-            contentTree.addContent(getSpace());
+            contentTree.addContent(Contents.SPACE);
         }
     }
 
@@ -188,7 +189,7 @@
      * @return a content tree for the link
      */
     public Content getNavLinkPrevious() {
-        Content prevletterLabel = getResource("doclet.Prev_Letter");
+        Content prevletterLabel = contents.prevLetter;
         if (prev == -1) {
             return HtmlTree.LI(prevletterLabel);
         }
@@ -205,7 +206,7 @@
      * @return a content tree for the link
      */
     public Content getNavLinkNext() {
-        Content nextletterLabel = getResource("doclet.Next_Letter");
+        Content nextletterLabel = contents.nextLetter;
         if (next == -1) {
             return HtmlTree.LI(nextletterLabel);
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -35,7 +35,6 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
-import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes;
@@ -67,8 +66,7 @@
      */
     protected HtmlTree mainTree = HtmlTree.MAIN();
 
-    public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename)
-            throws IOException {
+    public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename) {
         super(configuration, filename);
     }
 
@@ -126,7 +124,7 @@
             Content captionSpan;
             Content span;
             if (type.isDefaultTab()) {
-                captionSpan = HtmlTree.SPAN(configuration.getResource(type.resourceKey()));
+                captionSpan = HtmlTree.SPAN(configuration.getContent(type.resourceKey()));
                 span = HtmlTree.SPAN(type.tabId(),
                         HtmlStyle.activeTableTab, captionSpan);
             } else {
@@ -134,7 +132,7 @@
                 span = HtmlTree.SPAN(type.tabId(),
                         HtmlStyle.tableTab, captionSpan);
             }
-            Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, getSpace());
+            Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, Contents.SPACE);
             span.addContent(tabSpan);
             tabbedCaption.addContent(span);
         }
@@ -149,7 +147,7 @@
      */
     public Content getMethodTypeLinks(MethodTypes methodType) {
         String jsShow = "javascript:show(" + methodType.value() +");";
-        HtmlTree link = HtmlTree.A(jsShow, configuration.getResource(methodType.resourceKey()));
+        HtmlTree link = HtmlTree.A(jsShow, configuration.getContent(methodType.resourceKey()));
         return link;
     }
 
@@ -189,9 +187,9 @@
         List<? extends DocTree> deprs = utils.getBlockTags(member, DocTree.Kind.DEPRECATED);
         Content div;
         if (utils.isDeprecated(member)) {
-            Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+            Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
             div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
-            div.addContent(getSpace());
+            div.addContent(Contents.SPACE);
             if (!deprs.isEmpty()) {
                 addInlineDeprecatedComment(member, deprs.get(0), div);
             }
@@ -200,9 +198,9 @@
         } else {
             Element te = member.getEnclosingElement();
             if (te != null &&  utils.isTypeElement(te) && utils.isDeprecated(te)) {
-                Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase);
+                Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, contents.deprecatedPhrase);
                 div = HtmlTree.DIV(HtmlStyle.block, deprLabel);
-                div.addContent(getSpace());
+                div.addContent(Contents.SPACE);
                 tdSummary.addContent(div);
             }
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -26,6 +26,7 @@
 package jdk.javadoc.internal.doclets.formats.html;
 
 import java.util.List;
+
 import javax.lang.model.element.Element;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
@@ -51,7 +52,6 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
-import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
 /**
@@ -144,7 +144,7 @@
                     return null;
                 }
             }.visit(element);
-            si.setCategory(configuration.getResource("doclet.SearchTags").toString());
+            si.setCategory(configuration.getContent("doclet.SearchTags").toString());
             configuration.tagSearchIndex.add(si);
         }
         return result;
@@ -215,13 +215,6 @@
     /**
      * {@inheritDoc}
      */
-    public MessageRetriever getMsgRetriever() {
-        return configuration.message;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Content getParamHeader(String header) {
         HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.paramLabel,
                 new StringContent(header)));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -36,6 +36,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
@@ -96,10 +97,9 @@
         try {
             treegen = new TreeWriter(configuration, filename, classtree);
             treegen.generateTreeFile();
-            treegen.close();
         } catch (IOException exc) {
-            configuration.standardmessage.error(
-                        "doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                         exc.toString(), filename);
             throw new DocletAbortException(exc);
         }
@@ -110,7 +110,7 @@
      */
     public void generateTreeFile() throws IOException {
         HtmlTree body = getTreeHeader();
-        Content headContent = getResource("doclet.Hierarchy_For_All_Packages");
+        Content headContent = contents.hierarchyForAllPackages;
         Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
                 HtmlStyle.title, headContent);
         Content div = HtmlTree.DIV(HtmlStyle.header, heading);
@@ -154,7 +154,7 @@
         }
         if (!classesonly) {
             Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel,
-                    getResource("doclet.Package_Hierarchies"));
+                    contents.packageHierarchies);
             contentTree.addContent(span);
             HtmlTree ul = new HtmlTree(HtmlTag.UL);
             ul.addStyle(HtmlStyle.horizontal);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2010, 2016, 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 jdk.javadoc.internal.doclets.formats.html.markup;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+
+/**
+ * Class for containing fixed string content for HTML tags of javadoc output.
+ *
+ *  <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>
+ */
+public class FixedStringContent extends Content {
+    private final String string;
+
+    /**
+     * Constructor to construct FixedStringContent object.
+     *
+     * @param content content for the object
+     */
+    public FixedStringContent(CharSequence content) {
+        string = needEscape(content)
+                ? escape(content)
+                : content.toString();
+    }
+
+    /**
+     * This method is not supported by the class.
+     *
+     * @param content content that needs to be added
+     * @throws DocletAbortException this method will always throw a
+     *                              DocletAbortException because it
+     *                              is not supported.
+     */
+    @Override
+    public void addContent(Content content) {
+        throw new DocletAbortException("not supported");
+    }
+
+    /**
+     * Adds content for the StringContent object.  The method escapes
+     * HTML characters for the string content that is added.
+     *
+     * @param strContent string content to be added
+     * @throws DocletAbortException this method will always throw a
+     *                              DocletAbortException because it
+     *                              is not supported.
+     */
+    @Override
+    public void addContent(CharSequence strContent) {
+        throw new DocletAbortException("not supported");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isEmpty() {
+        return string.isEmpty();
+    }
+
+    @Override
+    public int charCount() {
+        return RawHtml.charCount(string);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return string;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean write(Writer out, boolean atNewline) throws IOException {
+        out.write(string);
+        return string.endsWith(DocletConstants.NL);
+    }
+
+    private boolean needEscape(CharSequence cs) {
+        for (int i = 0; i < cs.length(); i++) {
+            switch (cs.charAt(i)) {
+                case '<':
+                case '>':
+                case '&':
+                    return true;
+            }
+        }
+        return false;
+    }
+    private String escape(CharSequence s) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < s.length(); i++) {
+            char ch = s.charAt(i);
+            switch (ch) {
+                case '<': sb.append("&lt;");  break;
+                case '>': sb.append("&gt;");  break;
+                case '&': sb.append("&amp;"); break;
+                default:  sb.append(ch);      break;
+            }
+        }
+        return sb.toString();
+    }
+
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -36,6 +36,7 @@
 import jdk.javadoc.internal.doclets.formats.html.SectionName;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
 import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
@@ -67,11 +68,11 @@
      *
      * @param filename String file name.
      */
-    public HtmlDocWriter(Configuration configuration, DocPath filename)
-            throws IOException {
+    public HtmlDocWriter(Configuration configuration, DocPath filename) {
         super(configuration, filename);
         this.pathToRoot = filename.parent().invert();
-        configuration.message.notice("doclet.Generating_0",
+        Messages messages = configuration.getMessages();
+        messages.notice("doclet.Generating_0",
             DocFile.createFileForOutput(configuration, filename).getPath());
     }
 
@@ -310,10 +311,6 @@
         return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + ".");
     }
 
-    public boolean getMemberDetailsListPrinted() {
-        return memberDetailsListPrinted;
-    }
-
     /**
      * Print the frames version of the Html file header.
      * Called only when generating an HTML frames file.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -30,6 +30,7 @@
 
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
@@ -62,11 +63,6 @@
     protected Configuration configuration;
 
     /**
-     * The flag to indicate whether a member details list is printed or not.
-     */
-    protected boolean memberDetailsListPrinted;
-
-    /**
      * Header for table displaying modules and description..
      */
     protected final List<String> moduleTableHeader;
@@ -106,89 +102,7 @@
      */
     protected final String modifierTypeHeader;
 
-    public final Content overviewLabel;
-
-    public final Content defaultPackageLabel;
-
-    public final Content packageLabel;
-
-    public final Content moduleLabel;
-
-    public final Content useLabel;
-
-    public final Content prevLabel;
-
-    public final Content nextLabel;
-
-    public final Content prevclassLabel;
-
-    public final Content nextclassLabel;
-
-    public final Content summaryLabel;
-
-    public final Content detailLabel;
-
-    public final Content moduleSubNavLabel;
-
-    public final Content framesLabel;
-
-    public final Content noframesLabel;
-
-    public final Content treeLabel;
-
-    public final Content classLabel;
-
-    public final Content deprecatedLabel;
-
-    public final Content deprecatedPhrase;
-
-    public final Content allclassesLabel;
-
-    public final Content allpackagesLabel;
-
-    public final Content allmodulesLabel;
-
-    public final Content indexLabel;
-
-    public final Content helpLabel;
-
-    public final Content seeLabel;
-
-    public final Content descriptionLabel;
-
-    public final Content prevpackageLabel;
-
-    public final Content nextpackageLabel;
-
-    public final Content prevmoduleLabel;
-
-    public final Content nextmoduleLabel;
-
-    public final Content packagesLabel;
-
-    public final Content modulesLabel;
-
-    public final Content methodDetailsLabel;
-
-    public final Content annotationTypeDetailsLabel;
-
-    public final Content fieldDetailsLabel;
-
-    public final Content propertyDetailsLabel;
-
-    public final Content constructorDetailsLabel;
-
-    public final Content enumConstantsDetailsLabel;
-
-    public final Content specifiedByLabel;
-
-    public final Content overridesLabel;
-
-    public final Content descfrmClassLabel;
-
-    public final Content descfrmInterfaceLabel;
-
-    private final Writer writer;
+    private final DocFile docFile;
 
     protected Content script;
 
@@ -198,143 +112,45 @@
      *
      * @param path The directory path to be created for this file
      *             or null if none to be created.
-     * @exception IOException Exception raised by the FileWriter is passed on
-     * to next level.
-     * @exception UnsupportedEncodingException Exception raised by the
-     * OutputStreamWriter is passed on to next level.
      */
-    public HtmlWriter(Configuration configuration, DocPath path)
-            throws IOException, UnsupportedEncodingException {
-        writer = DocFile.createFileForOutput(configuration, path).openWriter();
+    public HtmlWriter(Configuration configuration, DocPath path) {
+        docFile = DocFile.createFileForOutput(configuration, path);
         this.configuration = configuration;
-        this.memberDetailsListPrinted = false;
+
+        // The following should be converted to shared Content objects
+        // and moved to Contents, but that will require additional
+        // changes at the use sites.
+        Resources resources = configuration.getResources();
         moduleTableHeader = Arrays.asList(
-            configuration.getText("doclet.Module"),
-            configuration.getText("doclet.Description"));
+            resources.getText("doclet.Module"),
+            resources.getText("doclet.Description"));
         packageTableHeader = new ArrayList<>();
-        packageTableHeader.add(configuration.getText("doclet.Package"));
-        packageTableHeader.add(configuration.getText("doclet.Description"));
+        packageTableHeader.add(resources.getText("doclet.Package"));
+        packageTableHeader.add(resources.getText("doclet.Description"));
         requiresTableHeader = new ArrayList<>();
-        requiresTableHeader.add(configuration.getText("doclet.Module"));
-        requiresTableHeader.add(configuration.getText("doclet.Description"));
+        requiresTableHeader.add(resources.getText("doclet.Module"));
+        requiresTableHeader.add(resources.getText("doclet.Description"));
         exportedPackagesTableHeader = new ArrayList<>();
-        exportedPackagesTableHeader.add(configuration.getText("doclet.Package"));
-        exportedPackagesTableHeader.add(configuration.getText("doclet.Module"));
-        exportedPackagesTableHeader.add(configuration.getText("doclet.Description"));
+        exportedPackagesTableHeader.add(resources.getText("doclet.Package"));
+        exportedPackagesTableHeader.add(resources.getText("doclet.Module"));
+        exportedPackagesTableHeader.add(resources.getText("doclet.Description"));
         usesTableHeader = new ArrayList<>();
-        usesTableHeader.add(configuration.getText("doclet.Type"));
-        usesTableHeader.add(configuration.getText("doclet.Description"));
+        usesTableHeader.add(resources.getText("doclet.Type"));
+        usesTableHeader.add(resources.getText("doclet.Description"));
         providesTableHeader = new ArrayList<>();
-        providesTableHeader.add(configuration.getText("doclet.Type"));
-        providesTableHeader.add(configuration.getText("doclet.Description"));
-        useTableSummary = configuration.getText("doclet.Use_Table_Summary",
-                configuration.getText("doclet.packages"));
-        modifierTypeHeader = configuration.getText("doclet.0_and_1",
-                configuration.getText("doclet.Modifier"),
-                configuration.getText("doclet.Type"));
-        overviewLabel = getResource("doclet.Overview");
-        defaultPackageLabel = new StringContent(DocletConstants.DEFAULT_PACKAGE_NAME);
-        packageLabel = getResource("doclet.Package");
-        moduleLabel = getResource("doclet.Module");
-        useLabel = getResource("doclet.navClassUse");
-        prevLabel = getResource("doclet.Prev");
-        nextLabel = getResource("doclet.Next");
-        prevclassLabel = getNonBreakResource("doclet.Prev_Class");
-        nextclassLabel = getNonBreakResource("doclet.Next_Class");
-        summaryLabel = getResource("doclet.Summary");
-        detailLabel = getResource("doclet.Detail");
-        moduleSubNavLabel = getResource("doclet.Module_Sub_Nav");
-        framesLabel = getResource("doclet.Frames");
-        noframesLabel = getNonBreakResource("doclet.No_Frames");
-        treeLabel = getResource("doclet.Tree");
-        classLabel = getResource("doclet.Class");
-        deprecatedLabel = getResource("doclet.navDeprecated");
-        deprecatedPhrase = getResource("doclet.Deprecated");
-        allclassesLabel = getNonBreakResource("doclet.All_Classes");
-        allpackagesLabel = getNonBreakResource("doclet.All_Packages");
-        allmodulesLabel = getNonBreakResource("doclet.All_Modules");
-        indexLabel = getResource("doclet.Index");
-        helpLabel = getResource("doclet.Help");
-        seeLabel = getResource("doclet.See");
-        descriptionLabel = getResource("doclet.Description");
-        prevpackageLabel = getNonBreakResource("doclet.Prev_Package");
-        nextpackageLabel = getNonBreakResource("doclet.Next_Package");
-        prevmoduleLabel = getNonBreakResource("doclet.Prev_Module");
-        nextmoduleLabel = getNonBreakResource("doclet.Next_Module");
-        packagesLabel = getResource("doclet.Packages");
-        modulesLabel = getResource("doclet.Modules");
-        methodDetailsLabel = getResource("doclet.Method_Detail");
-        annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
-        fieldDetailsLabel = getResource("doclet.Field_Detail");
-        propertyDetailsLabel = getResource("doclet.Property_Detail");
-        constructorDetailsLabel = getResource("doclet.Constructor_Detail");
-        enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
-        specifiedByLabel = getResource("doclet.Specified_By");
-        overridesLabel = getResource("doclet.Overrides");
-        descfrmClassLabel = getResource("doclet.Description_From_Class");
-        descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
+        providesTableHeader.add(resources.getText("doclet.Type"));
+        providesTableHeader.add(resources.getText("doclet.Description"));
+        useTableSummary = resources.getText("doclet.Use_Table_Summary",
+                resources.getText("doclet.packages"));
+        modifierTypeHeader = resources.getText("doclet.0_and_1",
+                resources.getText("doclet.Modifier"),
+                resources.getText("doclet.Type"));
     }
 
     public void write(Content c) throws IOException {
-        c.write(writer, true);
-    }
-
-    public void close() throws IOException {
-        writer.close();
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @return a content tree for the text
-     */
-    public Content getResource(String key) {
-        return configuration.getResource(key);
-    }
-
-    /**
-     * Get the configuration string as a content, replacing spaces
-     * with non-breaking spaces.
-     *
-     * @param key the key to look for in the configuration file
-     * @return a content tree for the text
-     */
-    public Content getNonBreakResource(String key) {
-        String text = configuration.getText(key);
-        Content c = configuration.newContent();
-        int start = 0;
-        int p;
-        while ((p = text.indexOf(" ", start)) != -1) {
-            c.addContent(text.substring(start, p));
-            c.addContent(RawHtml.nbsp);
-            start = p + 1;
+        try (Writer writer = docFile.openWriter()) {
+            c.write(writer, true);
         }
-        c.addContent(text.substring(start));
-        return c;
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @param o   string or content argument added to configuration text
-     * @return a content tree for the text
-     */
-    public Content getResource(String key, Object o) {
-        return configuration.getResource(key, o);
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @param o1  string or content argument added to configuration text
-     * @param o2  string or content argument added to configuration text
-     * @return a content tree for the text
-     */
-    public Content getResource(String key, Object o0, Object o1) {
-        return configuration.getResource(key, o0, o1);
     }
 
     /**
@@ -343,21 +159,21 @@
      * @return an HtmlTree for the SCRIPT tag
      */
     protected HtmlTree getWinTitleScript(){
-        HtmlTree script = HtmlTree.SCRIPT();
+        HtmlTree scriptTree = HtmlTree.SCRIPT();
         if(winTitle != null && winTitle.length() > 0) {
-            String scriptCode = "<!--" + DocletConstants.NL +
-                    "    try {" + DocletConstants.NL +
-                    "        if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL +
-                    "            parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";" + DocletConstants.NL +
-                    "        }" + DocletConstants.NL +
-                    "    }" + DocletConstants.NL +
-                    "    catch(err) {" + DocletConstants.NL +
-                    "    }" + DocletConstants.NL +
-                    "//-->" + DocletConstants.NL;
-            RawHtml scriptContent = new RawHtml(scriptCode);
-            script.addContent(scriptContent);
+            String scriptCode = "<!--\n" +
+                    "    try {\n" +
+                    "        if (location.href.indexOf('is-external=true') == -1) {\n" +
+                    "            parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";\n" +
+                    "        }\n" +
+                    "    }\n" +
+                    "    catch(err) {\n" +
+                    "    }\n" +
+                    "//-->\n";
+            RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL));
+            scriptTree.addContent(scriptContent);
         }
-        return script;
+        return scriptTree;
     }
 
     /**
@@ -413,61 +229,61 @@
      * @return a content for the SCRIPT tag
      */
     protected Content getFramesJavaScript() {
-        HtmlTree script = HtmlTree.SCRIPT();
-        String scriptCode = DocletConstants.NL +
-                "    targetPage = \"\" + window.location.search;" + DocletConstants.NL +
-                "    if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
-                "        targetPage = targetPage.substring(1);" + DocletConstants.NL +
-                "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
-                "        targetPage = \"undefined\";" + DocletConstants.NL +
-                "    function validURL(url) {" + DocletConstants.NL +
-                "        try {" + DocletConstants.NL +
-                "            url = decodeURIComponent(url);" + DocletConstants.NL +
-                "        }" + DocletConstants.NL +
-                "        catch (error) {" + DocletConstants.NL +
-                "            return false;" + DocletConstants.NL +
-                "        }" + DocletConstants.NL +
-                "        var pos = url.indexOf(\".html\");" + DocletConstants.NL +
-                "        if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL +
-                "            return false;" + DocletConstants.NL +
-                "        var allowNumber = false;" + DocletConstants.NL +
-                "        var allowSep = false;" + DocletConstants.NL +
-                "        var seenDot = false;" + DocletConstants.NL +
-                "        for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL +
-                "            var ch = url.charAt(i);" + DocletConstants.NL +
-                "            if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
-                "                    'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
-                "                    ch == '$' ||" + DocletConstants.NL +
-                "                    ch == '_' ||" + DocletConstants.NL +
-                "                    ch.charCodeAt(0) > 127) {" + DocletConstants.NL +
-                "                allowNumber = true;" + DocletConstants.NL +
-                "                allowSep = true;" + DocletConstants.NL +
-                "            } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
-                "                    || ch == '-') {" + DocletConstants.NL +
-                "                if (!allowNumber)" + DocletConstants.NL +
-                "                     return false;" + DocletConstants.NL +
-                "            } else if (ch == '/' || ch == '.') {" + DocletConstants.NL +
-                "                if (!allowSep)" + DocletConstants.NL +
-                "                    return false;" + DocletConstants.NL +
-                "                allowNumber = false;" + DocletConstants.NL +
-                "                allowSep = false;" + DocletConstants.NL +
-                "                if (ch == '.')" + DocletConstants.NL +
-                "                     seenDot = true;" + DocletConstants.NL +
-                "                if (ch == '/' && seenDot)" + DocletConstants.NL +
-                "                     return false;" + DocletConstants.NL +
-                "            } else {" + DocletConstants.NL +
-                "                return false;"+ DocletConstants.NL +
-                "            }" + DocletConstants.NL +
-                "        }" + DocletConstants.NL +
-                "        return true;" + DocletConstants.NL +
-                "    }" + DocletConstants.NL +
-                "    function loadFrames() {" + DocletConstants.NL +
-                "        if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
-                "             top.classFrame.location = top.targetPage;" + DocletConstants.NL +
-                "    }" + DocletConstants.NL;
-        RawHtml scriptContent = new RawHtml(scriptCode);
-        script.addContent(scriptContent);
-        return script;
+        HtmlTree scriptTree = HtmlTree.SCRIPT();
+        String scriptCode = "\n" +
+                "    targetPage = \"\" + window.location.search;\n" +
+                "    if (targetPage != \"\" && targetPage != \"undefined\")\n" +
+                "        targetPage = targetPage.substring(1);\n" +
+                "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))\n" +
+                "        targetPage = \"undefined\";\n" +
+                "    function validURL(url) {\n" +
+                "        try {\n" +
+                "            url = decodeURIComponent(url);\n" +
+                "        }\n" +
+                "        catch (error) {\n" +
+                "            return false;\n" +
+                "        }\n" +
+                "        var pos = url.indexOf(\".html\");\n" +
+                "        if (pos == -1 || pos != url.length - 5)\n" +
+                "            return false;\n" +
+                "        var allowNumber = false;\n" +
+                "        var allowSep = false;\n" +
+                "        var seenDot = false;\n" +
+                "        for (var i = 0; i < url.length - 5; i++) {\n" +
+                "            var ch = url.charAt(i);\n" +
+                "            if ('a' <= ch && ch <= 'z' ||\n" +
+                "                    'A' <= ch && ch <= 'Z' ||\n" +
+                "                    ch == '$' ||\n" +
+                "                    ch == '_' ||\n" +
+                "                    ch.charCodeAt(0) > 127) {\n" +
+                "                allowNumber = true;\n" +
+                "                allowSep = true;\n" +
+                "            } else if ('0' <= ch && ch <= '9'\n" +
+                "                    || ch == '-') {\n" +
+                "                if (!allowNumber)\n" +
+                "                     return false;\n" +
+                "            } else if (ch == '/' || ch == '.') {\n" +
+                "                if (!allowSep)\n" +
+                "                    return false;\n" +
+                "                allowNumber = false;\n" +
+                "                allowSep = false;\n" +
+                "                if (ch == '.')\n" +
+                "                     seenDot = true;\n" +
+                "                if (ch == '/' && seenDot)\n" +
+                "                     return false;\n" +
+                "            } else {\n" +
+                "                return false;\n" +
+                "            }\n" +
+                "        }\n" +
+                "        return true;\n" +
+                "    }\n" +
+                "    function loadFrames() {\n" +
+                "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
+                "             top.classFrame.location = top.targetPage;\n" +
+                "    }\n";
+        RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL));
+        scriptTree.addContent(scriptContent);
+        return scriptTree;
     }
 
     /**
@@ -487,7 +303,7 @@
             this.script = getWinTitleScript();
             body.addContent(script);
             Content noScript = HtmlTree.NOSCRIPT(
-                    HtmlTree.DIV(getResource("doclet.No_Script_Message")));
+                    HtmlTree.DIV(configuration.getContent("doclet.No_Script_Message")));
             body.addContent(noScript);
         }
         return body;
@@ -558,17 +374,6 @@
         return title;
     }
 
-    public String codeText(String text) {
-        return "<code>" + text + "</code>";
-    }
-
-    /**
-     * Return "&#38;nbsp;", non-breaking space.
-     */
-    public Content getSpace() {
-        return RawHtml.nbsp;
-    }
-
     /*
      * Returns a header for Modifier and Type column of a table.
      */
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java	Fri Aug 19 12:17:32 2016 -0700
@@ -44,7 +44,7 @@
  */
 public class RawHtml extends Content {
 
-    private String rawHtmlContent;
+    private final String rawHtmlContent;
 
     public static final Content nbsp = new RawHtml("&nbsp;");
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -191,180 +191,136 @@
 doclet.exception_encountered=Exception encountered while processing {1}\n{0}
 
 # option specifiers
-doclet.usage.d.name=d
 doclet.usage.d.parameters=<directory>
 doclet.usage.d.description=Destination directory for output files
 
-doclet.usage.use.name=use
 doclet.usage.use.description=Create class and package usage pages
 
-doclet.usage.version.name=version
 doclet.usage.version.description=Include @version paragraphs
 
-doclet.usage.author.name=author
 doclet.usage.author.description=Include @author paragraphs
 
-doclet.usage.docfilessubdirs.name=docfilessubdirs
 doclet.usage.docfilessubdirs.description=Recursively copy doc-file subdirectories
 
-doclet.usage.splitindex.name=splitindex
 doclet.usage.splitindex.description=Split index into one file per letter
 
-doclet.usage.windowtitle.name=windowtitle
-doclet.usage.windotitle.parameters=<text>
+doclet.usage.windowtitle.parameters=<text>
 doclet.usage.windowtitle.description=Browser window title for the documentation
 
-doclet.usage.doctitle.name=doctitle
 doclet.usage.doctitle.parameters=<html-code>
 doclet.usage.doctitle.description=Include title for the overview page
 
-doclet.usage.header.name=header
 doclet.usage.header.parameters=<html-code>
 doclet.usage.header.description=Include header text for each page
 
-doclet.usage.html4.name=html4
 doclet.usage.html4.description=Generate HTML 4.01 output
 
-doclet.usage.html5.name=html5
 doclet.usage.html5.description=Generate HTML 5 output
 
-doclet.usage.footer.name=footer
 doclet.usage.footer.parameters=<html-code>
 doclet.usage.footer.description=Include footer text for each page
 
-doclet.usage.top.name=top
 doclet.usage.top.parameters=<html-code>
 doclet.usage.top.description=Include top text for each page
 
-doclet.usage.bottom.name=bottom
 doclet.usage.bottom.parameters=<html-code>
 doclet.usage.bottom.description=Include bottom text for each page
 
-doclet.usage.link.name=link
 doclet.usage.link.parameters=<url>
 doclet.usage.link.description=Create links to javadoc output at <url>
 
-doclet.usage.linkoffline.name=linkoffline
 doclet.usage.linkoffline.parameters=<url1> <url2>
 doclet.usage.linkoffline.description=Link to docs at <url1> using package list\n\
-\                                  at <url2>
+\                                   at <url2>
 
-doclet.usage.excludedocfilessubdir.name=excludedocfilessubdir
 doclet.usage.excludedocfilessubdir.parameters=<name>:..
 doclet.usage.excludedocfilessubdir.description=\n\
-\                                  Exclude any doc-files subdirectories with\n\
-\                                  given name
+\                                   Exclude any doc-files subdirectories with\n\
+\                                   given name
 
-doclet.usage.group.name=group
 doclet.usage.group.parameters=<name> <p1>:<p2>..
 doclet.usage.group.description=Group specified packages together\n\
-\                                  in overview page
+\                                   in overview page
 
-doclet.usage.nocomment.name=nocomment
 doclet.usage.nocomment.description=Suppress description and tags, generate\n\
-\                                  only declarations
+\                                   only declarations
 
-doclet.usage.nodeprecated.name=nodeprecated
 doclet.usage.nodeprecated.description=Do not include @deprecated information
 
-doclet.usage.noqualifier.name=noqualifier
 doclet.usage.noqualifier.parameters=<name1>:<name2>:..
 doclet.usage.noqualifier.description=Exclude the list of qualifiers from the output
 
-doclet.usage.nosince.name=nosince
 doclet.usage.nosince.description=Do not include @since information
 
-doclet.usage.notimestamp.name=notimestamp
 doclet.usage.notimestamp.description=Do not include hidden time stamp
 
-doclet.usage.nodeprecatedlist.name=nodeprecatedlist
 doclet.usage.nodeprecatedlist.description=Do not generate deprecated list
 
-doclet.usage.notree.name=notree
 doclet.usage.notree.description=Do not generate class hierarchy
 
-doclet.usage.noindex.name=noindex
 doclet.usage.noindex.description=Do not generate index
 
-doclet.usage.nohelp.name=nohelp
 doclet.usage.nohelp.description=Do not generate help link
 
-doclet.usage.nonavbar.name=nonavbar
 doclet.usage.nonavbar.description=Do not generate navigation bar
 
-doclet.usage.nooverview.name=nooverview
 doclet.usage.nooverview.description=Do not generate overview pages
 
-doclet.usage.serialwarn.name=serialwarn
 doclet.usage.serialwarn.description=Generate warning about @serial tag
 
-doclet.usage.tag.name=tag
 doclet.usage.tag.parameters=<name>:<locations>:<header>
 doclet.usage.tag.description=\n\
-\                                  Specify single argument custom tags
+\                                   Specify single argument custom tags
 
-doclet.usage.taglet.name=taglet
 doclet.usage.taglet.description=The fully qualified name of Taglet to register
 
-doclet.usage.tagletpath.name=tagletpath
 doclet.usage.tagletpath.description=The path to Taglets
 
-doclet.usage.charset.name=charset
 doclet.usage.charset.parameters=<charset>
 doclet.usage.charset.description=Charset for cross-platform viewing of\n\
-\                                  generated documentation
+\                                   generated documentation
 
-doclet.usage.helpfile.name=helpfile
 doclet.usage.helpfile.parameters=<file>
 doclet.usage.helpfile.description=Include file that help link links to
 
-doclet.usage.linksource.name=linksource
 doclet.usage.linksource.description=Generate source in HTML
 
-doclet.usage.sourcetab.name=sourcetab
 doclet.usage.sourcetab.parameters=<tab length>
 doclet.usage.sourcetab.description=Specify the number of spaces each tab\n\
-\                                  takes up in the source
+\                                   takes up in the source
 
-doclet.usage.keywords.name=keywords
 doclet.usage.keywords.description=Include HTML meta tags with package,\n\
-\                                  class and member info
+\                                   class and member info
 
-doclet.usage.stylesheetfile.name=stylesheetfile
 doclet.usage.stylesheetfile.parameters=<path>
 doclet.usage.stylesheetfile.description=File to change style of the generated\n\
-\                                  documentation
+\                                   documentation
 
-doclet.usage.docencoding.name=docencoding
 doclet.usage.docencoding.parameters=<name>
 doclet.usage.docencoding.description=Specify the character encoding for the output
 
-doclet.xusage.xdocrootparent.name=Xdocrootparent
 doclet.xusage.xdocrootparent.parameters=<url>
 doclet.xusage.xdocrootparent.description=Replaces all @docRoot followed by /..\n\
-\                                  in doc comments with <url>
+\                                   in doc comments with <url>
 
-doclet.xusage.xdoclint.name=Xdoclint
 doclet.xusage.xdoclint.description=Enable recommended checks for problems in\n\
-\                                  javadoc comments
+\                                   javadoc comments
 
-doclet.xusage.xdoclint-extended.name=Xdoclint:
 doclet.xusage.xdoclint-extended.parameters=(all|none|[-]<group>)
 # L10N: do not localize these words: all none accessibility html missing reference syntax
 doclet.xusage.xdoclint-extended.description=Enable or disable specific checks\n\
-\                                  for problems in javadoc comments, where \n\
-\                                  <group> is one of accessibility, html,\n\
-\                                  missing, reference, or syntax.\n
+\                                   for problems in javadoc comments, where \n\
+\                                   <group> is one of accessibility, html,\n\
+\                                   missing, reference, or syntax.\n
 
-doclet.xusage.xdoclint-package.name=Xdoclint/package:
 doclet.xusage.xdoclint-package.parameters=([-]<packages>)
 doclet.xusage.xdoclint-package.description=\n\
-\                                  Enable or disable checks in specific\n\
-\                                  packages. <packages> is a comma separated\n\
-\                                  list of package specifiers. Package\n\
-\                                  specifier is either a qualified name of a\n\
-\                                  package or a package name prefix followed\n\
-\                                  by .*, which expands to all sub-packages\n\
-\                                  of the given package. Prefix the package\n\
-\                                  specifier with - to disable checks for\n\
-\                                  the specified packages.\n
+\                                   Enable or disable checks in specific\n\
+\                                   packages. <packages> is a comma separated\n\
+\                                   list of package specifiers. Package\n\
+\                                   specifier is either a qualified name of a\n\
+\                                   package or a package name prefix followed\n\
+\                                   by .*, which expands to all sub-packages\n\
+\                                   of the given package. Prefix the package\n\
+\                                   specifier with - to disable checks for\n\
+\                                   the specified packages.\n
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,6 +32,7 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
+import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder;
 import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
@@ -53,12 +54,15 @@
  *
  * @author Jamie Ho
  */
-public abstract class AbstractDoclet {
+public abstract class AbstractDoclet implements Doclet {
 
     /**
      * The global configuration information for this run.
      */
-    public Configuration configuration;
+    private Configuration configuration;
+
+    protected Messages messages;
+
     /*
      *  a handle to our utility methods
      */
@@ -76,7 +80,7 @@
      */
     private boolean isValidDoclet() {
         if (!getClass().getName().equals(TOOLKIT_DOCLET_NAME)) {
-            configuration.message.error("doclet.Toolkit_Usage_Violation",
+            messages.error("doclet.Toolkit_Usage_Violation",
                 TOOLKIT_DOCLET_NAME);
             return false;
         }
@@ -89,13 +93,16 @@
      * @param root   the {@link DocletEnvironment} that points to the source to document.
      * @return true if the doclet executed without error.  False otherwise.
      */
-    public boolean startDoclet(DocletEnvironment root) {
+    @Override
+    public boolean run(DocletEnvironment root) {
         configuration = configuration();
         configuration.docEnv = root;
         configuration.cmtUtils = new CommentUtils(configuration);
         configuration.utils = new Utils(configuration);
         utils = configuration.utils;
         configuration.workArounds = new WorkArounds(configuration);
+        messages = configuration.getMessages();
+
         if (!isValidDoclet()) {
             return false;
         }
@@ -116,6 +123,7 @@
             }
             return false;
         } catch (Exception exc) {
+            exc.printStackTrace(System.err);
             return false;
         }
         return true;
@@ -125,7 +133,8 @@
      * Returns the SourceVersion indicating the features supported by this doclet.
      * @return SourceVersion
      */
-    public SourceVersion sourceVersion() {
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
         return SourceVersion.RELEASE_9;
     }
 
@@ -146,14 +155,13 @@
      */
     private void startGeneration(DocletEnvironment root) throws Configuration.Fault, Exception {
         if (root.getIncludedClasses().isEmpty()) {
-            configuration.message.
-                error("doclet.No_Public_Classes_To_Document");
+            messages.error("doclet.No_Public_Classes_To_Document");
             return;
         }
         if (!configuration.setOptions()) {
             return;
         }
-        configuration.getDocletSpecificMsg().notice("doclet.build_version",
+        messages.notice("doclet.build_version",
             configuration.getDocletSpecificBuildDate());
         ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated);
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeFieldWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -124,9 +124,4 @@
      * @param annotationDocTree the content tree to which the tags will be added
      */
     public void addTags(Element member, Content annotationDocTree);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeRequiredMemberWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -125,9 +125,4 @@
      * @param annotationDocTree the content tree to which the tags will be added
      */
     public void addTags(Element member, Content annotationDocTree);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -156,11 +156,6 @@
     public void printDocument(Content contentTree) throws IOException;
 
     /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
-
-    /**
      * Return the {@link TypeElement} being documented.
      *
      * @return the TypeElement representing the annotation being documented.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -197,11 +197,6 @@
     public void printDocument(Content contentTree) throws IOException;
 
     /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
-
-    /**
      * Return the TypeElement being documented.
      *
      * @return the TypeElement being documented.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Fri Aug 19 12:17:32 2016 -0700
@@ -27,8 +27,6 @@
 
 import java.io.*;
 import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ModuleElement;
@@ -50,7 +48,6 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
 import jdk.javadoc.internal.doclets.toolkit.util.Extern;
 import jdk.javadoc.internal.doclets.toolkit.util.Group;
-import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
 import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords;
 import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
@@ -266,15 +263,6 @@
     public TypeElementCatalog typeElementCatalog;
 
     /**
-     * Message Retriever for the doclet, to retrieve message from the resource
-     * file for this Configuration, which is common for 1.1 and standard
-     * doclets.
-     *
-     * TODO:  Make this private!!!
-     */
-    public MessageRetriever message = null;
-
-    /**
      * True if user wants to suppress time stamp in output.
      * Default is false.
      */
@@ -309,6 +297,9 @@
 
     private List<GroupContainer> groups;
 
+    public abstract Messages getMessages();
+    public abstract Resources getResources();
+
     /**
      * Return the build date for the doclet.
      */
@@ -322,12 +313,6 @@
 
     public abstract boolean finishOptionSettings();
 
-    /**
-     * Return the doclet specific {@link MessageRetriever}
-     * @return the doclet specific MessageRetriever.
-     */
-    public abstract MessageRetriever getDocletSpecificMsg();
-
     public CommentUtils cmtUtils;
     public SortedSet<ModuleElement> modules;
 
@@ -354,11 +339,12 @@
      */
     public Map<ModuleElement, Set<PackageElement>> modulePackages;
 
+    protected static final String sharedResourceBundleName =
+            "jdk.javadoc.internal.doclets.toolkit.resources.doclets";
     /**
      * Constructor. Constructs the message retriever with resource file.
      */
     public Configuration() {
-        message = new MessageRetriever(this, "jdk.javadoc.internal.doclets.toolkit.resources.doclets");
         excludedDocFileDirs = new HashSet<>();
         excludedQualifiers = new HashSet<>();
         setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
@@ -578,7 +564,7 @@
                         sourcetab = -1;
                     }
                     if (sourcetab <= 0) {
-                        message.warning("doclet.sourcetab_warning");
+                        getMessages().warning("doclet.sourcetab_warning");
                         setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
                     }
                     return true;
@@ -696,7 +682,7 @@
      */
     private void initTagletManager(Set<List<String>> customTagStrs) {
         tagletManager = tagletManager == null ?
-            new TagletManager(nosince, showversion, showauthor, javafx, message) :
+            new TagletManager(nosince, showversion, showauthor, javafx, this) :
             tagletManager;
         for (List<String> args : customTagStrs) {
             if (args.get(0).equals("-taglet")) {
@@ -721,7 +707,8 @@
             } else if (tokens.size() >= 3) {
                 tagletManager.addNewSimpleCustomTag(tokens.get(0), tokens.get(2), tokens.get(1));
             } else {
-                message.error("doclet.Error_invalid_custom_tag_argument", args.get(1));
+                Messages messages = getMessages();
+                messages.error("doclet.Error_invalid_custom_tag_argument", args.get(1));
             }
         }
     }
@@ -893,123 +880,69 @@
                 : utils.getFullyQualifiedName(te);
     }
 
-    public String getText(String key) {
-        // Check the doclet specific properties file.
-        MessageRetriever docletMessage = getDocletSpecificMsg();
-        if (docletMessage.containsKey(key)) {
-            return docletMessage.getText(key);
-        }
-        // Check the shared properties file.
-        return message.getText(key);
-    }
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources}.
+     * Equivalent to <code>getResources.getText(key);</code>.
+     * @param key the key for the desired string
+     * @return the string for the given key
+     * @throws MissingResourceException if the key is not found in either
+     *  bundle.
+     */
+    public abstract String getText(String key);
 
-    public String getText(String key, String a1) {
-        // Check the doclet specific properties file.
-        MessageRetriever docletMessage = getDocletSpecificMsg();
-        if (docletMessage.containsKey(key)) {
-            return docletMessage.getText(key, a1);
-        }
-        // Check the shared properties file.
-        return message.getText(key, a1);
-    }
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources}.
+     * Equivalent to <code>getResources.getText(key, args);</code>.
+     * @param key the key for the desired string
+     * @param args values to be substituted into the resulting string
+     * @return the string for the given key
+     * @throws MissingResourceException if the key is not found in either
+     *  bundle.
+     */
+    public abstract String getText(String key, String... args);
 
-    public String getText(String key, String a1, String a2) {
-        // Check the doclet specific properties file.
-        MessageRetriever docletMessage = getDocletSpecificMsg();
-        if (docletMessage.containsKey(key)) {
-            return docletMessage.getText(key, a1, a2);
-        }
-        // Check the shared properties file.
-        return message.getText(key, a1, a2);
-    }
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources} as a {@code Content} object.
+     *
+     * @param key the key for the desired string
+     * @return a content tree for the text
+     */
+    public abstract Content getContent(String key);
 
-    public String getText(String key, String a1, String a2, String a3) {
-        // Check the doclet specific properties file.
-        MessageRetriever docletMessage = getDocletSpecificMsg();
-        if (docletMessage.containsKey(key)) {
-            return docletMessage.getText(key, a1, a2, a3);
-        }
-        // Check the shared properties file.
-        return message.getText(key, a1, a2, a3);
-    }
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources} as a {@code Content} object.
+     *
+     * @param key the key for the desired string
+     * @param o   string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    public abstract Content getContent(String key, Object o);
 
-    public abstract Content newContent();
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources} as a {@code Content} object.
+     *
+     * @param key the key for the desired string
+     * @param o1 resource argument
+     * @param o2 resource argument
+     * @return a content tree for the text
+     */
+    public abstract Content getContent(String key, Object o1, Object o2);
 
     /**
      * Get the configuration string as a content.
      *
-     * @param key the key to look for in the configuration file
-     * @return a content tree for the text
-     */
-    public Content getResource(String key) {
-        Content c = newContent();
-        c.addContent(getText(key));
-        return c;
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @param o   string or content argument added to configuration text
-     * @return a content tree for the text
-     */
-    public Content getResource(String key, Object o) {
-        return getResource(key, o, null, null);
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @param o1 resource argument
-     * @param o2 resource argument
-     * @return a content tree for the text
-     */
-    public Content getResource(String key, Object o1, Object o2) {
-        return getResource(key, o1, o2, null);
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
+     * @param key the key for the desired string
      * @param o0  string or content argument added to configuration text
      * @param o1  string or content argument added to configuration text
      * @param o2  string or content argument added to configuration text
      * @return a content tree for the text
      */
-    public Content getResource(String key, Object o0, Object o1, Object o2) {
-        Content c = newContent();
-        Pattern p = Pattern.compile("\\{([012])\\}");
-        String text = getText(key);
-        Matcher m = p.matcher(text);
-        int start = 0;
-        while (m.find(start)) {
-            c.addContent(text.substring(start, m.start()));
-
-            Object o = null;
-            switch (m.group(1).charAt(0)) {
-                case '0': o = o0; break;
-                case '1': o = o1; break;
-                case '2': o = o2; break;
-            }
-
-            if (o == null) {
-                c.addContent("{" + m.group(1) + "}");
-            } else if (o instanceof String) {
-                c.addContent((String) o);
-            } else if (o instanceof Content) {
-                c.addContent((Content) o);
-            }
-
-            start = m.end();
-        }
-
-        c.addContent(text.substring(start));
-        return c;
-    }
-
+    public abstract Content getContent(String key, Object o0, Object o1, Object o2);
 
     /**
      * Return true if the TypeElement element is getting documented, depending upon
@@ -1084,14 +1017,13 @@
         protected Option(Configuration config, String keyName, String name, int argCount) {
             c = config;
             this.name = name;
-            String key = keyName + "name";
-            String oname = getOptionsMessage(key);
-            if (oname.isEmpty()) {
+            String desc = getOptionsMessage(keyName + "description");
+            if (desc.isEmpty()) {
+                this.description = "<MISSING KEY>";
                 this.parameters = "<MISSING KEY>";
-                this.description = "<MISSING KEY>";
             } else {
+                this.description = desc;
                 this.parameters = getOptionsMessage(keyName + "parameters");
-                this.description = getOptionsMessage(keyName + "description");
             }
             this.argCount = argCount;
         }
@@ -1110,7 +1042,7 @@
 
         private String getOptionsMessage(String key) {
             try {
-                return c.getDocletSpecificMsg().getText(key, (Object[]) null);
+                return c.getResources().getText(key);
             } catch (MissingResourceException ignore) {
                 return "";
             }
@@ -1143,10 +1075,8 @@
         @Override
         public String toString() {
             String opt = name + (name.endsWith(":") ? "" : " ") + parameters;
-            int optlen = opt.length();
-            int spaces = 32 - optlen;
-            StringBuffer sb = new StringBuffer("  ").append(opt);
-            for (int i = 0; i < spaces; i++) {
+            StringBuffer sb = new StringBuffer("  ").append(opt).append(" ");
+            for (int i = opt.length(); i < 32; i++) {
                 sb.append(" ");
             }
             sb.append(description);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -47,11 +47,6 @@
 public interface ConstantsSummaryWriter {
 
     /**
-     * Close the writer.
-     */
-    public abstract void close() throws IOException;
-
-    /**
      * Get the header for the constant summary documentation.
      *
      * @return header that needs to be added to the documentation
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstructorWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -119,9 +119,4 @@
      * @param foundNonPubConstructor true if we found a non public constructor.
      */
     public void setFoundNonPubConstructor(boolean foundNonPubConstructor);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/EnumConstantWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/EnumConstantWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -112,9 +112,4 @@
      * @return content tree for the enum constants documentation
      */
     public Content getEnumConstants(Content enumConstantsTree, boolean isLastContent);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/FieldWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -113,9 +113,4 @@
      * @return content tree for the field documentation
      */
     public Content getFieldDoc(Content fieldDocTree, boolean isLastContent);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MemberSummaryWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MemberSummaryWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -122,9 +122,4 @@
      * @return a content tree for the member
      */
     public Content getMemberTree(Content memberTree);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2016, 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 jdk.javadoc.internal.doclets.toolkit;
+
+import javax.lang.model.element.Element;
+import javax.tools.Diagnostic;
+
+import com.sun.source.util.DocTreePath;
+import jdk.javadoc.doclet.Reporter;
+
+import static javax.tools.Diagnostic.Kind.*;
+
+/**
+ * Provides standardized access to the diagnostic reporting facilities
+ * for a doclet.
+ *
+ * Messages are specified by resource keys to be found in the doclet's
+ * {@link Resources resources}.  Values can be substituted into the
+ * strings obtained from the resource files.
+ *
+ * Messages are reported to the doclet's {@link Reporter reporter}.
+ */
+public class Messages {
+    private final Configuration configuration;
+    private final Resources resources;
+    private Reporter reporter;
+
+    /**
+     * Creates a {@code Messages} object to provide standardized access to
+     * the doclet's diagnostic reporting mechanisms.
+     *
+     * @param configuration the doclet's configuration, used to access
+     *  the doclet's resources, reporter, and additional methods and state
+     *  used to filter out messages, if any, which should be suppressed.
+     */
+    public Messages(Configuration configuration) {
+        this.configuration = configuration;
+        resources = configuration.getResources();
+    }
+
+    // ***** Errors *****
+
+    /**
+     * Reports an error message to the doclet's reporter.
+     *
+     * @param key the name of a resource containing the message to be printed
+     * @param args optional arguments to be replaced in the message.
+     */
+    public void error(String key, Object... args) {
+        report(ERROR, resources.getText(key, args));
+    }
+
+    /**
+     * Reports an error message to the doclet's reporter.
+     *
+     * @param path a path identifying the position to be included with
+     *  the message
+     * @param key the name of a resource containing the message to be printed
+     * @param args optional arguments to be replaced in the message.
+     */
+    public void error(DocTreePath path, String key, Object... args) {
+        report(ERROR, path, resources.getText(key, args));
+    }
+
+    // ***** Warnings *****
+
+    /**
+     * Reports a warning message to the doclet's reporter.
+     *
+     * @param key the name of a resource containing the message to be printed
+     * @param args optional arguments to be replaced in the message.
+     */
+    public void warning(String key, Object... args) {
+        report(WARNING, resources.getText(key, args));
+    }
+
+    /**
+     * Reports a warning message to the doclet's reporter.
+     *
+     * @param path a path identifying the position to be included with
+     *  the message
+     * @param key the name of a resource containing the message to be printed
+     * @param args optional arguments to be replaced in the message.
+     */
+    public void warning(DocTreePath path, String key, Object... args) {
+        if (configuration.showMessage(path, key))
+            report(WARNING, path, resources.getText(key, args));
+    }
+
+    /**
+     * Reports a warning message to the doclet's reporter.
+     *
+     * @param e an element identifying the declaration whose position should
+     *  to be included with the message
+     * @param key the name of a resource containing the message to be printed
+     * @param args optional arguments to be replaced in the message.
+     */
+    public void warning(Element e, String key, Object... args) {
+        if (configuration.showMessage(e, key)) {
+            report(WARNING, e, resources.getText(key, args));
+        }
+    }
+
+    // ***** Notices *****
+
+    /**
+     * Reports an informational notice to the doclet's reporter.
+     *
+     * @param key the name of a resource containing the message to be printed
+     * @param args optional arguments to be replaced in the message.
+     */
+    public void notice(String key, Object... args) {
+        if (!configuration.quiet) {
+            report(NOTE, resources.getText(key, args));
+        }
+    }
+
+    // ***** Internal support *****
+
+    private void report(Diagnostic.Kind k, String msg) {
+        initReporter();
+        reporter.print(k, msg);
+    }
+
+    private void report(Diagnostic.Kind k, DocTreePath p, String msg) {
+        initReporter();
+        reporter.print(k, p, msg);
+    }
+
+    private void report(Diagnostic.Kind k, Element e, String msg) {
+        initReporter();
+        reporter.print(k, e, msg);
+    }
+
+    // Lazy init the reporter for now, until we can fix/improve
+    // the init of ConfigurationImpl in HtmlDoclet (and similar.)
+    private void initReporter() {
+        if (reporter == null) {
+            reporter = configuration.reporter;
+        }
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/MethodWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -114,9 +114,4 @@
      * @return content tree for the method documentation
      */
     public Content getMethodDoc(Content methodDocTree, boolean isLastContent);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -132,10 +132,4 @@
      * @param contentTree the content tree that will be printed
      */
     public abstract void printDocument(Content contentTree) throws IOException;
-
-    /**
-     * Close the writer.
-     */
-    public abstract void close() throws IOException;
-
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/NestedClassWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/NestedClassWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -40,9 +40,4 @@
  */
 
 public interface NestedClassWriter {
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -121,9 +121,4 @@
      */
     public abstract void printDocument(Content contentTree) throws IOException;
 
-    /**
-     * Close the writer.
-     */
-    public abstract void close() throws IOException;
-
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PropertyWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -112,9 +112,4 @@
      * @return content tree for the property documentation
      */
     public Content getPropertyDoc(Content propertyDocTree, boolean isLastContent);
-
-    /**
-     * Close the writer.
-     */
-    public void close() throws IOException;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Resources.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2016, 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 jdk.javadoc.internal.doclets.toolkit;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Access to the localizable resources used by a doclet.
+ * The resources are split across two resource bundles:
+ * one that contains format-neutral strings common to
+ * all supported formats, and one that contains strings
+ * specific to the selected doclet, such as the standard
+ * HTML doclet.
+ */
+public class Resources {
+    private final Configuration configuration;
+    private final String commonBundleName;
+    private final String docletBundleName;
+
+    protected ResourceBundle commonBundle;
+    protected ResourceBundle docletBundle;
+
+    /**
+     * Creates a {@code Resources} to provide access the resource
+     * bundles used by a doclet.
+     *
+     * @param configuration the configuration for the doclet,
+     *  to provide access the locale to be used when accessing the
+     *  names resource bundles.
+     * @param commonBundleName the name of the bundle containing the strings
+     *  common to all output formats
+     * @param docletBundleName the name of the bundle containing the strings
+     *  specific to a particular format
+     */
+    public Resources(Configuration configuration, String commonBundleName, String docletBundleName) {
+        this.configuration = configuration;
+        this.commonBundleName = commonBundleName;
+        this.docletBundleName = docletBundleName;
+    }
+
+    /**
+     * Gets the string for the given key from one of the doclet's
+     * resource bundles.
+     *
+     * The more specific bundle is checked first;
+     * if it is not there, the common bundle is then checked.
+     *
+     * @param key the key for the desired string
+     * @return the string for the given key
+     * @throws MissingResourceException if the key is not found in either
+     *  bundle.
+     */
+    public String getText(String key) throws MissingResourceException {
+        initBundles();
+
+        if (docletBundle.containsKey(key))
+            return docletBundle.getString(key);
+
+        return commonBundle.getString(key);
+    }
+    /**
+     * Gets the string for the given key from one of the doclet's
+     * resource bundles, substituting additional arguments into
+     * into the resulting string with {@link MessageFormat#format}.
+     *
+     * The more specific bundle is checked first;
+     * if it is not there, the common bundle is then checked.
+     *
+     * @param key the key for the desired string
+     * @param args values to be substituted into the resulting string
+     * @return the string for the given key
+     * @throws MissingResourceException if the key is not found in either
+     *  bundle.
+     */
+    public String getText(String key, Object... args) throws MissingResourceException {
+        return MessageFormat.format(getText(key), args);
+    }
+
+    /**
+     * Lazily initializes the bundles. This is (currently) necessary because
+     * this object may be created before the locale to be used is known.
+     */
+    protected void initBundles() {
+        if (commonBundle == null) {
+            Locale locale = configuration.getLocale();
+            this.commonBundle = ResourceBundle.getBundle(commonBundleName, locale);
+            this.docletBundle = ResourceBundle.getBundle(docletBundleName, locale);
+        }
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -138,11 +138,6 @@
     public SerialMethodWriter getSerialMethodWriter(TypeElement typeElement);
 
     /**
-     * Close the writer.
-     */
-    public abstract void close() throws IOException;
-
-    /**
      * Get the serialized content.
      *
      * @param serializedTreeContent content for serialized data
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -33,6 +33,7 @@
 
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
@@ -89,6 +90,7 @@
      */
     protected final Configuration configuration;
 
+    protected final Messages messages;
     protected final Utils utils;
 
     /**
@@ -112,6 +114,7 @@
      */
     public AbstractBuilder(Context c) {
         this.configuration = c.configuration;
+        this.messages = configuration.getMessages();
         this.utils = configuration.utils;
         this.containingPackagesSeen = c.containingPackagesSeen;
         this.layoutParser = c.layoutParser;
@@ -144,13 +147,18 @@
                     new Class<?>[]{XMLNode.class, Content.class},
                     new Object[]{node, contentTree});
         } catch (NoSuchMethodException e) {
-            e.printStackTrace();
+            e.printStackTrace(System.err);
             configuration.reporter.print(ERROR, "Unknown element: " + component);
             throw new DocletAbortException(e);
         } catch (InvocationTargetException e) {
-            throw new DocletAbortException(e.getCause());
+            Throwable cause = e.getCause();
+            if (cause instanceof DocletAbortException) {
+                throw (DocletAbortException) cause;
+            } else {
+                throw new DocletAbortException(e.getCause());
+            }
         } catch (Exception e) {
-            e.printStackTrace();
+            e.printStackTrace(System.err);
             configuration.reporter.print(ERROR, "Exception " +
                     e.getClass().getName() +
                     " thrown while processing element: " + component);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -124,7 +124,6 @@
          writer.addAnnotationContentTree(contentTree, annotationContentTree);
          writer.addFooter(contentTree);
          writer.printDocument(contentTree);
-         writer.close();
          copyDocFiles();
      }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -152,7 +152,6 @@
          writer.addClassContentTree(contentTree, classContentTree);
          writer.addFooter(contentTree);
          writer.printDocument(contentTree);
-         writer.close();
          copyDocFiles();
      }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -153,7 +153,6 @@
         buildChildren(node, contentTree);
         writer.addFooter(contentTree);
         writer.printDocument(contentTree);
-        writer.close();
     }
 
     /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -132,7 +132,6 @@
         buildChildren(node, contentTree);
         moduleWriter.addModuleFooter(contentTree);
         moduleWriter.printDocument(contentTree);
-        moduleWriter.close();
         // TEMPORARY:
         // The use of SOURCE_PATH on the next line is temporary. As we transition into the
         // modules world, this should migrate into using a location for the appropriate module
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -131,7 +131,6 @@
         buildChildren(node, contentTree);
         packageWriter.addPackageFooter(contentTree);
         packageWriter.printDocument(contentTree);
-        packageWriter.close();
         utils.copyDocFiles(packageElement);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -140,7 +140,6 @@
             throw new DocletAbortException(e);
         }
         build(layoutParser.parseXML(NAME), contentTree);
-        writer.close();
     }
 
     /**
@@ -162,7 +161,6 @@
         buildChildren(node, serializedTree);
         writer.addFooter(serializedTree);
         writer.printDocument(serializedTree);
-        writer.close();
     }
 
     /**
@@ -362,7 +360,7 @@
                 && utils.getSerialDataTrees(method).isEmpty()) {
             if (configuration.serialwarn) {
                 TypeElement encl  = (TypeElement) method.getEnclosingElement();
-                configuration.getDocletSpecificMsg().warning(currentMember,
+                messages.warning(currentMember,
                         "doclet.MissingSerialDataTag", encl.getQualifiedName().toString(),
                         method.getSimpleName().toString());
             }
@@ -526,7 +524,7 @@
         // Process default Serializable field.
         if ((utils.getSerialTrees(field).isEmpty()) /*&& ! field.isSynthetic()*/
                 && configuration.serialwarn) {
-            configuration.message.warning(field,
+            messages.warning(field,
                     "doclet.MissingSerialTag", utils.getFullyQualifiedName(te),
                     utils.getSimpleName(field));
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,6 +31,7 @@
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Input;
@@ -135,6 +136,7 @@
             Element e, DocTree holderTag, boolean isFirstSentence) {
         Content replacement = writer.getOutputInstance();
         Configuration configuration = writer.configuration();
+        Messages messages = configuration.getMessages();
         Utils utils = configuration.utils;
         CommentHelper ch = utils.getCommentHelper(e);
         Taglet inheritableTaglet = holderTag == null
@@ -147,7 +149,7 @@
                         ? utils.flatSignature((ExecutableElement)e)
                         : "");
                 //This tag does not support inheritence.
-                configuration.message.warning(e, "doclet.noInheritedDoc", message);
+                messages.warning(e, "doclet.noInheritedDoc", message);
         }
         Input input = new DocFinder.Input(utils, e,
                 (InheritableTaglet) inheritableTaglet, new DocFinder.DocTreeInfo(holderTag, e),
@@ -165,7 +167,7 @@
                     ((utils.isExecutableElement(e))
                         ? utils.flatSignature((ExecutableElement)e)
                         : "");
-            configuration.message.warning(e, "doclet.noInheritedDoc", message);
+            messages.warning(e, "doclet.noInheritedDoc", message);
         }
         return replacement;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ParamTaglet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -34,6 +34,7 @@
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.ParamTree;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Input;
@@ -288,6 +289,7 @@
     private Content processParamTags(Element e, boolean isParams,
             List<? extends DocTree> paramTags, Map<String, String> rankMap, TagletWriter writer,
             Set<String> alreadyDocumented) {
+        Messages messages = writer.configuration().getMessages();
         Content result = writer.getOutputInstance();
         if (!paramTags.isEmpty()) {
             CommentHelper ch = writer.configuration().utils.getCommentHelper(e);
@@ -296,22 +298,22 @@
                         ? ch.getParameterName(dt)
                         : "<" + ch.getParameterName(dt) + ">";
                 if (!rankMap.containsKey(ch.getParameterName(dt))) {
-                    writer.getMsgRetriever().warning(ch.getDocTreePath(dt),
-                                                     isParams ?
-                                                     "doclet.Parameters_warn" :
-                                                     "doclet.Type_Parameters_warn",
-                                                     paramName);
+                    messages.warning(ch.getDocTreePath(dt),
+                            isParams
+                                    ? "doclet.Parameters_warn"
+                                    : "doclet.Type_Parameters_warn",
+                            paramName);
                 }
                 String rank = rankMap.get(ch.getParameterName(dt));
                 if (rank != null && alreadyDocumented.contains(rank)) {
-                    writer.getMsgRetriever().warning(ch.getDocTreePath(dt),
-                                                     isParams ?
-                                                     "doclet.Parameters_dup_warn" :
-                                                     "doclet.Type_Parameters_dup_warn",
-                                                     paramName);
+                    messages.warning(ch.getDocTreePath(dt),
+                            isParams
+                                    ? "doclet.Parameters_dup_warn"
+                                    : "doclet.Type_Parameters_dup_warn",
+                            paramName);
                 }
                 result.addContent(processParamTag(e, isParams, writer, dt,
-                                                  ch.getParameterName(dt), alreadyDocumented.isEmpty()));
+                        ch.getParameterName(dt), alreadyDocumented.isEmpty()));
                 alreadyDocumented.add(rank);
             }
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ReturnTaglet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ReturnTaglet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -34,6 +34,7 @@
 
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFinder;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFinder.Input;
@@ -87,6 +88,7 @@
      * {@inheritDoc}
      */
     public Content getTagletOutput(Element holder, TagletWriter writer) {
+        Messages messages = writer.configuration().getMessages();
         Utils utils = writer.configuration().utils;
         TypeMirror returnType = utils.getReturnType((ExecutableElement)holder);
         List<? extends DocTree> tags = utils.getBlockTags(holder, name);
@@ -94,7 +96,7 @@
         //Make sure we are not using @return tag on method with void return type.
         if (returnType != null && utils.isVoid(returnType)) {
             if (!tags.isEmpty()) {
-                writer.getMsgRetriever().warning(holder, "doclet.Return_tag_on_void_method");
+                messages.warning(holder, "doclet.Return_tag_on_void_method");
             }
             return null;
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java	Fri Aug 19 12:17:32 2016 -0700
@@ -26,7 +26,6 @@
 package jdk.javadoc.internal.doclets.toolkit.taglets;
 
 import java.io.*;
-import java.lang.reflect.Method;
 import java.util.*;
 
 import javax.lang.model.element.Element;
@@ -42,9 +41,11 @@
 import com.sun.source.doctree.DocTree;
 import com.sun.tools.javac.util.DefinedBy;
 import com.sun.tools.javac.util.DefinedBy.Api;
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
 
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
-import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
 import static javax.tools.DocumentationTool.Location.*;
@@ -126,10 +127,8 @@
      */
     private List<Taglet> serializedFormTags;
 
-    /**
-     * The message retriever that will be used to print error messages.
-     */
-    private final MessageRetriever message;
+    private final Messages messages;
+    private final Resources resources;
 
     /**
      * Keep track of standard tags.
@@ -191,7 +190,7 @@
      */
     public TagletManager(boolean nosince, boolean showversion,
                          boolean showauthor, boolean javafx,
-                         MessageRetriever message) {
+                         Configuration configuration) {
         overridenStandardTags = new HashSet<>();
         potentiallyConflictingTags = new HashSet<>();
         standardTags = new HashSet<>();
@@ -202,7 +201,8 @@
         this.showversion = showversion;
         this.showauthor = showauthor;
         this.javafx = javafx;
-        this.message = message;
+        this.messages = configuration.getMessages();
+        this.resources = configuration.getResources();
         initStandardTaglets();
         initStandardTagsLowercase();
     }
@@ -260,9 +260,9 @@
                 customTags.remove(tname);
             }
             customTags.put(tname, newLegacy);
-            message.notice("doclet.Notice_taglet_registered", classname);
+            messages.notice("doclet.Notice_taglet_registered", classname);
         } catch (Exception exc) {
-            message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
+            messages.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
         }
     }
 
@@ -359,10 +359,10 @@
             }
             if (! (standardTags.contains(name) || customTags.containsKey(name))) {
                 if (standardTagsLowercase.contains(Utils.toLowerCase(name))) {
-                    message.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag));
+                    messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTagLowercase", ch.getTagName(tag));
                     continue;
                 } else {
-                    message.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag));
+                    messages.warning(ch.getDocTreePath(tag), "doclet.UnknownTag", ch.getTagName(tag));
                     continue;
                 }
             }
@@ -481,7 +481,7 @@
             }
             combined_locations.append(locations[i]);
         }
-        message.warning(ch.getDocTreePath(tag), "doclet.tag_misuse",
+        messages.warning(ch.getDocTreePath(tag), "doclet.tag_misuse",
             "@" + taglet.getName(), holderType, combined_locations.toString());
     }
 
@@ -698,17 +698,17 @@
         addStandardTaglet(new ThrowsTaglet());
         addStandardTaglet(new SimpleTaglet(EXCEPTION.tagName, null,
                 SimpleTaglet.METHOD + SimpleTaglet.CONSTRUCTOR));
-        addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, message.getText("doclet.Since"),
+        addStandardTaglet(!nosince, new SimpleTaglet(SINCE.tagName, resources.getText("doclet.Since"),
                 SimpleTaglet.ALL));
-        addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, message.getText("doclet.Version"),
+        addStandardTaglet(showversion, new SimpleTaglet(VERSION.tagName, resources.getText("doclet.Version"),
                 SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
-        addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, message.getText("doclet.Author"),
+        addStandardTaglet(showauthor, new SimpleTaglet(AUTHOR.tagName, resources.getText("doclet.Author"),
                 SimpleTaglet.MODULE + SimpleTaglet.PACKAGE + SimpleTaglet.TYPE + SimpleTaglet.OVERVIEW));
-        addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, message.getText("doclet.SerialData"),
+        addStandardTaglet(new SimpleTaglet(SERIAL_DATA.tagName, resources.getText("doclet.SerialData"),
                 SimpleTaglet.EXCLUDED));
-        addStandardTaglet(new SimpleTaglet(HIDDEN.tagName, message.getText("doclet.Hidden"),
+        addStandardTaglet(new SimpleTaglet(HIDDEN.tagName, resources.getText("doclet.Hidden"),
                 SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE));
-        customTags.put((temp = new SimpleTaglet("factory", message.getText("doclet.Factory"),
+        customTags.put((temp = new SimpleTaglet("factory", resources.getText("doclet.Factory"),
                 SimpleTaglet.METHOD)).getName(), temp);
         addStandardTaglet(new SeeTaglet());
         //Standard inline tags
@@ -735,9 +735,9 @@
         addStandardTaglet(new PropertyGetterTaglet());
         addStandardTaglet(new PropertySetterTaglet());
         addStandardTaglet(new SimpleTaglet("propertyDescription",
-                message.getText("doclet.PropertyDescription"),
+                resources.getText("doclet.PropertyDescription"),
                 SimpleTaglet.FIELD + SimpleTaglet.METHOD));
-        addStandardTaglet(new SimpleTaglet("defaultValue", message.getText("doclet.DefaultValue"),
+        addStandardTaglet(new SimpleTaglet("defaultValue", resources.getText("doclet.DefaultValue"),
             SimpleTaglet.FIELD + SimpleTaglet.METHOD));
         addStandardTaglet(new SimpleTaglet("treatAsPrivate", null,
                 SimpleTaglet.FIELD + SimpleTaglet.METHOD + SimpleTaglet.TYPE));
@@ -790,7 +790,7 @@
                     result += ", ";
                 }
             }
-            message.notice(noticeKey, result);
+            messages.notice(noticeKey, result);
         }
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -36,7 +36,6 @@
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.taglets.Taglet.UnsupportedTagletOperationException;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
-import jdk.javadoc.internal.doclets.toolkit.util.MessageRetriever;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
 /**
@@ -107,13 +106,6 @@
     protected abstract Content literalTagOutput(Element element, DocTree tag);
 
     /**
-     * Returns {@link MessageRetriever} for output purposes.
-     *
-     * @return {@link MessageRetriever} for output purposes.
-     */
-    protected abstract MessageRetriever getMsgRetriever();
-
-    /**
      * Return the header for the param tags.
      *
      * @param header the header to display.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -34,6 +34,7 @@
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
@@ -181,15 +182,16 @@
      */
     public Content getTagletOutput(Element holder, DocTree tag, TagletWriter writer) {
         Utils utils = writer.configuration().utils;
+        Messages messages = writer.configuration().getMessages();
         VariableElement field = getVariableElement(holder, writer.configuration(), tag);
         if (field == null) {
             if (tag.toString().isEmpty()) {
                 //Invalid use of @value
-                writer.getMsgRetriever().warning(holder,
+                messages.warning(holder,
                         "doclet.value_tag_invalid_use");
             } else {
                 //Reference is unknown.
-                writer.getMsgRetriever().warning(holder,
+                messages.warning(holder,
                         "doclet.value_tag_invalid_reference", tag.toString());
             }
         } else if (field.getConstantValue() != null) {
@@ -202,7 +204,7 @@
             );
         } else {
             //Referenced field is not a constant.
-            writer.getMsgRetriever().warning(holder,
+            messages.warning(holder,
                 "doclet.value_tag_invalid_constant", utils.getSimpleName(field));
         }
         return writer.getOutputInstance();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java	Fri Aug 19 12:17:32 2016 -0700
@@ -44,6 +44,7 @@
 
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 /**
  * Build Class Hierarchy for all the Classes. This class builds the Class
@@ -105,9 +106,12 @@
      * true.
      */
     public ClassTree(Configuration configuration, boolean noDeprecated) {
-        configuration.message.notice("doclet.Building_Tree");
         this.configuration = configuration;
         this.utils = configuration.utils;
+
+        Messages messages = configuration.getMessages();
+        messages.notice("doclet.Building_Tree");
+
         comparator = utils.makeClassUseComparator();
         baseAnnotationTypes = new TreeSet<>(comparator);
         baseEnums = new TreeSet<>(comparator);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,6 +31,7 @@
 import javax.lang.model.element.PackageElement;
 
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 
 /**
@@ -87,6 +88,7 @@
      * The global configuration information for this run.
      */
     private final Configuration configuration;
+    private Messages messages;
 
     /**
      * Since we need to sort the keys in the reverse order(longest key first),
@@ -101,6 +103,7 @@
 
     public Group(Configuration configuration) {
         this.configuration = configuration;
+        messages = configuration.getMessages();
     }
 
     /**
@@ -120,14 +123,16 @@
     public boolean checkPackageGroups(String groupname, String pkgNameFormList) {
         StringTokenizer strtok = new StringTokenizer(pkgNameFormList, ":");
         if (groupList.contains(groupname)) {
-            configuration.message.warning("doclet.Groupname_already_used", groupname);
+            initMessages();
+            messages.warning("doclet.Groupname_already_used", groupname);
             return false;
         }
         groupList.add(groupname);
         while (strtok.hasMoreTokens()) {
             String id = strtok.nextToken();
             if (id.length() == 0) {
-                configuration.message.warning("doclet.Error_in_packagelist", groupname, pkgNameFormList);
+                initMessages();
+                messages.warning("doclet.Error_in_packagelist", groupname, pkgNameFormList);
                 return false;
             }
             if (id.endsWith("*")) {
@@ -148,6 +153,14 @@
         return true;
     }
 
+    // Lazy init of the messages for now, because Group is created
+    // in Configuration before configuration is fully initialized.
+    private void initMessages() {
+        if (messages == null) {
+            messages = configuration.getMessages();
+        }
+    }
+
     /**
      * Search if the given map has given the package format.
      *
@@ -158,7 +171,8 @@
      */
     boolean foundGroupFormat(Map<String,?> map, String pkgFormat) {
         if (map.containsKey(pkgFormat)) {
-            configuration.message.error("doclet.Same_package_name_used", pkgFormat);
+            initMessages();
+            messages.error("doclet.Same_package_name_used", pkgFormat);
             return true;
         }
         return false;
@@ -181,8 +195,8 @@
         Map<String, SortedSet<PackageElement>> groupPackageMap = new HashMap<>();
         String defaultGroupName =
             (pkgNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())?
-                configuration.message.getText("doclet.Packages") :
-                configuration.message.getText("doclet.Other_Packages");
+                configuration.getResources().getText("doclet.Packages") :
+                configuration.getResources().getText("doclet.Other_Packages");
         // if the user has not used the default group name, add it
         if (!groupList.contains(defaultGroupName)) {
             groupList.add(defaultGroupName);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java	Fri Aug 19 12:17:32 2016 -0700
@@ -33,6 +33,7 @@
 
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 /**
  * Build the mapping of each Unicode character with it's member lists
@@ -98,11 +99,14 @@
                         boolean classesOnly) {
         this.configuration  = configuration;
         this.utils = configuration.utils;
+
+        Messages messages = configuration.getMessages();
         if (classesOnly) {
-            configuration.message.notice("doclet.Building_Index_For_All_Classes");
+            messages.notice("doclet.Building_Index_For_All_Classes");
         } else {
-            configuration.message.notice("doclet.Building_Index");
+            messages.notice("doclet.Building_Index");
         }
+
         this.noDeprecated = noDeprecated;
         this.classesOnly = classesOnly;
         this.javafx = configuration.javafx;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MessageRetriever.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 1998, 2016, 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 jdk.javadoc.internal.doclets.toolkit.util;
-
-import java.text.MessageFormat;
-import java.util.*;
-
-import javax.lang.model.element.Element;
-
-import com.sun.source.util.DocTreePath;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
-
-import static javax.tools.Diagnostic.Kind.*;
-
-
-/**
- * Retrieve and format messages stored in a resource.
- *
- *  <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>
- *
- * @author Atul M Dambalkar
- * @author Robert Field
- */
-public class MessageRetriever {
-    /**
-     * The global configuration information for this run.
-     */
-    private final Configuration configuration;
-
-    /**
-     * The location from which to lazily fetch the resource..
-     */
-    private final String resourcelocation;
-
-    /**
-     * The lazily fetched resource..
-     */
-    private ResourceBundle messageRB;
-
-    /**
-     * Initialize the ResourceBundle with the given resource.
-     *
-     * @param rb the resource bundle to read.
-     */
-    public MessageRetriever(ResourceBundle rb) {
-        this.configuration = null;
-        this.messageRB = rb;
-        this.resourcelocation = null;
-    }
-
-    /**
-     * Initialize the ResourceBundle with the given resource.
-     *
-     * @param configuration the configuration
-     * @param resourcelocation Resource.
-     */
-    public MessageRetriever(Configuration configuration,
-                            String resourcelocation) {
-        this.configuration = configuration;
-        this.resourcelocation = resourcelocation;
-    }
-
-    private ResourceBundle initRB() {
-        ResourceBundle bundle = messageRB;
-        if (bundle == null) {
-            try {
-                messageRB = bundle =
-                        ResourceBundle.getBundle(resourcelocation, configuration.getLocale());
-            } catch (MissingResourceException e) {
-                throw new Error("Fatal: Resource (" + resourcelocation
-                        + ") for javadoc doclets is missing.");
-            }
-        }
-        return bundle;
-    }
-
-    /**
-     * Determines whether the given <code>key</code> can be retrieved
-     * from this <code>MessageRetriever</code>
-     *
-     * @param key
-     *        the resource <code>key</code>
-     * @return <code>true</code> if the given <code>key</code> is
-     *        contained in the underlying <code>ResourceBundle</code>.
-     */
-    public boolean containsKey(String key) {
-        ResourceBundle bundle = initRB();
-        return bundle.containsKey(key);
-    }
-
-    /**
-     * Get and format message string from resource
-     *
-     * @param key selects message from resource
-     * @param args arguments to be replaced in the message.
-     * @return the composed text
-     * @throws MissingResourceException when the key does not
-     * exist in the properties file.
-     */
-    public String getText(String key, Object... args) throws MissingResourceException {
-        ResourceBundle bundle = initRB();
-        String message = bundle.getString(key);
-        return MessageFormat.format(message, args);
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param pos the position of the source
-     * @param msg message to print
-     */
-    private void printError(DocTreePath path, String msg) {
-        configuration.reporter.print(ERROR, path, msg);
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param msg message to print
-     */
-    private void printError(String msg) {
-        configuration.reporter.print(ERROR, msg);
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param pos the position of the source
-     * @param msg message to print
-     */
-    private void printWarning(DocTreePath path, String msg) {
-        configuration.reporter.print(WARNING, path, msg);
-    }
-
-    private void printWarning(Element e, String msg) {
-        configuration.reporter.print(WARNING, e, msg);
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param msg message to print
-     */
-    private void printWarning(String msg) {
-        configuration.reporter.print(WARNING, msg);
-    }
-
-//    Note: the following do not appear to be needed any more, delete me.
-//    /**
-//     * Print a message.
-//     *
-//     * @param pos the position of the source
-//     * @param msg message to print
-//     */
-//    private void printNotice(DocTreePath path, String msg) {
-//        DocEnv env = ((RootDocImpl)configuration.root).env;
-//        if (env.isQuiet() || env.isSilent()) {
-//            return;
-//        }
-//        configuration.reporter.print(NOTE, path, msg);
-//    }
-
-//    Note: does not appear to be needed any more.
-//    /**
-//     * Print a message.
-//     *
-//     * @param pos the position of the source
-//     * @param key selects message from resource
-//     * @param args arguments to be replaced in the message.
-//     */
-//    public void notice(DocTreePath path, String key, Object... args) {
-//        printNotice(path, getText(key, args));
-//    }
-
-    // ERRORS
-    /**
-     * Print error message, increment error count.
-     *
-     * @param path the path to the source
-     * @param key selects message from resource
-     * @param args arguments to be replaced in the message.
-     */
-    public void error(DocTreePath path, String key, Object... args) {
-        printError(path, getText(key, args));
-    }
-
-    /**
-     * Print error message, increment error count.
-     *
-     * @param key selects message from resource
-     * @param args arguments to be replaced in the message.
-     */
-    public void error(String key, Object... args) {
-        printError(getText(key, args));
-    }
-
-    // WARNINGS
-    /**
-     * Print warning message, increment warning count.
-
-     * @param path the path to the source
-     * @param key selects message from resource
-     * @param args arguments to be replaced in the message.
-     */
-    public void warning(DocTreePath path, String key, Object... args) {
-        if (configuration.showMessage(path, key))
-            printWarning(path, getText(key, args));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param e element target of the message
-     * @param key selects message from resource
-     * @param args arguments to be replaced in the message.
-     */
-    public void warning(Element e, String key, Object... args) {
-        if (configuration.showMessage(e, key))
-            printWarning(e, getText(key, args));
-    }
-
-    /**
-     * Print warning message, increment warning count.
-     *
-     * @param key selects message from resource
-     * @param args arguments to be replaced in the message.
-     */
-    public void warning(String key, Object... args) {
-        printWarning(getText(key, args));
-    }
-
-    // NOTICES
-    /**
-     * Print a message.
-     *
-     * @param msg message to print
-     */
-    private void printNotice(String msg) {
-        if (configuration.quiet) {
-            return;
-        }
-        configuration.reporter.print(NOTE, msg);
-    }
-
-    /**
-     * Print a message.
-     *
-     * @param key selects message from resource
-     * @param args arguments to be replaced in the message.
-     */
-    public void notice(String key, Object... args) {
-        printNotice(getText(key, args));
-    }
-}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,6 +32,7 @@
 
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 
 /**
@@ -73,7 +74,8 @@
             packgen.generatePackageListFile(configuration.docEnv);
             packgen.close();
         } catch (IOException exc) {
-            configuration.message.error("doclet.exception_encountered",
+            Messages messages = configuration.getMessages();
+            messages.error("doclet.exception_encountered",
                 exc.toString(), DocPaths.PACKAGE_LIST);
             throw new DocletAbortException(exc);
         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Fri Aug 19 12:17:32 2016 -0700
@@ -85,7 +85,10 @@
 import static javax.lang.model.type.TypeKind.*;
 
 import static com.sun.source.doctree.DocTree.Kind.*;
+
 import com.sun.source.util.SimpleDocTreeVisitor;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
+
 import static jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.MAX_CONSTANT_VALUE_INDEX_LENGTH;
 
 
@@ -102,12 +105,14 @@
  */
 public class Utils {
     public final Configuration configuration;
+    public final Messages messages;
     public final DocTrees docTrees;
     public final Elements elementUtils;
     public final Types typeUtils;
 
     public Utils(Configuration c) {
         configuration = c;
+        messages = configuration.getMessages();
         elementUtils = c.docEnv.getElementUtils();
         typeUtils = c.docEnv.getTypeUtils();
         docTrees = c.docEnv.getDocTrees();
@@ -293,11 +298,10 @@
                     DocFile destfile = destdir.resolve(srcfile.getName());
                     if (srcfile.isFile()) {
                         if (destfile.exists() && !first) {
-                            configuration.message.warning("doclet.Copy_Overwrite_warning",
+                            messages.warning("doclet.Copy_Overwrite_warning",
                                     srcfile.getPath(), destdir.getPath());
                         } else {
-                            configuration.message.notice(
-                                    "doclet.Copying_File_0_To_Dir_1",
+                            messages.notice("doclet.Copying_File_0_To_Dir_1",
                                     srcfile.getPath(), destdir.getPath());
                             destfile.copyFile(srcfile);
                         }
@@ -1577,11 +1581,10 @@
                     DocFile destfile = destdir.resolve(srcfile.getName());
                     if (srcfile.isFile()) {
                         if (destfile.exists() && !first) {
-                            configuration.message.warning("doclet.Copy_Overwrite_warning",
+                            messages.warning("doclet.Copy_Overwrite_warning",
                                     srcfile.getPath(), destdir.getPath());
                         } else {
-                            configuration.message.notice(
-                                    "doclet.Copying_File_0_To_Dir_1",
+                            messages.notice("doclet.Copying_File_0_To_Dir_1",
                                     srcfile.getPath(), destdir.getPath());
                             destfile.copyFile(srcfile);
                         }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java	Fri Aug 19 12:17:32 2016 -0700
@@ -39,6 +39,7 @@
 import com.sun.source.doctree.DocTree;
 
 import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 /**
  * A data structure that encapsulates the visible members of a particular
@@ -126,6 +127,7 @@
      * The configuration this VisibleMemberMap was created with.
      */
     private final Configuration configuration;
+    private final Messages messages;
     private final Utils utils;
     private final Comparator<Element> comparator;
 
@@ -149,6 +151,7 @@
         this.typeElement = typeElement;
         this.kind = kind;
         this.configuration = configuration;
+        this.messages = configuration.getMessages();
         this.utils = configuration.utils;
         propertiesCache = configuration.propertiesCache;
         classPropertiesMap = configuration.classPropertiesMap;
@@ -697,7 +700,7 @@
                                 || tagName.equals("@propertyGetter")
                                 || tagName.equals("@propertyDescription")) {
                             if (!isPropertyGetterOrSetter(members, ee)) {
-                                configuration.message.warning(ch.getDocTreePath(tree),
+                                messages.warning(ch.getDocTreePath(tree),
                                         "doclet.javafx_tag_misuse");
                             }
                             break;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Fri Aug 19 12:17:32 2016 -0700
@@ -190,7 +190,7 @@
             // Parse file objects provide via the DocumentationTool API
             parse(fileObjects, classTrees, true);
 
-            modules.initModules(classTrees.toList(), Collections.emptySet(), Collections.emptySet());
+            modules.initModules(classTrees.toList());
 
             // Build up the complete list of any packages to be documented
             Location location = modules.multiModuleMode ? StandardLocation.MODULE_SOURCE_PATH
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Fri Aug 19 12:17:32 2016 -0700
@@ -172,7 +172,7 @@
     }
 
     void usage(boolean exit) {
-        usage("main.usage", "-help", null, exit);
+        usage("main.usage", "-help", "main.usage.foot", exit);
     }
 
     @Override
@@ -355,14 +355,14 @@
             ((BaseFileManager) fileManager).handleOptions(fileManagerOpts);
         }
 
-        String platformString = compOpts.get("-release");
+        String platformString = compOpts.get("--release");
 
         if (platformString != null) {
             if (compOpts.isSet("-source")) {
                 usageError("main.release.bootclasspath.conflict", "-source");
             }
-            if (fileManagerOpts.containsKey(BOOTCLASSPATH)) {
-                usageError("main.release.bootclasspath.conflict", BOOTCLASSPATH.getText());
+            if (fileManagerOpts.containsKey(BOOT_CLASS_PATH)) {
+                usageError("main.release.bootclasspath.conflict", BOOT_CLASS_PATH.getPrimaryName());
             }
 
             PlatformDescription platformDescription =
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Fri Aug 19 12:17:32 2016 -0700
@@ -49,21 +49,28 @@
     BOOTCLASSPATH("-bootclasspath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
+            helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
     CLASSPATH("-classpath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CLASSPATH, arg);
+            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
         }
     },
 
     CP("-cp", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CP, arg);
+            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
+        }
+    },
+
+    CLASS_PATH("--class-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
         }
     },
 
@@ -77,28 +84,49 @@
     SOURCEPATH("-sourcepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.SOURCEPATH, arg);
+            helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
+        }
+    },
+
+    SOURCE_PATH("--source-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
         }
     },
 
     SYSCLASSPATH("-sysclasspath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.BOOTCLASSPATH, arg);
+            helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
     MODULESOURCEPATH("-modulesourcepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.MODULESOURCEPATH, arg);
+            helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
+        }
+    },
+
+    MODULE_SOURCE_PATH("--module-source-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
         }
     },
 
     UPGRADEMODULEPATH("-upgrademodulepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.UPGRADEMODULEPATH, arg);
+            helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
+        }
+    },
+
+    UPGRADE_MODULE_PATH("--upgrade-module-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
         }
     },
 
@@ -109,24 +137,59 @@
         }
     },
 
+    SYSTEM_("--system", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.SYSTEM, arg);
+        }
+    },
+
     MODULEPATH("-modulepath", true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.MODULEPATH, arg);
+            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
+        }
+    },
+
+    MODULE_PATH("--module-path", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
+        }
+    },
+
+    P("-p", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
         }
     },
 
     ADDMODS("-addmods", true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.ADDMODS.process(helper.getOptionHelper(), opt, arg);
+            Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
+    ADD_MODULES("--add-modules", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
         }
     },
 
     LIMITMODS("-limitmods", true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.LIMITMODS.process(helper.getOptionHelper(), opt, arg);
+            Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
+    LIMIT_MODULES("--limit-modules", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
         }
     },
 
@@ -138,7 +201,14 @@
         }
     },
 
-    RELEASE("-release", true) {
+    RELEASE("--release", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
+    RELEASE_OLD("-release", true) {
         @Override
         public void process(Helper helper, String arg) {
             Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
@@ -169,14 +239,28 @@
     XADDREADS("-XaddReads:", false) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.XADDREADS.process(helper.getOptionHelper(), arg);
+            Option.ADD_READS.process(helper.getOptionHelper(), arg);
+        }
+    },
+
+    ADD_READS("--add-reads", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_READS.process(helper.getOptionHelper(), opt, arg);
         }
     },
 
-    XADDEXPORTS("-XaddExports:", false) {
+    ADDEXPORTS("-XaddExports:", false) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.XADDEXPORTS.process(helper.getOptionHelper(), arg);
+            Option.ADD_EXPORTS.process(helper.getOptionHelper(), arg);
+        }
+    },
+
+    ADD_EXPORTS("--add-exports", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg);
         }
     },
 
@@ -194,6 +278,13 @@
         }
     },
 
+    PATCH_MODULE("--patch-module", true) {
+        @Override
+        public void process(Helper helper, String arg) {
+            Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg);
+        }
+    },
+
     // ----- doclet options -----
 
     DOCLET("-doclet", true), // handled in setDocletInvoker
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -37,21 +37,27 @@
 \  -help                            Display command line options and exit\n\
 \  -doclet <class>                  Generate output via alternate doclet\n\
 \  -docletpath <path>               Specify where to find doclet class files\n\
-\  -modulesourcepath <path>         Specify where to find input source files for multiple modules\n\
-\  -upgrademodulepath <path>        Override location of upgradeable modules\n\
-\  -modulepath <path>               Specify where to find application modules\n\
-\  -mp <path>                       Specify where to find application modules\n\
-\  -addmods <module>(,<module>)*    Root modules to resolve in addition to the initial modules,\n\
+\  --module-source-path <path>      Specify where to find input source files for multiple modules\n\
+\  --upgrade-module-path <path>     Override location of upgradeable modules\n\
+\  --module-path <path>, -p <path>  Specify where to find application modules\n\
+\  --add-modules <module>(,<module>)*\n\
+\                                   Root modules to resolve in addition to the initial modules,\n\
 \                                   or all modules on the module path if <module> is ALL-MODULE-PATH.\n\
-\  -limitmods <module>(,<module>)*  Limit the universe of observable modules\n\
-\  -sourcepath <pathlist>           Specify where to find source files\n\
-\  -classpath <pathlist>            Specify where to find user class files\n\
-\  -cp <pathlist>                   Specify where to find user class files\n\
+\  --limit-modules <module>(,<module>)*\n\
+\                                   Limit the universe of observable modules\n\
+\  --source-path <path>             Specify where to find source files\n\
+\  -sourcepath <path>               Specify where to find source files\n\
+\  --class-path <path>              Specify where to find user class files\n\
+\  -classpath <path>                Specify where to find user class files\n\
+\  -cp <path>                       Specify where to find user class files\n\
 \  -exclude <pkglist>               Specify a list of packages to exclude\n\
 \  -subpackages <subpkglist>        Specify subpackages to recursively load\n\
 \  -breakiterator                   Compute first sentence with BreakIterator\n\
-\  -bootclasspath <pathlist>        Override location of class files loaded\n\
-\                                   by the bootstrap class loader\n\
+\  -bootclasspath <path>            Override location of platform class files\n\
+\                                   used for non-modular releases\n\
+\  --system <jdk>                   Override location of system modules used\n\
+\                                   for modular releases.\n\
+\  --release <release>              Provide source compatibility with specified release\n\
 \  -source <release>                Provide source compatibility with specified release\n\
 \  -extdirs <dirlist>               Override location of installed extensions\n\
 \  -verbose                         Output messages about what Javadoc is doing\n\
@@ -61,19 +67,23 @@
 \  -J<flag>                         Pass <flag> directly to the runtime system\n\
 \  -X                               Print a synopsis of nonstandard options and exit\n
 
+main.usage.foot=\n\
+GNU-style options may use '=' instead whitespace to separate the name of an option\n\
+from its value.\n
+
 main.Xusage=\
 \  -Xmaxerrs <number>               Set the maximum number of errors to print\n\
 \  -Xmaxwarns <number>              Set the maximum number of warnings to print\n\
-\  -XaddExports:<module>/<package>=<other-module>(,<other-module>)*\n\
+\  --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
 \                                   Specify a package to be considered as exported from its \n\
 \                                   defining module to additional modules, or to all unnamed \n\
 \                                   modules if <other-module> is ALL-UNNAMED.\n\
-\  -XaddReads:<module>=<other-module>(,<other-module>)*\n\
+\  --add-reads <module>=<other-module>(,<other-module>)*\n\
 \                                   Specify additional modules to be considered as required by a\n\
 \                                   given module. <other-module> may be ALL-UNNAMED to require\n\
 \                                   the unnamed module.\n\
 \  -Xmodule:<module-name>           Specify a module to which the classes being compiled belong.\n\
-\  -Xpatch:<module>=<file>(:<file>)*\n\
+\  --patch-module <module>=<file>(:<file>)*\n\
 \                                   Override or augment a module with classes and resources\n\
 \                                   in JAR files or directories\n\
 \  -Xold                            Invoke the legacy javadoc tool\n
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Fri Aug 19 12:17:32 2016 -0700
@@ -126,24 +126,28 @@
     static final Option[] recognizedOptions = {
 
         new Option(false, "-help", "--help", "-?") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.help = true;
             }
         },
 
         new Option(false, "-version") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.version = true;
             }
         },
 
         new Option(false, "-fullversion") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.fullVersion = true;
             }
         },
 
         new Option(false, "-v", "-verbose", "-all") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.verbose = true;
                 task.options.showDescriptors = true;
@@ -153,12 +157,14 @@
         },
 
         new Option(false, "-l") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.showLineAndLocalVariableTables = true;
             }
         },
 
         new Option(false, "-public") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.accessOptions.add(opt);
                 task.options.showAccess = AccessFlags.ACC_PUBLIC;
@@ -166,6 +172,7 @@
         },
 
         new Option(false, "-protected") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.accessOptions.add(opt);
                 task.options.showAccess = AccessFlags.ACC_PROTECTED;
@@ -173,6 +180,7 @@
         },
 
         new Option(false, "-package") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.accessOptions.add(opt);
                 task.options.showAccess = 0;
@@ -180,6 +188,7 @@
         },
 
         new Option(false, "-p", "-private") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 if (!task.options.accessOptions.contains("-p") &&
                         !task.options.accessOptions.contains("-private")) {
@@ -190,24 +199,28 @@
         },
 
         new Option(false, "-c") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.showDisassembled = true;
             }
         },
 
         new Option(false, "-s") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.showDescriptors = true;
             }
         },
 
         new Option(false, "-sysinfo") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.sysInfo = true;
             }
         },
 
         new Option(false, "-XDdetails") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
             }
@@ -221,6 +234,7 @@
                 return sep != -1 && super.matches(opt.substring(0, sep + 1));
             }
 
+            @Override
             void process(JavapTask task, String opt, String arg) throws BadArgs {
                 int sep = opt.indexOf(":");
                 for (String v: opt.substring(sep + 1).split("[,: ]+")) {
@@ -258,12 +272,14 @@
         },
 
         new Option(false, "-constants") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.showConstants = true;
             }
         },
 
         new Option(false, "-XDinner") {
+            @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.showInnerClasses = true;
             }
@@ -276,6 +292,7 @@
                 return sep != -1 && super.matches(opt.substring(0, sep + 1));
             }
 
+            @Override
             void process(JavapTask task, String opt, String arg) throws BadArgs {
                 int sep = opt.indexOf(":");
                 try {
@@ -294,6 +311,7 @@
                 return sep != -1 && super.matches(opt.substring(0, sep + 1));
             }
 
+            @Override
             void process(JavapTask task, String opt, String arg) throws BadArgs {
                 int sep = opt.indexOf(":");
                 try {
@@ -305,7 +323,7 @@
             }
         },
 
-        new Option(true, "-m") {
+        new Option(true, "--module", "-m") {
             @Override
             void process(JavapTask task, String opt, String arg) throws BadArgs {
                 task.options.moduleName = arg;
@@ -929,21 +947,26 @@
     private void showHelp() {
         printLines(getMessage("main.usage", progname));
         for (Option o: recognizedOptions) {
-            String name = o.aliases[0].substring(1); // there must always be at least one name
+            String name = o.aliases[0].replaceAll("^-+", "").replaceAll("-+", "_"); // there must always be at least one name
             if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify"))
                 continue;
             printLines(getMessage("main.opt." + name));
         }
+
         String[] fmOptions = {
-            "-classpath", "-cp", "-bootclasspath",
-            "-upgrademodulepath", "-system", "-modulepath" };
+            "--module-path", "--system",
+            "--class-path", "-classpath", "-cp",
+            "-bootclasspath"
+        };
+
         for (String o: fmOptions) {
             if (fileManager.isSupportedOption(o) == -1)
                 continue;
-            String name = o.substring(1);
+            String name = o.replaceAll("^-+", "").replaceAll("-+", "_");
             printLines(getMessage("main.opt." + name));
         }
 
+        printLines(getMessage("main.usage.foot"));
     }
 
     private void showVersion(boolean full) {
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -41,61 +41,73 @@
 
 
 main.opt.help=\
-\  -help  --help  -?        Print this usage message
+\  -help  --help  -?                Print this usage message
 
 main.opt.version=\
-\  -version                 Version information
+\  -version                         Version information
 
 main.opt.v=\
-\  -v  -verbose             Print additional information
+\  -v  -verbose                     Print additional information
 
 main.opt.l=\
-\  -l                       Print line number and local variable tables
+\  -l                               Print line number and local variable tables
 
 main.opt.public=\
-\  -public                  Show only public classes and members
+\  -public                          Show only public classes and members
 
 main.opt.protected=\
-\  -protected               Show protected/public classes and members
+\  -protected                       Show protected/public classes and members
 
 main.opt.package=\
-\  -package                 Show package/protected/public classes\n\
-\                           and members (default)
+\  -package                         Show package/protected/public classes\n\
+\                                   and members (default)
 
 main.opt.p=\
-\  -p  -private             Show all classes and members
+\  -p  -private                     Show all classes and members
 
 main.opt.c=\
-\  -c                       Disassemble the code
+\  -c                               Disassemble the code
 
 main.opt.s=\
-\  -s                       Print internal type signatures
+\  -s                               Print internal type signatures
+
+main.opt.class_path=\
+\  --class-path <path>              Specify where to find user class files
 
 main.opt.classpath=\
-\  -classpath <path>        Specify where to find user class files
+\  -classpath <path>                Specify where to find user class files
 
 main.opt.cp=\
-\  -cp <path>               Specify where to find user class files
+\  -cp <path>                       Specify where to find user class files
 
 main.opt.bootclasspath=\
-\  -bootclasspath <path>    Override location of bootstrap class files
+\  -bootclasspath <path>            Override location of bootstrap class files
 
-main.opt.upgrademodulepath=\
-\  -upgrademodulepath <path>    Specify where to find upgradeable modules
+main.opt.upgrade_module_path=\
+\  --upgrade-module-path <path>     Specify where to find upgradeable modules
 
 main.opt.system=\
-\  -system <jdk>            Specify where to find system modules
+\  --system <jdk>                   Specify where to find system modules
 
-main.opt.modulepath=\
-\  -modulepath <path>       Specify where to find application modules
+main.opt.module_path=\
+\  --module-path <path>             Specify where to find application modules
 
 main.opt.constants=\
-\  -constants               Show final constants
-
+\  -constants                       Show final constants
 
 main.opt.sysinfo=\
-\  -sysinfo                 Show system info (path, size, date, MD5 hash)\n\
-\                           of class being processed
+\  -sysinfo                         Show system info (path, size, date, MD5 hash)\n\
+\                                   of class being processed
+
+main.opt.module=\
+\  --module <module>, -m <module>   Specify module containing classes to be disassembled
 
-main.opt.m=\
-\  -m <module-name>         Specify module containing classes to be disassembled
+main.usage.foot=\n\
+GNU-style options may use '=' instead of whitespace to separate the name of an option\n\
+from its value.\n\
+\n\
+Each class to be shown may be specified by a filename, a URL, or by its fully\n\
+qualified class name. Examples:\n\
+\   path/to/MyClass.class\n\
+\   jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class\n\
+\   java.lang.Object\n
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java	Fri Aug 19 12:17:32 2016 -0700
@@ -514,7 +514,7 @@
         }
 
         /*
-         * This method is for -check option to find all target modules specified
+         * This method is for --check option to find all target modules specified
          * in qualified exports.
          *
          * Include all system modules and modules found on modulepath
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Fri Aug 19 12:17:32 2016 -0700
@@ -144,7 +144,7 @@
     }
 
     static Option[] recognizedOptions = {
-        new Option(false, "-h", "-?", "-help") {
+        new Option(false, "-h", "-?", "-help", "--help") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.help = true;
             }
@@ -195,14 +195,14 @@
                 task.options.apiOnly = true;
             }
         },
-        new Option(true, "-check") {
+        new Option(true, "--check") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 Set<String> mods =  Set.of(arg.split(","));
                 task.options.checkModuleDeps = mods;
                 task.options.addmods.addAll(mods);
             }
         },
-        new Option(true, "-genmoduleinfo") {
+        new Option(true, "--gen-module-info") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 Path p = Paths.get(arg);
                 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
@@ -222,22 +222,22 @@
         },
 
         // ---- paths option ----
-        new Option(true, "-cp", "-classpath") {
+        new Option(true, "-cp", "-classpath", "--class-path") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.classpath = arg;
             }
         },
-        new Option(true, "-mp", "-modulepath") {
+        new Option(true, "--module-path") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 task.options.modulePath = arg;
             }
         },
-        new Option(true, "-upgrademodulepath") {
+        new Option(true, "--upgrade-module-path") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 task.options.upgradeModulePath = arg;
             }
         },
-        new Option(true, "-system") {
+        new Option(true, "--system") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 if (arg.equals("none")) {
                     task.options.systemModulePath = null;
@@ -250,13 +250,13 @@
                 }
             }
         },
-        new Option(true, "-addmods") {
+        new Option(true, "--add-modules") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 Set<String> mods = Set.of(arg.split(","));
                 task.options.addmods.addAll(mods);
             }
         },
-        new Option(true, "-m") {
+        new Option(true, "-m", "--module") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 task.options.rootModule = arg;
                 task.options.addmods.add(arg);
@@ -314,7 +314,7 @@
         },
 
         // Another alternative to list modules in -addmods option
-        new HiddenOption(true, "-include-system-modules") {
+        new HiddenOption(true, "--include-system-modules") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 task.options.includeSystemModulePattern = Pattern.compile(arg);
             }
@@ -345,7 +345,7 @@
             }
         },
 
-        new Option(false, "-ct", "-compile-time") {
+        new Option(false, "--compile-time") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.compileTimeView = true;
                 task.options.filterSamePackage = true;
@@ -375,7 +375,7 @@
                 task.options.showLabel = true;
             }
         },
-        new HiddenOption(false, "-hide-module") {
+        new HiddenOption(false, "--hide-show-module") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.showModule = false;
             }
@@ -464,7 +464,7 @@
                 return EXIT_CMDERR;
             }
             if (options.checkModuleDeps != null && !inputArgs.isEmpty()) {
-                reportError("err.invalid.module.option", inputArgs, "-check");
+                reportError("err.invalid.module.option", inputArgs, "--check");
             }
 
             boolean ok = run();
@@ -501,12 +501,12 @@
                 .forEach(mn -> config.findModule(mn).orElseThrow(() ->
                     new UncheckedBadArgs(new BadArgs("err.module.not.found", mn))));
 
-            // -genmoduleinfo
+            // --gen-module-info
             if (options.genModuleInfo != null) {
                 return genModuleInfo(config);
             }
 
-            // -check
+            // --check
             if (options.checkModuleDeps != null) {
                 return new ModuleAnalyzer(config, log, options.checkModuleDeps).run();
             }
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleAnalyzer.java	Fri Aug 19 12:17:32 2016 -0700
@@ -77,7 +77,7 @@
             String list = config.initialArchives().stream()
                 .map(Archive::getPathName).collect(joining(" "));
             throw new JdepsTask.UncheckedBadArgs(new BadArgs("err.invalid.module.option",
-                list, "-check"));
+                list, "--check"));
         }
 
         this.configuration = config;
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -1,6 +1,6 @@
 main.usage.summary=\
 Usage: {0} <options> <path ...>]\n\
-use -h, -? or -help for a list of possible options
+use -h, -?, -help, or --help for a list of possible options
 
 main.usage=\
 Usage: {0} <options> <path ...>]\n\
@@ -12,7 +12,8 @@
 warn.prefix=Warning:
 
 main.opt.h=\
-\  -h -?        -help                Print this usage message
+\  -h -? -help\n\
+\  --help                            Print this usage message
 
 main.opt.version=\
 \  -version                          Version information
@@ -64,24 +65,26 @@
 \  -P           -profile             Show profile containing a package
 
 main.opt.cp=\
-\  -cp <path>   -classpath <path>    Specify where to find class files
+\  -cp <path>\n\
+\  -classpath <path>\n\
+\  --class-path <path>               Specify where to find class files
 
-main.opt.mp=\
-\  -mp <module path>...\n\
-\  -modulepath <module path>...      Specify module path
+main.opt.module-path=\
+\  --module-path <module path>...    Specify module path
 
-main.opt.upgrademodulepath=\
-\  -upgrademodulepath <module path>...  Specify upgrade module path
+main.opt.upgrade-module-path=\
+\  --upgrade-module-path <module path>...  Specify upgrade module path
 
 main.opt.system=\
-\  -system <java-home>               Specify an alternate system module path
+\  --system <java-home>              Specify an alternate system module path
 
-main.opt.addmods=\
-\  -addmods <module-name>[,<module-name>...]\n\
+main.opt.add-modules=\
+\  --add-modules <module-name>[,<module-name>...]\n\
 \                                    Adds modules to the root set for analysis
 
 main.opt.m=\
-\  -m <module-name>                  Specify the root module for analysis
+\  -m <module-name>\n\
+\  --module <module-name>            Specify the root module for analysis
 
 main.opt.R=\
 \  -R           -recursive           Recursively traverse all run-time dependencies.\n\
@@ -98,8 +101,8 @@
 \                                    dependency summary.  This option must use\n\
 \                                    with -requires, -package or -regex option.
 
-main.opt.ct=\
-\  -ct          -compile-time        Compile-time view of transitive dependencies\n\
+main.opt.compile-time=\
+\  --compile-time                    Compile-time view of transitive dependencies\n\
 \                                    i.e. compile-time view of -R option.\n\
 \                                    Analyzes the dependences per other given options\n\
 \                                    If a dependence is found from a directory,\n\
@@ -113,14 +116,14 @@
 \                                    type, method parameter types, returned type,\n\
 \                                    checked exception types etc.
 
-main.opt.genmoduleinfo=\
-\  -genmoduleinfo <dir>              Generate module-info.java under the specified\n\
+main.opt.gen-module-info=\
+\  --gen-module-info <dir>           Generate module-info.java under the specified\n\
 \                                    directory. The specified JAR files will be\n\
 \                                    analyzed. This option cannot be used with\n\
 \                                    -dotoutput or -cp.
 
 main.opt.check=\
-\  -check <module-name>[,<module-name>...\n\
+\  --check <module-name>[,<module-name>...\n\
 \                                    Analyze the dependence of the specified modules\n\
 \                                    It prints the module descriptor, the resulting\n\
 \                                    module dependences after analysis and the\n\
@@ -151,7 +154,7 @@
 err.missing.arg=no value given for {0}
 err.invalid.arg.for.option=invalid argument for option: {0}
 err.option.after.class=option must be specified before classes: {0}
-err.genmoduleinfo.not.jarfile={0} not valid for -genmoduleinfo option (must be non-modular JAR file)
+err.genmoduleinfo.not.jarfile={0} not valid for --gen-module-info option (must be non-modular JAR file)
 err.profiles.msg=No profile information
 err.exception.message={0}
 err.invalid.path=invalid path: {0}
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Fri Aug 19 12:17:32 2016 -0700
@@ -973,10 +973,10 @@
                                     p.getFileName().toString().endsWith(".jar"));
     }
 
-    private CompletionProvider snippetCompletion(Supplier<List<? extends Snippet>> snippetsSupplier) {
+    private CompletionProvider snippetCompletion(Supplier<Stream<? extends Snippet>> snippetsSupplier) {
         return (prefix, cursor, anchor) -> {
             anchor[0] = 0;
-            return snippetsSupplier.get()                        .stream()
+            return snippetsSupplier.get()
                         .flatMap(k -> (k instanceof DeclarationSnippet)
                                 ? Stream.of(String.valueOf(k.id()), ((DeclarationSnippet) k).name())
                                 : Stream.of(String.valueOf(k.id())))
@@ -986,7 +986,7 @@
         };
     }
 
-    private CompletionProvider snippetKeywordCompletion(Supplier<List<? extends Snippet>> snippetsSupplier) {
+    private CompletionProvider snippetKeywordCompletion(Supplier<Stream<? extends Snippet>> snippetsSupplier) {
         return (code, cursor, anchor) -> {
             List<Suggestion> result = new ArrayList<>();
             result.addAll(KEYWORD_COMPLETION_PROVIDER.completionSuggestions(code, cursor, anchor));
@@ -1020,36 +1020,32 @@
 
     // Snippet lists
 
-    List<Snippet> allSnippets() {
+    Stream<Snippet> allSnippets() {
         return state.snippets();
     }
 
-    List<PersistentSnippet> dropableSnippets() {
-        return state.snippets().stream()
+    Stream<PersistentSnippet> dropableSnippets() {
+        return state.snippets()
                 .filter(sn -> state.status(sn).isActive() && sn instanceof PersistentSnippet)
-                .map(sn -> (PersistentSnippet) sn)
-                .collect(toList());
+                .map(sn -> (PersistentSnippet) sn);
     }
 
-    List<VarSnippet> allVarSnippets() {
-        return state.snippets().stream()
+    Stream<VarSnippet> allVarSnippets() {
+        return state.snippets()
                 .filter(sn -> sn.kind() == Snippet.Kind.VAR)
-                .map(sn -> (VarSnippet) sn)
-                .collect(toList());
+                .map(sn -> (VarSnippet) sn);
     }
 
-    List<MethodSnippet> allMethodSnippets() {
-        return state.snippets().stream()
+    Stream<MethodSnippet> allMethodSnippets() {
+        return state.snippets()
                 .filter(sn -> sn.kind() == Snippet.Kind.METHOD)
-                .map(sn -> (MethodSnippet) sn)
-                .collect(toList());
+                .map(sn -> (MethodSnippet) sn);
     }
 
-    List<TypeDeclSnippet> allTypeSnippets() {
-        return state.snippets().stream()
+    Stream<TypeDeclSnippet> allTypeSnippets() {
+        return state.snippets()
                 .filter(sn -> sn.kind() == Snippet.Kind.TYPE_DECL)
-                .map(sn -> (TypeDeclSnippet) sn)
-                .collect(toList());
+                .map(sn -> (TypeDeclSnippet) sn);
     }
 
     // Table of commands -- with command forms, argument kinds, helpKey message, implementation, ...
@@ -1549,7 +1545,7 @@
      * string
      * @return a Stream of referenced snippets or null if no matches are found
      */
-    private <T extends Snippet> Stream<T> argsOptionsToSnippets(List<T> snippets,
+    private <T extends Snippet> Stream<T> argsOptionsToSnippets(Supplier<Stream<T>> snippetSupplier,
             Predicate<Snippet> defFilter, String rawargs, String cmd) {
         ArgTokenizer at = new ArgTokenizer(cmd, rawargs.trim());
         at.allowedOptions("-all", "-start");
@@ -1571,38 +1567,38 @@
         }
         if (at.hasOption("-all")) {
             // all snippets including start-up, failed, and overwritten
-            return snippets.stream();
+            return snippetSupplier.get();
         }
         if (at.hasOption("-start")) {
             // start-up snippets
-            return snippets.stream()
+            return snippetSupplier.get()
                     .filter(this::inStartUp);
         }
         if (args.isEmpty()) {
             // Default is all active user snippets
-            return snippets.stream()
+            return snippetSupplier.get()
                     .filter(defFilter);
         }
-        return argsToSnippets(snippets, args);
+        return argsToSnippets(snippetSupplier, args);
     }
 
     /**
      * Convert user arguments to a Stream of snippets referenced by those
      * arguments.
      *
-     * @param snippets the base list of possible snippets
+     * @param snippetSupplier the base list of possible snippets
      * @param args the user's argument to the command, maybe be the empty list
      * @return a Stream of referenced snippets or null if no matches to specific
      * arg
      */
-    private <T extends Snippet> Stream<T> argsToSnippets(List<T> snippets,
+    private <T extends Snippet> Stream<T> argsToSnippets(Supplier<Stream<T>> snippetSupplier,
             List<String> args) {
         Stream<T> result = null;
         for (String arg : args) {
             // Find the best match
-            Stream<T> st = layeredSnippetSearch(snippets, arg);
+            Stream<T> st = layeredSnippetSearch(snippetSupplier, arg);
             if (st == null) {
-                Stream<Snippet> est = layeredSnippetSearch(state.snippets(), arg);
+                Stream<Snippet> est = layeredSnippetSearch(state::snippets, arg);
                 if (est == null) {
                     errormsg("jshell.err.no.such.snippets", arg);
                 } else {
@@ -1620,10 +1616,10 @@
         return result;
     }
 
-    private <T extends Snippet> Stream<T> layeredSnippetSearch(List<T> snippets, String arg) {
+    private <T extends Snippet> Stream<T> layeredSnippetSearch(Supplier<Stream<T>> snippetSupplier, String arg) {
         return nonEmptyStream(
                 // the stream supplier
-                () -> snippets.stream(),
+                snippetSupplier,
                 // look for active user declarations matching the name
                 sn -> isActive(sn) && matchingDeclaration(sn, arg),
                 // else, look for any declarations matching the name
@@ -1648,7 +1644,7 @@
             errormsg("jshell.err.drop.arg");
             return false;
         }
-        Stream<PersistentSnippet> stream = argsToSnippets(dropableSnippets(), args);
+        Stream<PersistentSnippet> stream = argsToSnippets(this::dropableSnippets, args);
         if (stream == null) {
             // Snippet not found. Error already printed
             fluffmsg("jshell.msg.see.classes.etc");
@@ -1670,7 +1666,7 @@
     }
 
     private boolean cmdEdit(String arg) {
-        Stream<Snippet> stream = argsOptionsToSnippets(state.snippets(),
+        Stream<Snippet> stream = argsOptionsToSnippets(state::snippets,
                 this::mainActive, arg, "/edit");
         if (stream == null) {
             return false;
@@ -1775,7 +1771,7 @@
         if (arg.length() >= 2 && "-history".startsWith(arg)) {
             return cmdHistory();
         }
-        Stream<Snippet> stream = argsOptionsToSnippets(state.snippets(),
+        Stream<Snippet> stream = argsOptionsToSnippets(state::snippets,
                 this::mainActive, arg, "/list");
         if (stream == null) {
             return false;
@@ -1896,13 +1892,12 @@
             } else if (at.hasOption("-start")) {
                 writer.append(startup);
             } else {
-                List<Snippet> sns = at.hasOption("-all")
+                String sources = (at.hasOption("-all")
                         ? state.snippets()
-                        : state.snippets().stream().filter(this::mainActive).collect(toList());
-                for (Snippet sn : sns) {
-                    writer.write(sn.source());
-                    writer.write("\n");
-                }
+                        : state.snippets().filter(this::mainActive))
+                        .map(Snippet::source)
+                        .collect(Collectors.joining("\n"));
+                writer.write(sources);
             }
         } catch (FileNotFoundException e) {
             errormsg("jshell.err.file.not.found", "/save", filename, e.getMessage());
@@ -1915,7 +1910,7 @@
     }
 
     private boolean cmdVars(String arg) {
-        Stream<VarSnippet> stream = argsOptionsToSnippets(allVarSnippets(),
+        Stream<VarSnippet> stream = argsOptionsToSnippets(this::allVarSnippets,
                 this::isActive, arg, "/vars");
         if (stream == null) {
             return false;
@@ -1931,7 +1926,7 @@
     }
 
     private boolean cmdMethods(String arg) {
-        Stream<MethodSnippet> stream = argsOptionsToSnippets(allMethodSnippets(),
+        Stream<MethodSnippet> stream = argsOptionsToSnippets(this::allMethodSnippets,
                 this::isActive, arg, "/methods");
         if (stream == null) {
             return false;
@@ -1943,7 +1938,7 @@
     }
 
     private boolean cmdTypes(String arg) {
-        Stream<TypeDeclSnippet> stream = argsOptionsToSnippets(allTypeSnippets(),
+        Stream<TypeDeclSnippet> stream = argsOptionsToSnippets(this::allTypeSnippets,
                 this::isActive, arg, "/types");
         if (stream == null) {
             return false;
@@ -1982,7 +1977,7 @@
     }
 
     private boolean cmdUseHistoryEntry(int index) {
-        List<Snippet> keys = state.snippets();
+        List<Snippet> keys = state.snippets().collect(toList());
         if (index < 0)
             index += keys.size();
         else
@@ -2012,7 +2007,7 @@
     }
 
     private boolean rerunHistoryEntryById(String id) {
-        Optional<Snippet> snippet = state.snippets().stream()
+        Optional<Snippet> snippet = state.snippets()
             .filter(s -> s.id().equals(id))
             .findFirst();
         return snippet.map(s -> {
@@ -2135,7 +2130,7 @@
             debug("Event with null key: %s", ste);
             return false;
         }
-        List<Diag> diagnostics = state.diagnostics(sn);
+        List<Diag> diagnostics = state.diagnostics(sn).collect(toList());
         String source = sn.source();
         if (ste.causeSnippet() == null) {
             // main event
@@ -2212,7 +2207,7 @@
     //where
     void printUnresolvedException(UnresolvedReferenceException ex) {
         DeclarationSnippet corralled =  ex.getSnippet();
-        List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled));
+        List<Diag> otherErrors = errorsOnly(state.diagnostics(corralled).collect(toList()));
         new DisplayEvent(corralled, state.status(corralled), FormatAction.USED, true, null, otherErrors)
                 .displayDeclarationAndValue();
     }
@@ -2280,13 +2275,13 @@
             for (Diag d : errors) {
                 displayDiagnostics(sn.source(), d, errorLines);
             }
-            int unresolvedCount;
+            long unresolvedCount;
             if (sn instanceof DeclarationSnippet && (status == Status.RECOVERABLE_DEFINED || status == Status.RECOVERABLE_NOT_DEFINED)) {
                 resolution = (status == Status.RECOVERABLE_NOT_DEFINED)
                         ? FormatResolve.NOTDEFINED
                         : FormatResolve.DEFINED;
                 unresolved = unresolved((DeclarationSnippet) sn);
-                unresolvedCount = state.unresolvedDependencies((DeclarationSnippet) sn).size();
+                unresolvedCount = state.unresolvedDependencies((DeclarationSnippet) sn).count();
             } else {
                 resolution = FormatResolve.OK;
                 unresolved = "";
@@ -2305,7 +2300,7 @@
         }
 
         private String unresolved(DeclarationSnippet key) {
-            List<String> unr = state.unresolvedDependencies(key);
+            List<String> unr = state.unresolvedDependencies(key).collect(toList());
             StringBuilder sb = new StringBuilder();
             int fromLast = unr.size();
             if (fromLast > 0) {
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/JShell.java	Fri Aug 19 12:17:32 2016 -0700
@@ -43,6 +43,7 @@
 import java.util.function.Consumer;
 
 import java.util.function.Supplier;
+import java.util.stream.Stream;
 import jdk.internal.jshell.debug.InternalDebugControl;
 import jdk.jshell.Snippet.Status;
 import jdk.jshell.execution.JDIDefaultExecutionControl;
@@ -504,9 +505,9 @@
      * @return the snippets for all current snippets in id order.
      * @throws IllegalStateException if this JShell instance is closed.
      */
-    public List<Snippet> snippets() throws IllegalStateException {
+    public Stream<Snippet> snippets() throws IllegalStateException {
         checkIfAlive();
-        return Collections.unmodifiableList(maps.snippetList());
+        return maps.snippetList().stream();
     }
 
     /**
@@ -518,11 +519,10 @@
      * @return the active declared variables.
      * @throws IllegalStateException if this JShell instance is closed.
      */
-    public List<VarSnippet> variables() throws IllegalStateException {
-        return snippets().stream()
+    public Stream<VarSnippet> variables() throws IllegalStateException {
+        return snippets()
                      .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.VAR)
-                     .map(sn -> (VarSnippet) sn)
-                     .collect(collectingAndThen(toList(), Collections::unmodifiableList));
+                     .map(sn -> (VarSnippet) sn);
     }
 
     /**
@@ -534,11 +534,10 @@
      * @return the active declared methods.
      * @throws IllegalStateException if this JShell instance is closed.
      */
-    public List<MethodSnippet> methods() throws IllegalStateException {
-        return snippets().stream()
+    public Stream<MethodSnippet> methods() throws IllegalStateException {
+        return snippets()
                      .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.METHOD)
-                     .map(sn -> (MethodSnippet)sn)
-                     .collect(collectingAndThen(toList(), Collections::unmodifiableList));
+                     .map(sn -> (MethodSnippet)sn);
     }
 
     /**
@@ -550,11 +549,10 @@
      * @return the active declared type declarations.
      * @throws IllegalStateException if this JShell instance is closed.
      */
-    public List<TypeDeclSnippet> types() throws IllegalStateException {
-        return snippets().stream()
+    public Stream<TypeDeclSnippet> types() throws IllegalStateException {
+        return snippets()
                 .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.TYPE_DECL)
-                .map(sn -> (TypeDeclSnippet) sn)
-                .collect(collectingAndThen(toList(), Collections::unmodifiableList));
+                .map(sn -> (TypeDeclSnippet) sn);
     }
 
     /**
@@ -566,11 +564,10 @@
      * @return the active declared import declarations.
      * @throws IllegalStateException if this JShell instance is closed.
      */
-    public List<ImportSnippet> imports() throws IllegalStateException {
-        return snippets().stream()
+    public Stream<ImportSnippet> imports() throws IllegalStateException {
+        return snippets()
                 .filter(sn -> status(sn).isActive() && sn.kind() == Snippet.Kind.IMPORT)
-                .map(sn -> (ImportSnippet) sn)
-                .collect(collectingAndThen(toList(), Collections::unmodifiableList));
+                .map(sn -> (ImportSnippet) sn);
     }
 
     /**
@@ -598,8 +595,8 @@
      * @throws IllegalArgumentException if the snippet is not associated with
      * this {@code JShell} instance.
      */
-    public List<Diag> diagnostics(Snippet snippet) {
-        return Collections.unmodifiableList(checkValidSnippet(snippet).diagnostics());
+    public Stream<Diag> diagnostics(Snippet snippet) {
+        return checkValidSnippet(snippet).diagnostics().stream();
     }
 
     /**
@@ -611,13 +608,13 @@
      * {@code eval()} or {@code drop()} of another snippet causes
      * an update of a dependency.
      * @param snippet the declaration {@code Snippet} to look up
-     * @return the list of symbol names that are currently unresolvedDependencies.
+     * @return a stream of symbol names that are currently unresolvedDependencies.
      * @throws IllegalStateException if this {@code JShell} instance is closed.
      * @throws IllegalArgumentException if the snippet is not associated with
      * this {@code JShell} instance.
      */
-    public List<String> unresolvedDependencies(DeclarationSnippet snippet) {
-        return Collections.unmodifiableList(checkValidSnippet(snippet).unresolved());
+    public Stream<String> unresolvedDependencies(DeclarationSnippet snippet) {
+        return checkValidSnippet(snippet).unresolved().stream();
     }
 
     /**
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Fri Aug 19 12:17:32 2016 -0700
@@ -27,6 +27,7 @@
 
 import jdk.jshell.SourceCodeAnalysis.Completeness;
 import com.sun.source.tree.AssignmentTree;
+import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.ErroneousTree;
 import com.sun.source.tree.ExpressionTree;
@@ -39,6 +40,7 @@
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
+import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.JavacTask;
 import com.sun.source.util.SourcePositions;
@@ -91,6 +93,7 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
+import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -267,6 +270,7 @@
             case IMPORT:
                 codeWrap = proc.outerMap.wrapImport(Wrap.simpleWrap(code + "any.any"), null);
                 break;
+            case CLASS:
             case METHOD:
                 codeWrap = proc.outerMap.wrapInTrialClass(Wrap.classMemberWrap(code));
                 break;
@@ -380,10 +384,46 @@
                         addElements(membersOf(at, at.getElements().getPackageElement("").asType(), false), it.isStatic() ? STATIC_ONLY.and(accessibility) : accessibility, smartFilter, result);
                     }
                     break;
-                case ERRONEOUS:
-                case EMPTY_STATEMENT: {
+                case CLASS: {
+                    Predicate<Element> accept = accessibility.and(IS_TYPE);
+                    addScopeElements(at, scope, IDENTITY, accept, smartFilter, result);
+                    addElements(primitivesOrVoid(at), TRUE, smartFilter, result);
+                    break;
+                }
+                case BLOCK:
+                case EMPTY_STATEMENT:
+                case ERRONEOUS: {
                     boolean staticOnly = ReplResolve.isStatic(((JavacScope)scope).getEnv());
                     Predicate<Element> accept = accessibility.and(staticOnly ? STATIC_ONLY : TRUE);
+                    if (isClass(tp)) {
+                        ClassTree clazz = (ClassTree) tp.getParentPath().getLeaf();
+                        if (clazz.getExtendsClause() == tp.getLeaf()) {
+                            accept = accept.and(IS_TYPE);
+                            smartFilter = smartFilter.and(el -> el.getKind() == ElementKind.CLASS);
+                        } else {
+                            Predicate<Element> f = smartFilterFromList(at, tp, clazz.getImplementsClause(), tp.getLeaf());
+                            if (f != null) {
+                                accept = accept.and(IS_TYPE);
+                                smartFilter = f.and(el -> el.getKind() == ElementKind.INTERFACE);
+                            }
+                        }
+                    } else if (isTypeParameter(tp)) {
+                        TypeParameterTree tpt = (TypeParameterTree) tp.getParentPath().getLeaf();
+                        Predicate<Element> f = smartFilterFromList(at, tp, tpt.getBounds(), tp.getLeaf());
+                        if (f != null) {
+                            accept = accept.and(IS_TYPE);
+                            smartFilter = f;
+                            if (!tpt.getBounds().isEmpty() && tpt.getBounds().get(0) != tp.getLeaf()) {
+                                smartFilter = smartFilter.and(el -> el.getKind() == ElementKind.INTERFACE);
+                            }
+                        }
+                    } else if (isVariable(tp)) {
+                        VariableTree var = (VariableTree) tp.getParentPath().getLeaf();
+                        if (var.getType() == tp.getLeaf()) {
+                            accept = accept.and(IS_TYPE);
+                        }
+                    }
+
                     addScopeElements(at, scope, IDENTITY, accept, smartFilter, result);
 
                     Tree parent = tp.getParentPath().getLeaf();
@@ -413,6 +453,23 @@
         return result;
     }
 
+    private static final Set<Kind> CLASS_KINDS = EnumSet.of(
+            Kind.ANNOTATION_TYPE, Kind.CLASS, Kind.ENUM, Kind.INTERFACE
+    );
+
+    private Predicate<Element> smartFilterFromList(AnalyzeTask at, TreePath base, Collection<? extends Tree> types, Tree current) {
+        Set<Element> existingEls = new HashSet<>();
+
+        for (Tree type : types) {
+            if (type == current) {
+                return el -> !existingEls.contains(el);
+            }
+            existingEls.add(at.trees().getElement(new TreePath(base, type)));
+        }
+
+        return null;
+    }
+
     @Override
     public SnippetWrapper wrapper(Snippet snippet) {
         return new SnippetWrapper() {
@@ -516,6 +573,21 @@
                 ((MethodTree)parent).getThrows().contains(tp.getLeaf());
     }
 
+    private boolean isClass(TreePath tp) {
+        return tp.getParentPath() != null &&
+               CLASS_KINDS.contains(tp.getParentPath().getLeaf().getKind());
+    }
+
+    private boolean isTypeParameter(TreePath tp) {
+        return tp.getParentPath() != null &&
+               tp.getParentPath().getLeaf().getKind() == Kind.TYPE_PARAMETER;
+    }
+
+    private boolean isVariable(TreePath tp) {
+        return tp.getParentPath() != null &&
+               tp.getParentPath().getLeaf().getKind() == Kind.VARIABLE;
+    }
+
     private ImportTree findImport(TreePath tp) {
         while (tp != null && tp.getLeaf().getKind() != Kind.IMPORT) {
             tp = tp.getParentPath();
@@ -550,6 +622,7 @@
     private final Predicate<Element> IS_PACKAGE = el -> el.getKind() == ElementKind.PACKAGE;
     private final Predicate<Element> IS_CLASS = el -> el.getKind().isClass();
     private final Predicate<Element> IS_INTERFACE = el -> el.getKind().isInterface();
+    private final Predicate<Element> IS_TYPE = IS_CLASS.or(IS_INTERFACE).or(el -> el.getKind() == ElementKind.TYPE_PARAMETER);
     private final Predicate<Element> IS_VOID = el -> el.asType().getKind() == TypeKind.VOID;
     private final Predicate<Element> STATIC_ONLY = el -> {
         ElementKind kind = el.getKind();
@@ -583,6 +656,11 @@
         for (Element c : elements) {
             if (!accept.test(c))
                 continue;
+            if (c.getKind() == ElementKind.METHOD &&
+                c.getSimpleName().contentEquals(Util.DOIT_METHOD_NAME) &&
+                ((ExecutableElement) c).getParameters().isEmpty()) {
+                continue;
+            }
             String simpleName = simpleName(c);
             if (c.getKind() == ElementKind.CONSTRUCTOR || c.getKind() == ElementKind.METHOD) {
                 simpleName += paren.apply(hasParams.contains(simpleName));
@@ -754,13 +832,25 @@
         };
         @SuppressWarnings("unchecked")
         List<Element> result = Util.stream(scopeIterable)
-                             .flatMap(s -> Util.stream((Iterable<Element>)s.getLocalElements()))
+                             .flatMap(s -> localElements(s))
                              .flatMap(el -> Util.stream((Iterable<Element>)elementConvertor.apply(el)))
                              .collect(toCollection(ArrayList :: new));
         result.addAll(listPackages(at, ""));
         return result;
     }
 
+    private Stream<Element> localElements(Scope scope) {
+        @SuppressWarnings("unchecked")
+        Stream<Element> elements = Util.stream((Iterable<Element>)scope.getLocalElements());
+
+        if (scope.getEnclosingScope() != null &&
+            scope.getEnclosingClass() != scope.getEnclosingScope().getEnclosingClass()) {
+            elements = Stream.concat(elements, scope.getEnclosingClass().getEnclosedElements().stream());
+        }
+
+        return elements;
+    }
+
     @SuppressWarnings("fallthrough")
     private Iterable<TypeMirror> findTargetType(AnalyzeTask at, TreePath forPath) {
         if (forPath.getParentPath() == null)
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java	Fri Aug 19 12:17:32 2016 -0700
@@ -414,25 +414,29 @@
     // types are the same. if so, consider it an overwrite replacement.
     private Status overwriteMatchingMethod(MethodSnippet msi) {
         String qpt = msi.qualifiedParameterTypes();
+        List<MethodSnippet> matching = state.methods()
+                .filter(sn ->
+                           sn != null
+                        && sn != msi
+                        && sn.status().isActive()
+                        && sn.name().equals(msi.name())
+                        && qpt.equals(sn.qualifiedParameterTypes()))
+                .collect(toList());
 
         // Look through all methods for a method of the same name, with the
         // same computed qualified parameter types
         Status overwrittenStatus = null;
-        for (MethodSnippet sn : state.methods()) {
-            if (sn != null && sn != msi && sn.status().isActive() && sn.name().equals(msi.name())) {
-                if (qpt.equals(sn.qualifiedParameterTypes())) {
-                    overwrittenStatus = sn.status();
-                    SnippetEvent se = new SnippetEvent(
-                            sn, overwrittenStatus, OVERWRITTEN,
-                            false, msi, null, null);
-                    sn.setOverwritten();
-                    secondaryEvents.add(se);
-                    state.debug(DBG_EVNT,
-                            "Overwrite event #%d -- key: %s before: %s status: %s sig: %b cause: %s\n",
-                            secondaryEvents.size(), se.snippet(), se.previousStatus(),
-                            se.status(), se.isSignatureChange(), se.causeSnippet());
-                }
-            }
+        for (MethodSnippet sn : matching) {
+            overwrittenStatus = sn.status();
+            SnippetEvent se = new SnippetEvent(
+                    sn, overwrittenStatus, OVERWRITTEN,
+                    false, msi, null, null);
+            sn.setOverwritten();
+            secondaryEvents.add(se);
+            state.debug(DBG_EVNT,
+                    "Overwrite event #%d -- key: %s before: %s status: %s sig: %b cause: %s\n",
+                    secondaryEvents.size(), se.snippet(), se.previousStatus(),
+                    se.status(), se.isSignatureChange(), se.causeSnippet());
         }
         return overwrittenStatus;
     }
--- a/langtools/test/ProblemList.txt	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/ProblemList.txt	Fri Aug 19 12:17:32 2016 -0700
@@ -26,36 +26,16 @@
 ###########################################################################
 #
 # javadoc
-
-jdk/javadoc/tool/6176978/T6176978.java                                          8152049    generic-all    no longer applicable, should delete
-jdk/javadoc/tool/InlineTagsWithBraces.java                                      8152050    generic-all    API, re-evaluate @bold, @maybe causes doclint to throw up.
-jdk/javadoc/tool/LangVers.java                                                  8152051    generic-all    API, re-evaluate, unsure of this test.
 jdk/javadoc/tool/VerifyLocale.java                                              8149565    generic-all    -locale option issues
-jdk/javadoc/tool/enum/docComments/Main.java                                     8152054    generic-all    API modifications
-jdk/javadoc/tool/enum/enumType/Main.java                                        8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/genericClass/Main.java                                8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java                        8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/genericInterface/Main.java                            8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/genericMethod/Main.java                               8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/genericSuper/Main.java                                8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/supertypes/Main.java                                  8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/throwsGeneric/Main.java                               8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/tparamCycle/Main.java                                 8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java                           8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/tparamTagOnType/Main.java                             8152054    generic-all    API modifications
-jdk/javadoc/tool/generics/wildcards/Main.java                                   8152054    generic-all    API modifications
-jdk/javadoc/tool/imports/MissingImport.java                                     8152054    generic-all    API modifications, testing deprecated APIs.
-jdk/javadoc/tool/sourceOnly/Test.java                                           8152054    generic-all    API modifications
-jdk/javadoc/tool/sourceOption/SourceOption.java                                 8152054    generic-all    API modifications
-jdk/javadoc/tool/subpackageIgnore/SubpackageIgnore.java                         8152054    generic-all    API modifications
-jdk/javadoc/tool/varArgs/Main.java                                              8152054    generic-all    API modifications
+jdk/javadoc/tool/enum/docComments/Main.java                                     8152313    generic-all    convert to doclet test framework
+jdk/javadoc/tool/enum/enumType/Main.java                                        8152313    generic-all    convert to doclet test framework
+jdk/javadoc/tool/varArgs/Main.java                                              8152313    generic-all    convert to doclet test framework
 
 ###########################################################################
 #
 # jshell
 
-jdk/jshell/EditorPadTest.java                                                   8139872    generic-all    test requires a non-headless environment
-jdk/jshell/ExternalEditorTest.java                                              8080843    generic-all    invalid key error occurs when external editor is used.
+jdk/jshell/EditorPadTest.java                                                   8161276    windows-all    Test set-up cannot press buttons
 jdk/jshell/ToolBasicTest.java                                                   8139873    generic-all    JShell tests failing
 
 ###########################################################################
@@ -88,6 +68,11 @@
 tools/sjavac/IncCompileFullyQualifiedRef.java                                   8152055    generic-all    Requires dependency code to deal with in-method dependencies.
 tools/sjavac/IncCompileWithChanges.java                                         8152055    generic-all    Requires dependency code to deal with in-method dependencies.
 
+tools/sjavac/ApiExtraction.java							8158002	   generic-all	  Requires investigation
+tools/sjavac/IgnoreSymbolFile.java						8158002	   generic-all	  Requires investigation
+tools/sjavac/ClasspathDependencies.java						8158002	   generic-all	  Requires investigation
+
+
 ###########################################################################
 #
 # jdeps 
--- a/langtools/test/TEST.ROOT	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/TEST.ROOT	Fri Aug 19 12:17:32 2016 -0700
@@ -14,8 +14,8 @@
 # Group definitions
 groups=TEST.groups
 
-# Tests using jtreg 4.2 b02 features
-requiredVersion=4.2 b02
+# Tests using jtreg 4.2 b03 features
+requiredVersion=4.2 b03
 
-# Use new form of -Xpatch
-useNewXpatch=true
+# Use new module options
+useNewOptions=true
--- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Fri Aug 19 12:17:32 2016 -0700
@@ -42,8 +42,8 @@
     @Test
     void test1() {
         javadoc("-d", "out", "-use",
-                "-modulesourcepath", testSrc,
-                "-addmods", "module1,module2",
+                "--module-source-path", testSrc,
+                "--add-modules", "module1,module2",
                 "testpkgmdl1", "testpkgmdl2");
         checkExit(Exit.OK);
         testDescription(true);
@@ -57,8 +57,8 @@
     @Test
     void test2() {
         javadoc("-d", "out-html5", "-html5", "-use",
-                "-modulesourcepath", testSrc,
-                "-addmods", "module1,module2",
+                "--module-source-path", testSrc,
+                "--add-modules", "module1,module2",
                 "testpkgmdl1", "testpkgmdl2");
         checkExit(Exit.OK);
         testHtml5Description(true);
@@ -72,8 +72,8 @@
     @Test
     void test3() {
         javadoc("-d", "out-nocomment", "-nocomment", "-use",
-                "-modulesourcepath", testSrc,
-                "-addmods", "module1,module2",
+                "--module-source-path", testSrc,
+                "--add-modules", "module1,module2",
                 "testpkgmdl1", "testpkgmdl2");
         checkExit(Exit.OK);
         testDescription(false);
@@ -84,8 +84,8 @@
     @Test
     void test4() {
         javadoc("-d", "out-html5-nocomment", "-nocomment", "-html5", "-use",
-                "-modulesourcepath", testSrc,
-                "-addmods", "module1,module2",
+                "--module-source-path", testSrc,
+                "--add-modules", "module1,module2",
                 "testpkgmdl1", "testpkgmdl2");
         checkExit(Exit.OK);
         testHtml5Description(false);
@@ -108,8 +108,8 @@
         javadoc("-d", "out-mdltags", "-author", "-version",
                 "-tag", "regular:a:Regular Tag:",
                 "-tag", "moduletag:s:Module Tag:",
-                "-modulesourcepath", testSrc,
-                "-addmods", "moduletags,module2",
+                "--module-source-path", testSrc,
+                "--add-modules", "moduletags,module2",
                 "testpkgmdltags", "testpkgmdl2");
         checkExit(Exit.OK);
         testModuleTags();
--- a/langtools/test/jdk/javadoc/tool/6964914/TestStdDoclet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/6964914/TestStdDoclet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -47,8 +47,6 @@
      */
     void run() throws Exception {
         File javaHome = new File(System.getProperty("java.home"));
-        if (javaHome.getName().equals("jre"))
-            javaHome = javaHome.getParentFile();
         File javadoc = new File(new File(javaHome, "bin"), "javadoc");
         File testSrc = new File(System.getProperty("test.src"));
 
@@ -57,11 +55,6 @@
         String thisClassName = TestStdDoclet.class.getName();
         List<String> cmdArgs = new ArrayList<>();
         cmdArgs.add(javadoc.getPath());
-        int i = 0;
-        String prop;
-        while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) {
-            cmdArgs.add("-J-Xpatch:" + prop);
-        }
         cmdArgs.addAll(Arrays.asList(
                 "-classpath", ".", // insulates us from ambient classpath
                 "-Xdoclint:none",
--- a/langtools/test/jdk/javadoc/tool/6964914/TestUserDoclet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/6964914/TestUserDoclet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -68,11 +68,6 @@
         String thisClassName = TestUserDoclet.class.getName();
         List<String> cmdArgs = new ArrayList<>();
         cmdArgs.add(javadoc.getPath());
-        int i = 0;
-        String prop;
-        while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) {
-            cmdArgs.add("-J-Xpatch:" + prop);
-        }
         cmdArgs.addAll(Arrays.asList(
                 "-doclet", thisClassName,
                 "-docletpath", testClasses.getPath(),
--- a/langtools/test/jdk/javadoc/tool/8025693/Test.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/8025693/Test.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 8025693
  * @summary javadoc should ignore <clinit> methods found in classes on classpath
- * @modules jdk.javadoc
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
  */
 
 import java.io.*;
@@ -69,7 +69,7 @@
         PrintStream prev = System.err;
         System.setErr(ps);
         try {
-            int rc = com.sun.tools.javadoc.Main.execute(args);
+            int rc = jdk.javadoc.internal.tool.Main.execute(args);
         } finally {
             System.err.flush();
             System.setErr(prev);
--- a/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Fri Aug 19 12:17:32 2016 -0700
@@ -148,7 +148,7 @@
             if (codeKeys.contains(rk))
                 continue;
 
-            error("Resource key not found in code: " + rk);
+            error("Resource key not found in code: '" + rk + '"');
         }
     }
 
--- a/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/ReleaseOption.java	Fri Aug 19 12:17:32 2016 -0700
@@ -21,6 +21,7 @@
  * questions.
  */
 
+import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
@@ -53,16 +54,16 @@
         List<String> options = new ArrayList<>();
         options.addAll(Arrays.asList(args));
         options.add("-XDrawDiagnostics");
-        options.add(System.getProperty("test.src", ".") + java.io.File.separatorChar + "ReleaseOptionSource.java");
+        options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath());
         StringWriter out = new StringWriter();
         PrintWriter pw = new PrintWriter(out);
         int actualResult = Main.execute(options.toArray(new String[0]), pw);
         System.err.println("actual result=" + actualResult);
         System.err.println("actual output=" + out.toString());
         if (actualResult != expectedResult)
-            throw new Error();
+            throw new Error("Exit code not as expected");
         if (!validate.test(out.toString())) {
-            throw new Error("Not an expected error output: " + out.toString());
+            throw new Error("Output not as expected");
         }
     }
 }
--- a/langtools/test/jdk/javadoc/tool/T4696488.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/T4696488.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, 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
@@ -21,16 +21,17 @@
  * questions.
  */
 
-import com.sun.tools.doclets.internal.toolkit.Configuration;
-
 /**
  * @test
  * @bug     4696488
  * @summary javadoc doesn't handle UNC paths for destination directory
  * @author  Jesse Glick
- * @modules jdk.javadoc/com.sun.tools.doclets.internal.toolkit
+ * @modules jdk.javadoc/jdk.javadoc.internal.doclets.toolkit
  * @run main T4696488 T4696488.java
  */
+
+import jdk.javadoc.internal.doclets.toolkit.Configuration;
+
 public class T4696488 {
 
     public static void main(String... args) {
@@ -53,5 +54,4 @@
             throw new Error("expected " + expectedOutput + " but was " + output);
         }
     }
-
 }
--- a/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/badSuper/BadSuper.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 4983023
  * @summary A bad superclass shouldn't throw the standard doclet into a loop
- * @modules jdk.javadoc
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
  */
 
 public class BadSuper {
@@ -33,7 +33,7 @@
     public static void main(String[] args) {
         String srcpath = System.getProperty("test.src", ".");
 
-        if (com.sun.tools.javadoc.Main.execute(
+        if (jdk.javadoc.internal.tool.Main.execute(
                 new String[] {"-d", "doc", "-sourcepath", srcpath, "p"}) != 0)
             throw new Error("Javadoc encountered warnings or errors.");
     }
--- a/langtools/test/jdk/javadoc/tool/enum/docComments/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/enum/docComments/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 4421066
  * @summary Verify the comments in an enum type.
- * @ignore API modifications
+ * @ignore 8152313 convert to doclet test framework
  * @library ../../lib
  * @modules jdk.javadoc
  * @compile  ../../lib/Tester.java Main.java
--- a/langtools/test/jdk/javadoc/tool/enum/enumType/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/enum/enumType/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 4421066
  * @summary Verify the contents of an enum type.
- * @ignore API modifications
+ * @ignore 8152313 convert to doclet test framework
  * @library ../../lib
  * @modules jdk.javadoc
  * @compile  ../../lib/Tester.java Main.java
--- a/langtools/test/jdk/javadoc/tool/generics/genericClass/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the contents of the ClassDoc of a generic class.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            for (ClassDoc cd : root.classes()) {
-                tester.printClass(cd);
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericClass/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-class pkg1.A<T>
-  name: A / A / pkg1.A
-  type parameters:
-    T
-  superclass:
-    java.lang.Object
-  fields:
-    T t
-    pkg1.A<T> at
-    pkg1.A<java.lang.String> as
-  constructors:
-    A()
-  methods:
-    void m1(T)
-    void m2(A<T>)
-    void m3(A<String>)
--- a/langtools/test/jdk/javadoc/tool/generics/genericClass/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public class A<T> {
-    public T t;
-    public A<T> at;
-    public A<String> as;
-
-    public void m1(T t) {}
-    public void m2(A<T> at) {}
-    public void m3(A<String> as) {}
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the contents of the ClassDoc of
- *          a generic class with a generic inner class.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import java.util.Arrays;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            ClassDoc[] cds = root.classes();
-            Arrays.sort(cds);
-            for (ClassDoc cd : cds) {
-                tester.printClass(cd);
-                tester.println();
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-class pkg1.O<T>
-  name: O / O / pkg1.O
-  type parameters:
-    T
-  superclass:
-    java.lang.Object
-  constructors:
-    O()
-
-class pkg1.O<T>.I<S>
-  name: I / O.I / pkg1.O.I
-  type parameters:
-    S
-  nested in:
-    pkg1.O<T>
-  superclass:
-    java.lang.Object
-  constructors:
-    I()
-  methods:
-    void m1(O<String>.I<Number>)
-
-class pkg1.X<T>
-  name: X / X / pkg1.X
-  type parameters:
-    T
-  superclass:
-    java.lang.Object
-  constructors:
-    X()
-
-class pkg1.X<T>.Y
-  name: Y / X.Y / pkg1.X.Y
-  nested in:
-    pkg1.X<T>
-  superclass:
-    java.lang.Object
-  constructors:
-    Y()
-
-class pkg1.X<T>.Y.Z<S>
-  name: Z / X.Y.Z / pkg1.X.Y.Z
-  type parameters:
-    S
-  nested in:
-    pkg1.X<T>.Y
-  superclass:
-    java.lang.Object
-  constructors:
-    Z()
-  methods:
-    void m1(X<String>.Y.Z<Number>)
-
--- a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/O.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public class O<T> {
-    public class I<S> {
-        public void m1(O<String>.I<Number> a) {}
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericInnerAndOuter/pkg1/X.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public class X<T> {
-    public class Y {
-        public class Z<S> {
-            public void m1(X<String>.Y.Z<Number> a) {}
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericInterface/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the contents of the ClassDoc of a generic interface.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            for (ClassDoc cd : root.classes()) {
-                tester.printClass(cd);
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericInterface/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-interface pkg1.A<T>
-  name: A / A / pkg1.A
-  type parameters:
-    T
-  methods:
-    void m1(T)
--- a/langtools/test/jdk/javadoc/tool/generics/genericInterface/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public interface A<T> {
-    void m1(T t);
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericMethod/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the reading of generic methods and constructors.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            for (ClassDoc cd : root.classes()) {
-                for (ConstructorDoc c : cd.constructors())
-                    tester.printConstructor(c);
-                for (MethodDoc m : cd.methods())
-                    tester.printMethod(m);
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericMethod/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-constructor <T>pkg1.A()
-  signature: ()
-             ()
-  type parameters:
-    T
-method pkg1.A.<T>m1(T)
-  signature: (T)
-             (T)
-  type parameters:
-    T
-  returns:
-    void
-method pkg1.A.<T extends java.lang.Number, U>m2(T, U)
-  signature: (T, U)
-             (T, U)
-  type parameters:
-    T extends java.lang.Number
-    U
-  returns:
-    void
--- a/langtools/test/jdk/javadoc/tool/generics/genericMethod/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public class A {
-    public <T> A() {}
-    public <T> void m1(T t) {}
-    public <T extends Number, U> void m2(T t, U u) {}
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericSuper/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the contents of the ClassDoc of a generic class.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import java.util.Arrays;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester =
-            new Tester("Main", "pkg1", "-package");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            ClassDoc[] cds = root.classes();
-            Arrays.sort(cds);
-            for (ClassDoc cd : cds) {
-                tester.printClass(cd);
-                tester.println();
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/genericSuper/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-class pkg1.A<V, W>
-  name: A / A / pkg1.A
-  type parameters:
-    V
-    W
-  superclass:
-    pkg1.S<W, V>
-  interfaces:
-    pkg1.I<java.lang.String>
-  constructors:
-    A()
-
-interface pkg1.I<R>
-  name: I / I / pkg1.I
-  type parameters:
-    R
-
-class pkg1.S<T, U>
-  name: S / S / pkg1.S
-  type parameters:
-    T
-    U
-  superclass:
-    java.lang.Object
-  constructors:
-    S()
-
--- a/langtools/test/jdk/javadoc/tool/generics/genericSuper/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-class S<T,U> {
-}
-
-interface I<R> {
-}
-
-public class A<V,W> extends S<W,V> implements I<String> {
-}
--- a/langtools/test/jdk/javadoc/tool/generics/supertypes/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4922918
- * @summary Check supertypes and superinterfaces of parameterized types.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.Arrays;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            ClassDoc[] cds = root.classes();
-            Arrays.sort(cds);
-            for (ClassDoc cd : cds) {
-                ParameterizedType arrayList =
-                    cd.superclassType().asParameterizedType();
-                tester.println(arrayList);
-                tester.println();
-
-                tester.println(arrayList.superclassType());
-                Type[] interfaces = arrayList.interfaceTypes();
-                // Sort interfaces by type name, for consistent output.
-                Arrays.sort(interfaces,
-                            new Comparator<Type>() {
-                                    public int compare(Type t1, Type t2) {
-                                        String name1 = t1.qualifiedTypeName();
-                                        String name2 = t2.qualifiedTypeName();
-                                        return name1.compareTo(name2);
-                                    }
-                                });
-                for (Type t : interfaces) {
-                    tester.println(t);
-                }
-                tester.println();
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/supertypes/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-java.util.ArrayList<java.lang.String>
-
-java.util.AbstractList<java.lang.String>
-java.io.Serializable
-java.lang.Cloneable
-java.util.List<java.lang.String>
-java.util.RandomAccess
-
-java.util.ArrayList<X>
-
-java.util.AbstractList<X>
-java.io.Serializable
-java.lang.Cloneable
-java.util.List<X>
-java.util.RandomAccess
-
--- a/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-import java.util.ArrayList;
-
-public class A extends ArrayList<String> {
-}
--- a/langtools/test/jdk/javadoc/tool/generics/supertypes/pkg1/B.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-import java.util.ArrayList;
-
-public class B<X> extends ArrayList<X> {
-}
--- a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the reading of generic methods and constructors.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            for (ClassDoc cd : root.classes()) {
-                for (MethodDoc m : cd.methods())
-                    tester.printMethod(m);
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-method pkg1.A.m1()
-  signature: ()
-             ()
-  throws:
-    T extends java.lang.Throwable
-  returns:
-    void
-method pkg1.A.<U extends java.lang.Throwable>m2()
-  signature: ()
-             ()
-  type parameters:
-    U extends java.lang.Throwable
-  throws:
-    U extends java.lang.Throwable
-  returns:
-    void
--- a/langtools/test/jdk/javadoc/tool/generics/throwsGeneric/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public interface A<T extends Throwable> {
-    void m1() throws T;
-    <U extends Throwable> void m2() throws U;
-}
--- a/langtools/test/jdk/javadoc/tool/generics/tparamCycle/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Check a type parameter whose bound cycles back on itself.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        ClassDoc cd = root.classes()[0];
-        System.out.println("*** " + cd);
-        TypeVariable E = cd.typeParameters()[0];
-        System.out.println("*** " + E);
-        Type bound = E.bounds()[0];
-        System.out.println("*** " + bound);
-
-        // Verify that we have an instantiation of Enum<E>, and not
-        // the generic interface.
-        ParameterizedType enumE = (ParameterizedType)bound;
-
-        if (enumE.asClassDoc() != cd) {
-            throw new Error("Type declaration and type use don't match up.");
-        } else {
-            return true;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/tparamCycle/pkg1/LikeEnum.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public interface LikeEnum<E extends LikeEnum<E>> {
-}
--- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the reading of type parameter tags on methods.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            for (ClassDoc cd : root.classes()) {
-                for (MethodDoc m : cd.methods()) {
-                    tester.printMethod(m);
-                }
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-method pkg1.A.<T, U>m1(T, U)
-  signature: (T, U)
-             (T, U)
-  @param <T> the kind of thing
-  @param <U> the other kind of thing
-  @param t the thing itself
-  @param u the other thing
-  type parameters:
-    T
-    U
-  returns:
-    void
--- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnMethod/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public interface A {
-    /**
-     * @param <T> the kind of thing
-     * @param <U> the other kind of thing
-     * @param t the thing itself
-     * @param u the other thing
-     */
-    public <T,U> void m1(T t, U u);
-}
--- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the reading of a type parameter tag on an interface.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            for (ClassDoc cd : root.classes()) {
-                tester.printClass(cd);
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-interface pkg1.A<T>
-  name: A / A / pkg1.A
-  type parameters:
-    T
-  @param <T> the type parameter
--- a/langtools/test/jdk/javadoc/tool/generics/tparamTagOnType/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-/**
- * @param <T> the type parameter
- */
-public interface A<T> {
-}
--- a/langtools/test/jdk/javadoc/tool/generics/wildcards/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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 4421066
- * @summary Verify the contents of the ClassDoc of a generic class.
- * @ignore API modifications
- * @library ../../lib
- * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
- * @run main Main
- */
-
-import java.io.IOException;
-import com.sun.javadoc.*;
-
-public class Main extends Tester.Doclet {
-
-    private static final Tester tester = new Tester("Main", "pkg1");
-
-    public static void main(String[] args) throws IOException {
-        tester.run();
-        tester.verify();
-    }
-
-    public static boolean run(DocletEnvironment root) {
-        try {
-            for (ClassDoc cd : root.classes()) {
-                tester.printClass(cd);
-            }
-
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/generics/wildcards/expected.out	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-class pkg1.A<T>
-  name: A / A / pkg1.A
-  type parameters:
-    T
-  superclass:
-    java.lang.Object
-  fields:
-    pkg1.A<?> f1
-    pkg1.A<? extends java.lang.Number> f2
-    pkg1.A<? super java.lang.Long> f3
-  constructors:
-    A()
-  methods:
-    void m1(A<?>)
-    void m2(A<? extends Number>)
-    void m3(A<? super Long>)
--- a/langtools/test/jdk/javadoc/tool/generics/wildcards/pkg1/A.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-package pkg1;
-
-public class A<T> {
-    public A<?> f1;
-    public A<? extends Number> f2;
-    public A<? super Long> f3;
-
-    public void m1(A<?> p1) {}
-    public void m2(A<? extends Number> p2) {}
-    public void m3(A<? super Long> p3) {}
-}
--- a/langtools/test/jdk/javadoc/tool/imports/I.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- */
-
-// The following imported class is bogus, but should still be returned
-// when inquired of.
-import bo.o.o.o.Gus;
-
-public interface I {
-}
--- a/langtools/test/jdk/javadoc/tool/imports/MissingImport.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, 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 5012972
- * @summary ClassDoc.getImportedClasses should return a class even if
- *          it's not in the classpath.
- * @ignore API modifications, testing deprecated APIs.
- * @modules jdk.javadoc
- */
-
-import java.util.Collections;
-import java.util.Set;
-import javax.lang.model.SourceVersion;
-import jdk.javadoc.doclet.Doclet;
-import jdk.javadoc.doclet.Doclet.Option;
-import jdk.javadoc.doclet.DocletEnvironment;
-
-
-public class MissingImport implements Doclet {
-
-    public static void main(String[] args) {
-        String thisFile = "" +
-            new java.io.File(System.getProperty("test.src", "."),
-                             "I.java");
-        String[] toolargs = {
-            "-doclet", "MissingImport",
-            "-docletpath", System.getProperty("test.classes", "."),
-            thisFile
-        };
-        if (com.sun.tools.javadoc.Main.execute(toolargs) != 0)
-            throw new Error("Javadoc encountered warnings or errors.");
-    }
-
-    /*
-     * The world's simplest doclet.
-     */
-    public static boolean run(DocletEnvironment root) {
-        ClassDoc c = root.classNamed("I");
-        ClassDoc[] imps = c.importedClasses();
-        if (imps.length == 0 ||
-            !imps[0].qualifiedName().equals("bo.o.o.o.Gus")) {
-            throw new Error("Import bo.o.o.o.Gus not found");
-        }
-        return true;
-    }
-
-    @Override
-    public String getName() {
-        return "Test";
-    }
-
-    @Override
-    public Set<Option> getSupportedOptions() {
-        return Collections.emptySet();
-    }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/lib/Tester.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2003, 2015, 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.
- */
-
-/*
- * A utility used to invoke and test the javadoc tool.
- *
- * @author Scott Seligman
- */
-
-
-import java.io.*;
-import java.util.*;
-
-import javax.lang.model.SourceVersion;
-
-
-public class Tester {
-
-    protected final String TEST_SRC = System.getProperty("test.src", ".");
-    protected final String TEST_CLASSES = System.getProperty("test.classes",
-                                                             ".");
-    private final String DEFAULT_ARGS[] = {
-        "-sourcepath", TEST_SRC,
-    };
-
-    private final File outputFile = new File(TEST_CLASSES, "testrun.out");
-    private final File expectedOutputFile = new File(TEST_SRC, "expected.out");
-
-    private String docletName;
-    private String[] args;
-    private Writer out = null;
-
-
-    /*
-     * Individual tests can extend this to create generics-aware doclets.
-     */
-    public abstract class Doclet extends jdk.javadoc.doclet.Doclet {
-
-        @Override
-        public SourceVersion getSupportedSourceVersion() {
-            return super.getSourceVersion();
-        }
-
-    }
-
-
-    public Tester(String docletName) {
-        this(docletName, new String[0]);
-    }
-
-    public Tester(String docletName, String... additionalArgs) {
-        this.docletName = docletName;
-        List<String> args = new ArrayList<>();
-        args.addAll(Arrays.asList(DEFAULT_ARGS));
-        args.addAll(Arrays.asList(additionalArgs));
-
-        try {
-            out = new BufferedWriter(new FileWriter(outputFile));
-        } catch (IOException e) {
-            throw new Error("Could not open output file " + outputFile);
-        }
-    }
-
-    public void run() throws IOException {
-        try {
-            if (Main.execute("javadoc", docletName, getClass().getClassLoader(), args) != 0) {
-                throw new Error("Javadoc errors encountered.");
-            }
-            System.out.println("--> Output written to " + outputFile);
-        } finally {
-            out.close();
-        }
-    }
-
-    /*
-     * Compare output of test run to expected output.
-     * Throw an Error if they don't match.
-     */
-    public void verify() throws IOException {
-        BufferedReader thisRun =
-            new BufferedReader(new FileReader(outputFile));
-        BufferedReader expected =
-            new BufferedReader(new FileReader(expectedOutputFile));
-
-        for (int lineNum = 1; true; lineNum++) {
-            String line1 = thisRun.readLine();
-            String line2 = expected.readLine();
-            if (line1 == null && line2 == null) {
-                return;         // EOF with all lines matching
-            }
-            if (line1 == null || !line1.equals(line2)) {
-                throw new Error(outputFile + ":" + lineNum +
-                                ": output doesn't match");
-            }
-        }
-    }
-
-
-    public void println(Object o) throws IOException {
-        prln(0, o);
-    }
-
-    public void println() throws IOException {
-        prln();
-    }
-//
-//    public void printPackage(PackageDoc p) throws IOException {
-//        prPackage(0, p);
-//    }
-//
-//    public void printClass(ClassDoc cd) throws IOException {
-//        if (cd.isAnnotationType())
-//            printAnnotationType((AnnotationTypeDoc)cd);
-//        else
-//            prClass(0, cd);
-//    }
-//
-//    public void printAnnotationType(AnnotationTypeDoc at) throws IOException {
-//        prAnnotationType(0, at);
-//    }
-//
-//    public void printField(FieldDoc f) throws IOException {
-//        prField(0, f);
-//    }
-//
-//    public void printParameter(Parameter p) throws IOException {
-//        prParameter(0, p);
-//    }
-//
-//    public void printMethod(MethodDoc m) throws IOException {
-//        prln(0, "method " + m);
-//        prMethod(0, m);
-//    }
-//
-//    public void printAnnotationTypeElement(AnnotationTypeElementDoc e)
-//                                                        throws IOException {
-//        prln(0, "element " + e);
-//        prMethod(0, e);
-//    }
-//
-//    public void printConstructor(ConstructorDoc c) throws IOException {
-//        prln(0, "constructor " + c);
-//        prExecutable(0, c);
-//    }
-//
-//
-//    private void prPackage(int off, PackageDoc p) throws IOException {
-//        prln(off, "package " + p);
-//        prAnnotations(off + 2, p.annotations());
-//    }
-//
-//    private void prClass(int off, ClassDoc cd) throws IOException {
-//        prln(off,
-//             (cd.isInterface() ? "interface" : cd.isEnum() ? "enum" : "class")
-//             + " " + cd);
-//        prln(off + 2, "name: " + cd.simpleTypeName() + " / " +
-//             cd.typeName() + " / " + cd.qualifiedTypeName());
-//        prAnnotations(off + 2, cd.annotations());
-//        prLabel(off + 2, "type parameters");
-//        for (Type t : cd.typeParameters())
-//            prln(off + 4, t);
-//        prParamTags(off + 2, cd.typeParamTags());
-//        prLabel(off + 2, "nested in");
-//        prln(off + 4, cd.containingClass());
-//        prLabel(off + 2, "superclass");
-//        prln(off + 4, cd.superclassType());
-//        prLabel(off + 2, "interfaces");
-//        Type[] ts = cd.interfaceTypes();
-//        Arrays.sort(ts);
-//        for (Type t : ts)
-//            prln(off + 4, t);
-//        prLabel(off + 2, "enum constants");
-//        for (FieldDoc f : cd.enumConstants())
-//            prln(off + 4, f.name());
-//        prLabel(off + 2, "fields");
-//        for (FieldDoc f : cd.fields())
-//            prln(off + 4, f.type() + " " + f.name());
-//        prLabel(off + 2, "constructors");
-//        for (ConstructorDoc c : cd.constructors())
-//            prln(off + 4, c.name() + c.flatSignature());
-//        prLabel(off + 2, "methods");
-//        for (MethodDoc m : cd.methods())
-//            prln(off + 4, typeUseString(m.returnType()) + " " +
-//                          m.name() + m.flatSignature());
-//    }
-//
-//    private void prAnnotationType(int off, AnnotationTypeDoc at)
-//                                                        throws IOException {
-//        prln(off, "@interface " + at);
-//        prAnnotations(off + 2, at.annotations());
-//        prLabel(off + 2, "elements");
-//        for (AnnotationTypeElementDoc e : at.elements()) {
-//            String def = (e.defaultValue() == null)
-//                                ? ""
-//                                : " default " + e.defaultValue();
-//            prln(off + 4, typeUseString(e.returnType()) + " " + e.name() +
-//                          e.flatSignature() + def);
-//        }
-//    }
-//
-//    private void prField(int off, FieldDoc f) throws IOException {
-//        prln(off, "field " + typeUseString(f.type()) + " " + f.name());
-//        prAnnotations(off + 2, f.annotations());
-//    }
-//
-//    private void prParameter(int off, Parameter p) throws IOException {
-//        prln(off, "parameter " + p);
-//        prAnnotations(off + 2, p.annotations());
-//    }
-//
-//    private void prMethod(int off, MethodDoc m) throws IOException {
-//        prExecutable(off, m);
-//        prLabel(off + 2, "returns");
-//        prln(off + 4, typeUseString(m.returnType()));
-//        prLabel(off + 2, "overridden type");
-//        prln(off + 4, m.overriddenType());
-//    }
-//
-//    private void prExecutable(int off, ExecutableMemberDoc m)
-//                                                        throws IOException {
-//        if (!m.isAnnotationTypeElement()) {
-//            prln(off + 2, "signature: " + m.flatSignature());
-//            prln(off + 2, "           " + m.signature());
-//        }
-//        prAnnotations(off + 2, m.annotations());
-//        prParamTags(off + 2, m.typeParamTags());
-//        prParamTags(off + 2, m.paramTags());
-//        prLabel(off + 2, "type parameters");
-//        for (Type t : m.typeParameters())
-//            prln(off + 4, t);
-//        prLabel(off + 2, "throws");
-//        Type[] ts = m.thrownExceptionTypes();
-//        Arrays.sort(ts);
-//        for (Type t : ts)
-//            prln(off + 4, t);
-//    }
-//
-//    private void prAnnotations(int off, AnnotationDesc[] as)
-//                                                        throws IOException {
-//        prLabel(off, "annotations");
-//        for (AnnotationDesc a : as)
-//            prln(off + 2, a.toString());
-//    }
-//
-//    private void prParamTags(int off, ParamTag tags[]) throws IOException {
-//        for (ParamTag tag : tags)
-//            prParamTag(off, tag);
-//    }
-//
-//    private void prParamTag(int off, ParamTag tag) throws IOException {
-//        String name = tag.parameterName();
-//        if (tag.isTypeParameter()) name = "<" + name + ">";
-//        prln(off, "@param " + name + " " + tag.parameterComment());
-//    }
-//
-//
-//    private String typeUseString(Type t) {
-//        return (t instanceof ClassDoc || t instanceof TypeVariable)
-//                ? t.typeName()
-//                : t.toString();
-//    }
-
-
-    // Labels queued for possible printing.  Innermost is first in list.
-    List<Line> labels = new ArrayList<Line>();
-
-    // Print label if its section is nonempty.
-    void prLabel(int off, String s) {
-        while (!labels.isEmpty() && labels.get(0).off >= off)
-            labels.remove(0);
-        labels.add(0, new Line(off, s));
-    }
-
-    // Print queued labels with offsets less than "off".
-    void popLabels(int off) throws IOException {
-        while (!labels.isEmpty()) {
-            Line label = labels.remove(0);
-            if (label.off < off)
-                prln(label.off, label.o + ":");
-        }
-    }
-
-    // Print "o" at given offset.
-    void pr(int off, Object o) throws IOException {
-        popLabels(off);
-        for (int i = 0; i < off; i++)
-            out.write(' ');
-        if (o != null)
-            out.write(o.toString());
-    }
-
-    // Print "o" (if non-null) at given offset, then newline.
-    void prln(int off, Object o) throws IOException {
-        if (o != null) {
-            pr(off, o);
-            prln();
-        }
-    }
-
-    // Print newline.
-    void prln() throws IOException {
-        out.write('\n');        // don't want platform-dependent separator
-    }
-
-
-    static class Line {
-        int off;
-        Object o;
-        Line(int off, Object o) { this.off = off; this.o = o; }
-    }
-}
--- a/langtools/test/jdk/javadoc/tool/sourceOnly/Test.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/sourceOnly/Test.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, 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
@@ -26,15 +26,15 @@
  * @bug 4548768
  * @summary Javadoc in JDK 1.4 uses classpath and not just source dir
  * @author gafter
- * @ignore API modifications
- * @modules jdk.javadoc
- * @compile p/SourceOnly.java
- * @run main p.SourceOnly
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @compile p/SourceOnly.java p/NonSource.jasm
+ * @run main Test
  */
 
-// this file is just a dummy to get the javadoc started.
-//
-// NOTE: this test only seems to work in separate JVM mode for
-// reasons having something to do with javing tools.jar
-// on the classpath.  Until that is sorted out, these tests
-// must be run in separate VM mode.
+public class Test {
+    public static void main(String[] args) {
+        // run javadoc on package p
+        if (jdk.javadoc.internal.tool.Main.execute("javadoc", "p.SourceOnly", "p") != 0)
+            throw new Error();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/sourceOnly/p/NonSource.jasm	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+package  p;
+
+super public class NonSource
+        version 46:0
+{
+    public Method "<init>":"()V"
+        stack 1 locals 1
+    {
+                aload_0;
+                invokespecial   Method java/lang/Object."<init>":"()V";
+                return;
+    }
+}
--- a/langtools/test/jdk/javadoc/tool/sourceOnly/p/SourceOnly.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/sourceOnly/p/SourceOnly.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, 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,29 +23,27 @@
 
 package p;
 
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.Locale;
 import java.util.Set;
 
 import javax.lang.model.SourceVersion;
 
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
 
 /** Test that when running javadoc on a package, we only get
  *  documentation for those classes for which source was provided.
  */
 public class SourceOnly implements Doclet {
-    public static void main(String[] args) {
-        // run javadoc on package p
-        int result = jdk.javadoc.internal.tool.Main.
-            execute("javadoc", "p.SourceOnly", SourceOnly.class.getClassLoader(), new String[] {"p"});
-        if (result != 0)
-            throw new Error();
-    }
-
-    public boolean start(DocletEnvironment root) {
+    NonSource dependency; // force a compilation error if not on classpath.
+    @Override
+    public boolean run(DocletEnvironment root) {
         if (root.getIncludedClasses().size() != 1)
-            throw new Error("wrong set of classes documented: " + java.util.Arrays.asList(root.getIncludedClasses()));
+            throw new Error("wrong set of classes documented: " +
+                    Arrays.asList(root.getIncludedClasses()));
         return true;
     }
 
@@ -63,4 +61,9 @@
     public SourceVersion getSupportedSourceVersion() {
         return SourceVersion.latest();
     }
+
+    @Override
+    public void init(Locale locale, Reporter reporter) {
+        // do nothing
+    }
 }
--- a/langtools/test/jdk/javadoc/tool/sourceOption/SourceOption.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/sourceOption/SourceOption.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -26,8 +26,7 @@
  * @bug     6507179
  * @summary Ensure that "-source" option isn't ignored.
  * @author  Scott Seligman
- * @ignore API modifications
- * @modules jdk.javadoc
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
  * @run main/fail SourceOption 7
  * @run main      SourceOption 9
  * @run main      SourceOption
@@ -55,34 +54,41 @@
  *      JDK8, JDK9, or JDK10.  Set -source below appropriately.
  */
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 
 import javax.lang.model.SourceVersion;
+import javax.tools.Diagnostic.Kind;
 
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.Doclet.Option;
 import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
 
 public class SourceOption implements Doclet {
 
     public static void main(String[] args) {
-        String[] params;
+        List<String> params = new ArrayList<>();
+        params.add("-sourcepath");
+        params.add(System.getProperty("test.src"));
+        params.add("-docletpath");
+        params.add(System.getProperty("test.classes"));
+        params.add("-doclet");
+        params.add("SourceOption");
         if ((args == null) || (args.length==0)) {
-            params = new String[]{"p"};
             System.out.println("NOTE : -source not provided, default taken");
         } else {
-            params = new String[]{"-source", args[0], "p"};
+            params.add("-source");
+            params.add(args[0]);
             System.out.println("NOTE : -source will be: " + args[0]);
         }
-
-        if (com.sun.tools.javadoc.Main.execute(
-                "javadoc",
-                "SourceOption",
-                SourceOption.class.getClassLoader(),
-                params) != 0)
-        throw new Error("Javadoc encountered warnings or errors.");
-
+        params.add("p");
+        System.out.println("arguments: " + params);
+        if (jdk.javadoc.internal.tool.Main.execute(params.toArray(new String[params.size()])) != 0)
+            throw new Error("Javadoc encountered warnings or errors.");
     }
 
     public boolean run(DocletEnvironment root) {
@@ -104,4 +110,9 @@
     public SourceVersion getSupportedSourceVersion() {
         return SourceVersion.latest();
     }
+
+    @Override
+    public void init(Locale locale, Reporter reporter) {
+        reporter.print(Kind.NOTE, "init");
+    }
 }
--- a/langtools/test/jdk/javadoc/tool/subpackageIgnore/SubpackageIgnore.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/subpackageIgnore/SubpackageIgnore.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -26,30 +26,33 @@
  * @bug 4773013
  * @summary When hunting subpackages, silently ignore any directory name that
  *          can't be part of a subpackage.
- * @ignore API modifications
- * @modules jdk.javadoc
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
  */
 
 import java.util.Collections;
+import java.util.Locale;
 import java.util.Set;
 
 import javax.lang.model.SourceVersion;
 
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
 
 public class SubpackageIgnore implements Doclet {
 
     public static void main(String[] args) {
-        if (jdk.javadoc.internal.tool.Main.execute(
-                "javadoc",
-                "SubpackageIgnore",
-                SubpackageIgnore.class.getClassLoader(),
-                new String[] {"-Xwerror",
-                              "-sourcepath",
-                              System.getProperty("test.src", "."),
-                              "-subpackages",
-                              "pkg1"}) != 0)
+        String[] cmds = new String[] {
+            "-docletpath",
+            System.getProperty("test.classes"),
+            "-doclet",
+            "SubpackageIgnore",
+            "-Xwerror",
+            "-sourcepath",
+            System.getProperty("test.src", "."),
+            "-subpackages",
+            "pkg1"};
+        if (jdk.javadoc.internal.tool.Main.execute(cmds) != 0)
             throw new Error("Javadoc encountered warnings or errors.");
     }
 
@@ -74,4 +77,9 @@
     public SourceVersion getSupportedSourceVersion() {
         return SourceVersion.latest();
     }
+
+    @Override
+    public void init(Locale locale, Reporter reporter) {
+        // do nothing
+    }
 }
--- a/langtools/test/jdk/javadoc/tool/varArgs/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/javadoc/tool/varArgs/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -26,7 +26,7 @@
  * @bug 4421066 5006659
  * @summary Verify the contents of a ClassDoc containing a varArgs method.
  *          Verify that see/link tags can use "..." notation.
- * @ignore API modifications
+ * @ignore 8152313 convert to doclet test framework
  * @library ../lib
  * @modules jdk.javadoc
  * @compile  ../lib/Tester.java Main.java
--- a/langtools/test/jdk/jshell/ClassesTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/ClassesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -41,6 +41,7 @@
 import org.testng.annotations.Test;
 
 import jdk.jshell.Diag;
+import static java.util.stream.Collectors.toList;
 import static jdk.jshell.Snippet.Status.VALID;
 import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED;
 import static jdk.jshell.Snippet.Status.RECOVERABLE_DEFINED;
@@ -210,8 +211,8 @@
                 ste(b, RECOVERABLE_NOT_DEFINED, RECOVERABLE_NOT_DEFINED, false, MAIN_SNIPPET));
         ***/
         // It is random which one it shows up in, but cyclic error should be there
-        List<Diag> diagsA = getState().diagnostics(a);
-        List<Diag> diagsB = getState().diagnostics(b);
+        List<Diag> diagsA = getState().diagnostics(a).collect(toList());
+        List<Diag> diagsB = getState().diagnostics(b).collect(toList());
         List<Diag> diags;
         if (diagsA.isEmpty()) {
             diags = diagsB;
--- a/langtools/test/jdk/jshell/CompletionSuggestionTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/CompletionSuggestionTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -415,7 +415,7 @@
         assertCompletion("new Clazz() {}.defaultM|", "defaultMethod()");
     }
 
-    @Test(enabled = false) // TODO 8129422
+    @Test
     public void testUncompletedDeclaration() {
         assertCompletion("class Clazz { Claz|", "Clazz");
         assertCompletion("class Clazz { class A extends Claz|", "Clazz");
@@ -423,16 +423,18 @@
         assertCompletion("class Clazz { static Clazz clazz; Object o = cla|", "clazz");
         assertCompletion("class Clazz { Clazz clazz; static Object o = cla|", true);
         assertCompletion("class Clazz { void method(Claz|", "Clazz");
-        assertCompletion("class A { int method() { return 0; } int a = meth|", "method");
+        assertCompletion("class A { int method() { return 0; } int a = meth|", "method()");
         assertCompletion("class A { int field = 0; int method() { return fiel|", "field");
-        assertCompletion("class A { static int method() { return 0; } int a = meth|", "method");
+        assertCompletion("class A { static int method() { return 0; } int a = meth|", "method()");
         assertCompletion("class A { static int field = 0; int method() { return fiel|", "field");
         assertCompletion("class A { int method() { return 0; } static int a = meth|", true);
         assertCompletion("class A { int field = 0; static int method() { return fiel|", true);
     }
 
-    @Test(enabled = false) // TODO 8129421
+    @Test
     public void testClassDeclaration() {
+        assertEval("void ClazzM() {}");
+        assertEval("void InterfaceM() {}");
         assertEval("interface Interface {}");
         assertCompletion("interface A extends Interf|", "Interface");
         assertCompletion("class A implements Interf|", "Interface");
@@ -445,6 +447,27 @@
         assertCompletion("interface A implements Inter|");
         assertCompletion("class A implements Claz|", true);
         assertCompletion("class A extends Clazz implements Interface, Interf|", true, "Interface1");
+        assertCompletion("class A extends Clazz implements Interface, Interf|", true, "Interface1");
+        assertEval("class InterfaceClazz {}");
+        assertCompletion("class A <T extends Claz|", "Clazz");
+        assertCompletion("class A <T extends Interf|", "Interface", "Interface1", "InterfaceClazz");
+        assertCompletion("class A <T extends Interface & Interf|", "Interface", "Interface1", "InterfaceClazz");
+        assertCompletion("class A <T extends Clazz & Interf|", "Interface", "Interface1", "InterfaceClazz");
+        assertCompletion("class A <T extends Claz|", true, "Clazz");
+        assertCompletion("class A <T extends Interf|", true, "Interface", "Interface1", "InterfaceClazz");
+        assertCompletion("class A <T extends Interface & Interf|", true, "Interface1");
+        assertCompletion("class A <T extends Clazz & Interf|", true, "Interface", "Interface1");
+    }
+
+    public void testMethodDeclaration() {
+        assertEval("void ClazzM() {}");
+        assertEval("void InterfaceM() {}");
+        assertEval("interface Interface {}");
+        assertCompletion("void m(Interf|", "Interface");
+        assertCompletion("void m(Interface i1, Interf|", "Interface");
+        assertEval("class InterfaceException extends Exception {}");
+        assertCompletion("void m(Interface i1) throws Interf|", "Interface", "InterfaceException");
+        assertCompletion("void m(Interface i1) throws Interf|", true, "InterfaceException");
     }
 
     public void testDocumentationOfUserDefinedMethods() {
--- a/langtools/test/jdk/jshell/EditorTestBase.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/EditorTestBase.java	Fri Aug 19 12:17:32 2016 -0700
@@ -125,7 +125,7 @@
         );
     }
 
-    @Test
+    @Test(enabled = false) // TODO 8163816
     public void testEditClass1() {
         testEditor(
                 a -> assertClass(a, "class A {}", "class", "A"),
@@ -163,7 +163,7 @@
         );
     }
 
-    @Test
+    @Test(enabled = false) // TODO 8163816
     public void testEditMethod1() {
         testEditor(
                 a -> assertMethod(a, "void f() {}", "()void", "f"),
--- a/langtools/test/jdk/jshell/ExternalEditorTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/ExternalEditorTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -201,7 +201,7 @@
         );
     }
 
-    @Test
+    @Test(enabled = false) // TODO 8159229
     public void testRemoveTempFile() {
         test(new String[]{"-nostartup"},
                 a -> assertCommandCheckOutput(a, "/set editor " + executionScript,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/jshell/JShellQueryTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2016, 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 8143964
+ * @summary test queries to the JShell that return Streams
+ * @build KullaTesting
+ * @run testng JShellQueryTest
+ */
+import java.util.Set;
+import java.util.stream.Stream;
+import jdk.jshell.Snippet;
+import org.testng.annotations.Test;
+
+import jdk.jshell.ImportSnippet;
+import jdk.jshell.MethodSnippet;
+import jdk.jshell.TypeDeclSnippet;
+import jdk.jshell.VarSnippet;
+import static java.util.stream.Collectors.joining;
+import static java.util.stream.Collectors.toSet;
+import static org.testng.Assert.assertEquals;
+
+@Test
+public class JShellQueryTest extends KullaTesting {
+
+    private <T> void checkStreamMatch(Stream<T> result, T... expected) {
+        Set<T> sns = result.collect(toSet());
+        Set<T> exp = Stream.of(expected).collect(toSet());
+        assertEquals(sns, exp);
+    }
+
+    public void testSnippets() {
+        checkStreamMatch(getState().snippets());
+        VarSnippet sx = varKey(assertEval("int x = 5;"));
+        VarSnippet sfoo = varKey(assertEval("String foo;"));
+        MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }"));
+        MethodSnippet svv = methodKey(assertEval("void vv() { }"));
+        checkStreamMatch(getState().snippets(), sx, sfoo, smm, svv);
+        TypeDeclSnippet sc = classKey(assertEval("class C { }"));
+        TypeDeclSnippet si = classKey(assertEval("interface I { }"));
+        ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;"));
+        checkStreamMatch(getState().snippets(), sx, sfoo, smm, svv, sc, si, simp);
+    }
+
+    public void testVars() {
+        checkStreamMatch(getState().variables());
+        VarSnippet sx = varKey(assertEval("int x = 5;"));
+        VarSnippet sfoo = varKey(assertEval("String foo;"));
+        MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }"));
+        MethodSnippet svv = methodKey(assertEval("void vv() { }"));
+        checkStreamMatch(getState().variables(), sx, sfoo);
+        TypeDeclSnippet sc = classKey(assertEval("class C { }"));
+        TypeDeclSnippet si = classKey(assertEval("interface I { }"));
+        ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;"));
+        checkStreamMatch(getState().variables(), sx, sfoo);
+    }
+
+    public void testMethods() {
+        checkStreamMatch(getState().methods());
+        VarSnippet sx = varKey(assertEval("int x = 5;"));
+        VarSnippet sfoo = varKey(assertEval("String foo;"));
+        MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }"));
+        MethodSnippet svv = methodKey(assertEval("void vv() { }"));
+        TypeDeclSnippet sc = classKey(assertEval("class C { }"));
+        TypeDeclSnippet si = classKey(assertEval("interface I { }"));
+        ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;"));
+        checkStreamMatch(getState().methods(), smm, svv);
+    }
+
+    public void testTypes() {
+        checkStreamMatch(getState().types());
+        VarSnippet sx = varKey(assertEval("int x = 5;"));
+        VarSnippet sfoo = varKey(assertEval("String foo;"));
+        MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }"));
+        MethodSnippet svv = methodKey(assertEval("void vv() { }"));
+        TypeDeclSnippet sc = classKey(assertEval("class C { }"));
+        TypeDeclSnippet si = classKey(assertEval("interface I { }"));
+        ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;"));
+        checkStreamMatch(getState().types(), sc, si);
+    }
+
+    public void testImports() {
+        checkStreamMatch(getState().imports());
+        VarSnippet sx = varKey(assertEval("int x = 5;"));
+        VarSnippet sfoo = varKey(assertEval("String foo;"));
+        MethodSnippet smm = methodKey(assertEval("int mm() { return 6; }"));
+        MethodSnippet svv = methodKey(assertEval("void vv() { }"));
+        TypeDeclSnippet sc = classKey(assertEval("class C { }"));
+        TypeDeclSnippet si = classKey(assertEval("interface I { }"));
+        ImportSnippet simp = importKey(assertEval("import java.lang.reflect.*;"));
+        checkStreamMatch(getState().imports(), simp);
+    }
+
+    public void testDiagnostics() {
+        Snippet sx = varKey(assertEval("int x = 5;"));
+        checkStreamMatch(getState().diagnostics(sx));
+        Snippet broken = methodKey(assertEvalFail("int m() { blah(); return \"hello\"; }"));
+        String res = getState().diagnostics(broken)
+                .map(d -> d.getCode())
+                .collect(joining("+"));
+        assertEquals(res, "compiler.err.cant.resolve.location.args+compiler.err.prob.found.req");
+    }
+
+    public void testUnresolvedDependencies() {
+        VarSnippet sx = varKey(assertEval("int x = 5;"));
+        checkStreamMatch(getState().unresolvedDependencies(sx));
+        MethodSnippet unr = methodKey(getState().eval("void uu() { baz(); zips(); }"));
+        checkStreamMatch(getState().unresolvedDependencies(unr), "method zips()", "method baz()");
+    }
+}
--- a/langtools/test/jdk/jshell/KullaTesting.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/KullaTesting.java	Fri Aug 19 12:17:32 2016 -0700
@@ -70,6 +70,7 @@
 import org.testng.annotations.BeforeMethod;
 
 import jdk.jshell.Diag;
+import static java.util.stream.Collectors.toList;
 import static jdk.jshell.Snippet.Status.*;
 import static org.testng.Assert.*;
 import static jdk.jshell.Snippet.SubKind.METHOD_SUBKIND;
@@ -183,7 +184,7 @@
     }
 
     public List<String> assertUnresolvedDependencies(DeclarationSnippet key, int unresolvedSize) {
-        List<String> unresolved = getState().unresolvedDependencies(key);
+        List<String> unresolved = getState().unresolvedDependencies(key).collect(toList());
         assertEquals(unresolved.size(), unresolvedSize, "Input: " + key.source() + ", checking unresolved: ");
         return unresolved;
     }
@@ -202,8 +203,8 @@
         SnippetEvent ste = events.get(0);
         DeclarationSnippet sn = ((UnresolvedReferenceException) ste.exception()).getSnippet();
         assertEquals(sn.name(), name, "Given input: " + input + ", checking name");
-        assertEquals(getState().unresolvedDependencies(sn).size(), unresolvedSize, "Given input: " + input + ", checking unresolved");
-        assertEquals(getState().diagnostics(sn).size(), diagnosticsSize, "Given input: " + input + ", checking diagnostics");
+        assertEquals(getState().unresolvedDependencies(sn).count(), unresolvedSize, "Given input: " + input + ", checking unresolved");
+        assertEquals(getState().diagnostics(sn).count(), (long) diagnosticsSize, "Given input: " + input + ", checking diagnostics");
         return sn;
     }
 
@@ -546,7 +547,7 @@
                                     " got: " + main.exception().toString());
                 }
             }
-            List<Diag> diagnostics = getState().diagnostics(mainKey);
+            List<Diag> diagnostics = getState().diagnostics(mainKey).collect(toList());
             switch (diagMain) {
                 case DIAG_OK:
                     assertEquals(diagnostics.size(), 0, "Expected no diagnostics, got: " + diagnosticsToString(diagnostics));
@@ -560,7 +561,7 @@
             }
             if (eventChain.mainInfo != null) {
                 for (STEInfo ste : eventChain.updates) {
-                    diagnostics = getState().diagnostics(ste.snippet());
+                    diagnostics = getState().diagnostics(ste.snippet()).collect(toList());
                     switch (diagUpdates) {
                         case DIAG_OK:
                             assertEquals(diagnostics.size(), 0, "Expected no diagnostics, got: " + diagnosticsToString(diagnostics));
@@ -637,7 +638,7 @@
         SnippetEvent e = events.get(0);
         Snippet key = e.snippet();
         assertEquals(getState().status(key), REJECTED);
-        List<Diag> diagnostics = getState().diagnostics(e.snippet());
+        List<Diag> diagnostics = getState().diagnostics(e.snippet()).collect(toList());
         assertTrue(diagnostics.size() > 0, "Expected diagnostics, got none");
         assertDiagnostic(input, diagnostics.get(0), expectedDiagnostic);
         assertTrue(key != null, "key must never be null, but it was for: " + input);
@@ -656,7 +657,7 @@
         List<SnippetEvent> events = assertEval(input, IGNORE_VALUE, null,
                 DiagCheck.DIAG_WARNING, DiagCheck.DIAG_IGNORE, mainInfo, updates);
         SnippetEvent e = events.get(0);
-        List<Diag> diagnostics = getState().diagnostics(e.snippet());
+        List<Diag> diagnostics = getState().diagnostics(e.snippet()).collect(toList());
         if (expectedDiagnostic != null) assertDiagnostic(input, diagnostics.get(0), expectedDiagnostic);
         return e.snippet();
     }
@@ -704,12 +705,12 @@
         String source = declarationKey.source();
         assertEquals(declarationKey.name(), expectedName,
                 "Expected " + source + " to have the name: " + expectedName + ", got: " + declarationKey.name());
-        List<String> unresolved = getState().unresolvedDependencies(declarationKey);
-        assertEquals(unresolved.size(), unressz, "Expected " + source + " to have " + unressz
-                + " unresolved symbols, got: " + unresolved.size());
-        List<Diag> otherCorralledErrors = getState().diagnostics(declarationKey);
-        assertEquals(otherCorralledErrors.size(), othersz, "Expected " + source + " to have " + othersz
-                + " other errors, got: " + otherCorralledErrors.size());
+        long unresolved = getState().unresolvedDependencies(declarationKey).count();
+        assertEquals(unresolved, unressz, "Expected " + source + " to have " + unressz
+                + " unresolved symbols, got: " + unresolved);
+        long otherCorralledErrorsCount = getState().diagnostics(declarationKey).count();
+        assertEquals(otherCorralledErrorsCount, othersz, "Expected " + source + " to have " + othersz
+                + " other errors, got: " + otherCorralledErrorsCount);
     }
 
     public void assertKey(Snippet key, Status expectedStatus, SubKind expectedSubKind) {
@@ -757,31 +758,20 @@
     }
 
     public void assertNumberOfActiveVariables(int cnt) {
-        Collection<VarSnippet> variables = getState().variables();
-        assertEquals(variables.size(), cnt, "Variables : " + variables);
+        assertEquals(getState().variables().count(), cnt, "Variables : " + getState().variables().collect(toList()));
     }
 
     public void assertNumberOfActiveMethods(int cnt) {
-        Collection<MethodSnippet> methods = getState().methods();
-        assertEquals(methods.size(), cnt, "Methods : " + methods);
+        assertEquals(getState().methods().count(), cnt, "Methods : " + getState().methods().collect(toList()));
     }
 
     public void assertNumberOfActiveClasses(int cnt) {
-        Collection<TypeDeclSnippet> classes = getState().types();
-        assertEquals(classes.size(), cnt, "Classes : " + classes);
-    }
-
-    public void assertMembers(Collection<? extends Snippet> members, Set<MemberInfo> expected) {
-        assertEquals(members.size(), expected.size(), "Expected : " + expected + ", actual : " + members);
-        assertEquals(members.stream()
-                        .map(this::getMemberInfo)
-                        .collect(Collectors.toSet()),
-                expected);
+        assertEquals(getState().types().count(), cnt, "Types : " + getState().types().collect(toList()));
     }
 
     public void assertKeys(MemberInfo... expected) {
         int index = 0;
-        List<Snippet> snippets = getState().snippets();
+        List<Snippet> snippets = getState().snippets().collect(toList());
         assertEquals(allSnippets.size(), snippets.size());
         for (Snippet sn : snippets) {
             if (sn.kind().isPersistent() && getState().status(sn).isActive()) {
@@ -801,7 +791,7 @@
 
     public void assertActiveKeys(Snippet... expected) {
         int index = 0;
-        for (Snippet key : getState().snippets()) {
+        for (Snippet key : getState().snippets().collect(toList())) {
             if (state.status(key).isActive()) {
                 assertEquals(expected[index], key, String.format("Difference in #%d. Expected: %s, actual: %s", index, key, expected[index]));
                 ++index;
@@ -809,31 +799,43 @@
         }
     }
 
-    private List<Snippet> filterDeclaredKeys(Predicate<Snippet> p) {
-        return getActiveKeys().stream()
+    private void assertActiveSnippets(Stream<? extends Snippet> snippets, Predicate<Snippet> p, String label) {
+        Set<Snippet> active = getActiveKeys().stream()
                 .filter(p)
-                .collect(Collectors.toList());
+                .collect(Collectors.toSet());
+        Set<Snippet> got = snippets
+                .collect(Collectors.toSet());
+        assertEquals(active, got, label);
     }
 
     public void assertVariables() {
-        assertEquals(getState().variables(), filterDeclaredKeys((key) -> key instanceof VarSnippet), "Variables");
+        assertActiveSnippets(getState().variables(), (key) -> key instanceof VarSnippet, "Variables");
     }
 
     public void assertMethods() {
-        assertEquals(getState().methods(), filterDeclaredKeys((key) -> key instanceof MethodSnippet), "Methods");
+        assertActiveSnippets(getState().methods(), (key) -> key instanceof MethodSnippet, "Methods");
     }
 
     public void assertClasses() {
-        assertEquals(getState().types(), filterDeclaredKeys((key) -> key instanceof TypeDeclSnippet), "Classes");
+        assertActiveSnippets(getState().types(), (key) -> key instanceof TypeDeclSnippet, "Classes");
+    }
+
+    public void assertMembers(Stream<? extends Snippet> members, MemberInfo...expectedInfos) {
+        Set<MemberInfo> expected = Stream.of(expectedInfos).collect(Collectors.toSet());
+        Set<MemberInfo> got = members
+                        .map(this::getMemberInfo)
+                        .collect(Collectors.toSet());
+        assertEquals(got.size(), expected.size(), "Expected : " + expected + ", actual : " + members);
+        assertEquals(got, expected);
     }
 
     public void assertVariables(MemberInfo...expected) {
-        assertMembers(getState().variables(), Stream.of(expected).collect(Collectors.toSet()));
+        assertMembers(getState().variables(), expected);
     }
 
     public void assertMethods(MemberInfo...expected) {
-        assertMembers(getState().methods(), Stream.of(expected).collect(Collectors.toSet()));
-        for (MethodSnippet methodKey : getState().methods()) {
+        assertMembers(getState().methods(), expected);
+        getState().methods().forEach(methodKey -> {
             MemberInfo expectedInfo = null;
             for (MemberInfo info : expected) {
                 if (info.name.equals(methodKey.name()) && info.type.equals(methodKey.signature())) {
@@ -843,11 +845,11 @@
             assertNotNull(expectedInfo, "Not found method: " + methodKey.name());
             int lastIndexOf = expectedInfo.type.lastIndexOf(')');
             assertEquals(methodKey.parameterTypes(), expectedInfo.type.substring(1, lastIndexOf), "Parameter types");
-        }
+        });
     }
 
     public void assertClasses(MemberInfo...expected) {
-        assertMembers(getState().types(), Stream.of(expected).collect(Collectors.toSet()));
+        assertMembers(getState().types(), expected);
     }
 
     public void assertCompletion(String code, String... expected) {
--- a/langtools/test/jdk/jshell/RejectedFailedTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/RejectedFailedTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -39,6 +39,7 @@
 import jdk.jshell.Snippet.Status;
 
 import jdk.jshell.SnippetEvent;
+import static java.util.stream.Collectors.toList;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 
@@ -49,7 +50,7 @@
         List<SnippetEvent> events = assertEvalFail(input);
         assertEquals(events.size(), 1, "Expected one event, got: " + events.size());
         SnippetEvent e = events.get(0);
-        List<Diag> diagnostics = getState().diagnostics(e.snippet());
+        List<Diag> diagnostics = getState().diagnostics(e.snippet()).collect(toList());
         assertTrue(diagnostics.size() > 0, "Expected diagnostics, got none");
         assertEquals(e.exception(), null, "Expected exception to be null.");
         assertEquals(e.value(), null, "Expected value to be null.");
@@ -60,7 +61,7 @@
         SubKind expectedSubKind = kind == Kind.ERRONEOUS ? SubKind.UNKNOWN_SUBKIND : SubKind.METHOD_SUBKIND;
         assertEquals(key.subKind(), expectedSubKind, "SubKind: ");
         assertTrue(key.id().compareTo(prevId) > 0, "Current id: " + key.id() + ", previous: " + prevId);
-        assertEquals(getState().diagnostics(key), diagnostics, "Expected retrieved diagnostics to match, but didn't.");
+        assertEquals(getState().diagnostics(key).collect(toList()), diagnostics, "Expected retrieved diagnostics to match, but didn't.");
         assertEquals(key.source(), input, "Expected retrieved source: " +
                 key.source() + " to match input: " + input);
         assertEquals(getState().status(key), Status.REJECTED, "Expected status of REJECTED, got: " + getState().status(key));
--- a/langtools/test/jdk/jshell/ReplaceTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/ReplaceTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -28,9 +28,9 @@
  * @run testng ReplaceTest
  */
 
-import java.util.Collection;
-
+import java.util.Iterator;
 import java.util.List;
+import java.util.stream.Stream;
 import jdk.jshell.Snippet;
 import jdk.jshell.MethodSnippet;
 import jdk.jshell.PersistentSnippet;
@@ -42,6 +42,7 @@
 import jdk.jshell.SnippetEvent;
 import jdk.jshell.UnresolvedReferenceException;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
 import static jdk.jshell.Snippet.Status.*;
 import static jdk.jshell.Snippet.SubKind.*;
 import static org.testng.Assert.assertTrue;
@@ -90,17 +91,22 @@
         assertActiveKeys();
     }
 
+    private <T extends Snippet> void identityMatch(Stream<T> got, T expected) {
+        Iterator<T> it = got.iterator();
+        assertTrue(it.hasNext(), "expected exactly one");
+        assertTrue(expected == it.next(), "Identity must not change");
+        assertFalse(it.hasNext(), "expected exactly one");
+    }
+
     public void testReplaceVarToMethod() {
         Snippet x = varKey(assertEval("int x;"));
-        Snippet musn = methodKey(assertEval("double mu() { return x * 4; }"));
+        MethodSnippet musn = methodKey(assertEval("double mu() { return x * 4; }"));
         assertEval("x == 0;", "true");
         assertEval("mu() == 0.0;", "true");
         assertEval("double x = 2.5;",
                 ste(MAIN_SNIPPET, VALID, VALID, true, null),
                 ste(x, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
-        Collection<MethodSnippet> meths = getState().methods();
-        assertEquals(meths.size(), 1);
-        assertTrue(musn == meths.iterator().next(), "Identity must not change");
+        identityMatch(getState().methods(), musn);
         assertEval("x == 2.5;", "true");
         assertEval("mu() == 10.0;", "true");  // Auto redefine
         assertActiveKeys();
@@ -132,15 +138,13 @@
 
     public void testReplaceVarToClass() {
         Snippet x = varKey(assertEval("int x;"));
-        Snippet c = classKey(assertEval("class A { double a = 4 * x; }"));
+        TypeDeclSnippet c = classKey(assertEval("class A { double a = 4 * x; }"));
         assertEval("x == 0;", "true");
         assertEval("new A().a == 0.0;", "true");
         assertEval("double x = 2.5;",
                 ste(MAIN_SNIPPET, VALID, VALID, true, null),
                 ste(x, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
-        Collection<TypeDeclSnippet> classes = getState().types();
-        assertEquals(classes.size(), 1);
-        assertTrue(c == classes.iterator().next(), "Identity must not change");
+        identityMatch(getState().types(), c);
         assertEval("x == 2.5;", "true");
         assertEval("new A().a == 10.0;", "true");
         assertActiveKeys();
@@ -148,16 +152,14 @@
 
     public void testReplaceMethodToClass() {
         Snippet x = methodKey(assertEval("int x() { return 0; }"));
-        Snippet c = classKey(assertEval("class A { double a = 4 * x(); }"));
+        TypeDeclSnippet c = classKey(assertEval("class A { double a = 4 * x(); }"));
         assertEval("x() == 0;", "true");
         assertEval("new A().a == 0.0;", "true");
         assertEval("double x() { return 2.5; }",
                 ste(MAIN_SNIPPET, VALID, VALID, true, null),
                 ste(x, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
         assertEval("x();", "2.5");
-        Collection<TypeDeclSnippet> classes = getState().types();
-        assertEquals(classes.size(), 1);
-        assertTrue(c == classes.iterator().next(), "Identity must not change");
+        identityMatch(getState().types(), c);
         assertEval("x() == 2.5;", "true");
         assertEval("new A().a == 10.0;", "true");
         assertActiveKeys();
@@ -313,8 +315,8 @@
         Snippet assn = ste.snippet();
         DeclarationSnippet unsn = ((UnresolvedReferenceException) ste.exception()).getSnippet();
         assertEquals(unsn.name(), "A", "Wrong with unresolved");
-        assertEquals(getState().unresolvedDependencies(unsn).size(), 1, "Wrong size unresolved");
-        assertEquals(getState().diagnostics(unsn).size(), 0, "Expected no diagnostics");
+        assertEquals(getState().unresolvedDependencies(unsn).count(), 1, "Wrong size unresolved");
+        assertEquals(getState().diagnostics(unsn).count(), 0L, "Expected no diagnostics");
 
         Snippet g = varKey(assertEval("int g = 10;", "10",
                 added(VALID),
--- a/langtools/test/jdk/jshell/VariablesTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/jdk/jshell/VariablesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -39,6 +39,7 @@
 import jdk.jshell.SnippetEvent;
 import org.testng.annotations.Test;
 
+import static java.util.stream.Collectors.toList;
 import static jdk.jshell.Snippet.Status.*;
 import static jdk.jshell.Snippet.SubKind.VAR_DECLARATION_SUBKIND;
 import static org.testng.Assert.assertEquals;
@@ -331,7 +332,7 @@
         //assertEquals(getState().source(snippet), src);
         //assertEquals(snippet, undefKey);
         assertEquals(getState().status(undefKey), RECOVERABLE_NOT_DEFINED);
-        List<String> unr = getState().unresolvedDependencies((VarSnippet) undefKey);
+        List<String> unr = getState().unresolvedDependencies((VarSnippet) undefKey).collect(toList());;
         assertEquals(unr.size(), 1);
         assertEquals(unr.get(0), "class undefined");
         assertVariables(variable("undefined", "d"));
--- a/langtools/test/tools/all/RunCodingRules.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/all/RunCodingRules.java	Fri Aug 19 12:17:32 2016 -0700
@@ -111,11 +111,11 @@
             Path crulesTarget = targetDir.resolve("crules");
             Files.createDirectories(crulesTarget);
             List<String> crulesOptions = Arrays.asList(
-                    "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                    "-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-                    "-XaddExports:jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
-                    "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-                    "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                    "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                    "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
+                    "--add-exports", "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
+                    "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+                    "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                     "-d", crulesTarget.toString());
             javaCompiler.getTask(null, fm, noErrors, crulesOptions, null,
                     fm.getJavaFileObjectsFromFiles(crulesFiles)).call();
@@ -178,7 +178,7 @@
 
             List<String> options = Arrays.asList(
                     "-d", sourceTarget.toString(),
-                    "-modulesourcepath", mainSrcDir + FS + "*" + FS + "share" + FS + "classes" + PS
+                    "--module-source-path", mainSrcDir + FS + "*" + FS + "share" + FS + "classes" + PS
                                        + genSrcTarget + FS + "*" + FS + "share" + FS + "classes",
                     "-XDaccessInternalAPI",
                     "-processorpath", processorPath,
--- a/langtools/test/tools/javac/6410653/T6410653.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/6410653/T6410653.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -49,9 +49,8 @@
         compiler.run(null, null, out, "-d", source, source);
         System.err.println(">>>" + out + "<<<");
         useRawMessages.setBoolean(null, false);
-        if (!out.toString().equals(String.format("%s%n%s%n",
-                                                 "javac: javac.err.file.not.directory",
-                                                 "javac.msg.usage"))) {
+        if (!out.toString().equals(String.format("%s%n",
+                                                 "javac: javac.err.file.not.directory"))) {
             throw new AssertionError(out);
         }
         System.out.println("Test PASSED.  Running javac again to see localized output:");
--- a/langtools/test/tools/javac/MethodParameters/AnnotationTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/AnnotationTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters AnnotationTest.java
- * @run main Tester AnnotationTest AnnotationTest.out
+ * @run main MethodParametersTester AnnotationTest AnnotationTest.out
  */
 
 import java.lang.annotation.*;
--- a/langtools/test/tools/javac/MethodParameters/AnonymousClass.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/AnonymousClass.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters AnonymousClass.java
- * @run main Tester AnonymousClass AnonymousClass.out
+ * @run main MethodParametersTester AnonymousClass AnonymousClass.out
  */
 
 class AnonymousClass {
--- a/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/ClassFileVisitor.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -52,9 +52,9 @@
  * rule is checked: <i>param[n] == ++param[n-1].charAt(0) + param[n-1]</i>
  * </ul>
  */
-class ClassFileVisitor extends Tester.Visitor {
+class ClassFileVisitor extends MethodParametersTester.Visitor {
 
-    Tester tester;
+    MethodParametersTester tester;
 
     public String cname;
     public boolean isEnum;
@@ -66,7 +66,7 @@
     public ClassFile classFile;
 
 
-    public ClassFileVisitor(Tester tester) {
+    public ClassFileVisitor(MethodParametersTester tester) {
         super(tester);
     }
 
--- a/langtools/test/tools/javac/MethodParameters/Constructors.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/Constructors.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters Constructors.java
- * @run main Tester Constructors Constructors.out
+ * @run main MethodParametersTester Constructors Constructors.out
  */
 
 public class Constructors {
--- a/langtools/test/tools/javac/MethodParameters/EnumTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/EnumTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582 8008658
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters EnumTest.java
- * @run main Tester EnumTest EnumTest.out
+ * @run main MethodParametersTester EnumTest EnumTest.out
  */
 
 /** Test that parameter names are recorded for enum methods */
--- a/langtools/test/tools/javac/MethodParameters/InstanceMethods.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/InstanceMethods.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters InstanceMethods.java
- * @run main Tester InstanceMethods InstanceMethods.out
+ * @run main MethodParametersTester InstanceMethods InstanceMethods.out
  */
 
 public class InstanceMethods {
--- a/langtools/test/tools/javac/MethodParameters/LambdaTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/LambdaTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582 8037546 8138729
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters LambdaTest.java
- * @run main Tester LambdaTest LambdaTest.out
+ * @run main MethodParametersTester LambdaTest LambdaTest.out
  */
 
 /**
--- a/langtools/test/tools/javac/MethodParameters/LocalClassTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/LocalClassTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582 8008658
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters LocalClassTest.java
- * @run main Tester LocalClassTest LocalClassTest.out
+ * @run main MethodParametersTester LocalClassTest LocalClassTest.out
  */
 
 class LocalClassTest {
--- a/langtools/test/tools/javac/MethodParameters/MemberClassTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/MemberClassTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582 8008658
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters MemberClassTest.java
- * @run main Tester MemberClassTest MemberClassTest.out
+ * @run main MethodParametersTester MemberClassTest MemberClassTest.out
  */
 
 class MemberClassTest {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MethodParameters/MethodParametersTester.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2013, 2016, 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.
+ */
+
+import java.io.*;
+import java.lang.reflect.Constructor;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Test driver for MethodParameters testing.
+ * <p>
+ * The intended use of this driver is to run it, giving the name of
+ * a single class compiled with -parameters as argument. The driver
+ * will test the specified class, and any nested classes it finds.
+ * <p>
+ * Each class is tested in two way. By refelction, and by directly
+ * checking MethodParameters attributes in the classfile. The checking
+ * is done using two visitor classes {@link ClassFileVisitor} and
+ * {@link ReflectionVisitor}.
+ * <p>
+ * The {@code ReflectionVisitor} test logically belongs with library tests.
+ * we wish to reuse the same test-cases, so both test are committed together,
+ * under langtools. The tests, may be duplicated in the jdk repository.
+ */
+public class MethodParametersTester {
+
+    final static File classesdir = new File(System.getProperty("test.classes", "."));
+
+    private String classname;
+    private File[] files;
+    private File refFile;
+    private int errors;
+    private int warnings;
+    private int diffGolden;
+
+    /**
+     * The visitor classes that does the actual checking are referenced
+     * statically, to force compilations, without having to reference
+     * them in individual test cases.
+     * <p>
+     * This makes it easy to change the set of visitors, without
+     * complicating the design with dynamic discovery and compilation
+     * of visitor classes.
+     */
+    static final Class visitors[] = {
+        ClassFileVisitor.class,
+        ReflectionVisitor.class
+    };
+
+    /**
+     * Test-driver expect a single classname as argument.
+     */
+    public static void main(String... args) throws Exception {
+        if (args.length != 2) {
+            throw new Error("A single class name and a golden file are expected as argument");
+        }
+        String testSrc = System.getProperty("test.src");
+        String testName = args[0];
+        String testGoldenFile = args[1];
+        final String pattern = testName + ".*\\.class";
+        File refFile = new File(testSrc, testGoldenFile);
+        File[] files = classesdir.listFiles(new FileFilter() {
+                public boolean accept(File f) {
+                    return f.getName().matches(pattern);
+                }
+            });
+        if (files.length == 0) {
+            File file = new File(classesdir, testName + ".class");
+            throw new Error(file.getPath() + " not found");
+        }
+
+        new MethodParametersTester(testName, files, refFile).run();
+    }
+
+    public MethodParametersTester(String name, File[] files, File refFile) {
+        this.classname = name;
+        this.files = files;
+        this.refFile = refFile;
+    }
+
+    void run() throws Exception {
+
+        // Test with each visitor
+        for (Class<Visitor> vclass : visitors) {
+            boolean compResult = false;
+            try {
+                String vname = vclass.getName();
+                Constructor c = vclass.getConstructor(MethodParametersTester.class);
+
+                info("\nRun " + vname + " for " + classname + "\n");
+                StringBuilder sb = new StringBuilder();
+                for (File f : files) {
+                    String fname = f.getName();
+                    fname = fname.substring(0, fname.length() - 6);
+                    Visitor v = (Visitor) c.newInstance(this);
+                    try {
+                        v.visitClass(fname, f,  sb);
+                    } catch(Exception e) {
+                        error("Uncaught exception in visitClass()");
+                        e.printStackTrace();
+                    }
+                }
+                String output = sb.toString();
+                info(output);
+                compResult = compareOutput(refFile, output);
+            } catch(ReflectiveOperationException e) {
+                warn("Class " + vclass.getName() + " ignored, not a Visitor");
+                continue;
+            }
+            if (!compResult) {
+                diffGolden++;
+                error("The output from " + vclass.getName() + " did not match golden file.");
+        }
+        }
+
+        if (0 != diffGolden)
+            throw new Exception("Test output is not equal with golden file.");
+
+        if(0 != warnings)
+                System.err.println("Test generated " + warnings + " warnings");
+
+        if(0 != errors)
+            throw new Exception("Tester test failed with " +
+                                errors + " errors");
+    }
+    // Check if test output matches the golden file.
+    boolean compareOutput(File refFile, String sb)
+            throws FileNotFoundException, IOException {
+
+        List<String> refFileList = Files.readAllLines(refFile.toPath(), StandardCharsets.UTF_8);
+        List<String> sbList = Arrays.asList(sb.split("[\r\n]+"));
+        // Check if test output contains unexpected lines or is missing expected lines.
+        List<String> sbOnly = new ArrayList<>(sbList);
+        sbOnly.removeAll(refFileList);
+        for (String line: sbOnly)
+            error("unexpected line found: " + line);
+
+        List<String> refOnly = new ArrayList<>(refFileList);
+        refOnly.removeAll(sbList);
+        for (String line: refOnly)
+            error("expected line not found: " + line);
+
+        return sbOnly.isEmpty() && refOnly.isEmpty();
+    }
+
+    abstract static  class Visitor {
+        MethodParametersTester tester;
+        File classesdir;
+
+        public Visitor(MethodParametersTester tester) {
+            this.tester = tester;
+        }
+
+        abstract void visitClass(final String classname, final File  cfile,
+                final StringBuilder sb) throws Exception;
+
+        public void error(String msg) {
+            tester.error(msg);
+        }
+
+        public void warn(String msg) {
+            tester.warn(msg);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    void warn(String msg) {
+        System.err.println("Warning: " + msg);
+        warnings++;
+    }
+
+    void info(String msg) {
+        System.out.println(msg);
+    }
+}
--- a/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/ReflectionVisitor.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -27,9 +27,9 @@
 /**
  * Test MethodParameter attributs by reflection API
  */
-public class ReflectionVisitor extends Tester.Visitor {
+public class ReflectionVisitor extends MethodParametersTester.Visitor {
 
-    public ReflectionVisitor(Tester tester) {
+    public ReflectionVisitor(MethodParametersTester tester) {
         super(tester);
     }
 
--- a/langtools/test/tools/javac/MethodParameters/StaticMethods.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/StaticMethods.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters StaticMethods.java
- * @run main Tester StaticMethods StaticMethods.out
+ * @run main MethodParametersTester StaticMethods StaticMethods.out
  */
 
 public class StaticMethods {
--- a/langtools/test/tools/javac/MethodParameters/Tester.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2013, 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.
- */
-
-import java.io.*;
-import java.lang.reflect.Constructor;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Test driver for MethodParameters testing.
- * <p>
- * The intended use of this driver is to run it, giving the name of
- * a single class compiled with -parameters as argument. The driver
- * will test the specified class, and any nested classes it finds.
- * <p>
- * Each class is tested in two way. By refelction, and by directly
- * checking MethodParameters attributes in the classfile. The checking
- * is done using two visitor classes {@link ClassFileVisitor} and
- * {@link ReflectionVisitor}.
- * <p>
- * The {@code ReflectionVisitor} test logically belongs with library tests.
- * we wish to reuse the same test-cases, so both test are committed together,
- * under langtools. The tests, may be duplicated in the jdk repository.
- */
-public class Tester {
-
-    final static File classesdir = new File(System.getProperty("test.classes", "."));
-
-    private String classname;
-    private File[] files;
-    private File refFile;
-    private int errors;
-    private int warnings;
-    private int diffGolden;
-
-    /**
-     * The visitor classes that does the actual checking are referenced
-     * statically, to force compilations, without having to reference
-     * them in individual test cases.
-     * <p>
-     * This makes it easy to change the set of visitors, without
-     * complicating the design with dynamic discovery and compilation
-     * of visitor classes.
-     */
-    static final Class visitors[] = {
-        ClassFileVisitor.class,
-        ReflectionVisitor.class
-    };
-
-    /**
-     * Test-driver expect a single classname as argument.
-     */
-    public static void main(String... args) throws Exception {
-        if (args.length != 2) {
-            throw new Error("A single class name and a golden file are expected as argument");
-        }
-        String testSrc = System.getProperty("test.src");
-        String testName = args[0];
-        String testGoldenFile = args[1];
-        final String pattern = testName + ".*\\.class";
-        File refFile = new File(testSrc, testGoldenFile);
-        File[] files = classesdir.listFiles(new FileFilter() {
-                public boolean accept(File f) {
-                    return f.getName().matches(pattern);
-                }
-            });
-        if (files.length == 0) {
-            File file = new File(classesdir, testName + ".class");
-            throw new Error(file.getPath() + " not found");
-        }
-
-        new Tester(testName, files, refFile).run();
-    }
-
-    public Tester(String name, File[] files, File refFile) {
-        this.classname = name;
-        this.files = files;
-        this.refFile = refFile;
-    }
-
-    void run() throws Exception {
-
-        // Test with each visitor
-        for (Class<Visitor> vclass : visitors) {
-            boolean compResult = false;
-            try {
-                String vname = vclass.getName();
-                Constructor c = vclass.getConstructor(Tester.class);
-
-                info("\nRun " + vname + " for " + classname + "\n");
-                StringBuilder sb = new StringBuilder();
-                for (File f : files) {
-                    String fname = f.getName();
-                    fname = fname.substring(0, fname.length() - 6);
-                    Visitor v = (Visitor) c.newInstance(this);
-                    try {
-                        v.visitClass(fname, f,  sb);
-                    } catch(Exception e) {
-                        error("Uncaught exception in visitClass()");
-                        e.printStackTrace();
-                    }
-                }
-                String output = sb.toString();
-                info(output);
-                compResult = compareOutput(refFile, output);
-            } catch(ReflectiveOperationException e) {
-                warn("Class " + vclass.getName() + " ignored, not a Visitor");
-                continue;
-            }
-            if (!compResult) {
-                diffGolden++;
-                error("The output from " + vclass.getName() + " did not match golden file.");
-        }
-        }
-
-        if (0 != diffGolden)
-            throw new Exception("Test output is not equal with golden file.");
-
-        if(0 != warnings)
-                System.err.println("Test generated " + warnings + " warnings");
-
-        if(0 != errors)
-            throw new Exception("Tester test failed with " +
-                                errors + " errors");
-    }
-    // Check if test output matches the golden file.
-    boolean compareOutput(File refFile, String sb)
-            throws FileNotFoundException, IOException {
-
-        List<String> refFileList = Files.readAllLines(refFile.toPath(), StandardCharsets.UTF_8);
-        List<String> sbList = Arrays.asList(sb.split("[\r\n]+"));
-        // Check if test output contains unexpected lines or is missing expected lines.
-        List<String> sbOnly = new ArrayList<>(sbList);
-        sbOnly.removeAll(refFileList);
-        for (String line: sbOnly)
-            error("unexpected line found: " + line);
-
-        List<String> refOnly = new ArrayList<>(refFileList);
-        refOnly.removeAll(sbList);
-        for (String line: refOnly)
-            error("expected line not found: " + line);
-
-        return sbOnly.isEmpty() && refOnly.isEmpty();
-    }
-
-    abstract static  class Visitor {
-        Tester tester;
-        File classesdir;
-
-        public Visitor(Tester tester) {
-            this.tester = tester;
-        }
-
-        abstract void visitClass(final String classname, final File  cfile,
-                final StringBuilder sb) throws Exception;
-
-        public void error(String msg) {
-            tester.error(msg);
-        }
-
-        public void warn(String msg) {
-            tester.warn(msg);
-        }
-    }
-
-    void error(String msg) {
-        System.err.println("Error: " + msg);
-        errors++;
-    }
-
-    void warn(String msg) {
-        System.err.println("Warning: " + msg);
-        warnings++;
-    }
-
-    void info(String msg) {
-        System.out.println(msg);
-    }
-}
--- a/langtools/test/tools/javac/MethodParameters/UncommonParamNames.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/MethodParameters/UncommonParamNames.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -26,9 +26,9 @@
  * @bug 8006582
  * @summary javac should generate method parameters correctly.
  * @modules jdk.jdeps/com.sun.tools.classfile
- * @build Tester
+ * @build MethodParametersTester
  * @compile -parameters UncommonParamNames.java
- * @run main Tester UncommonParamNames UncommonParamNames.out
+ * @run main MethodParametersTester UncommonParamNames UncommonParamNames.out
  */
 
 /** Test uncommon parameter names */
--- a/langtools/test/tools/javac/T6358024.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/T6358024.java	Fri Aug 19 12:17:32 2016 -0700
@@ -70,9 +70,9 @@
         JavacTool tool = JavacTool.create();
         List<String> flags = new ArrayList<String>();
         flags.addAll(Arrays.asList(
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"));
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"));
         for (Option opt: opts) {
             flags.add(opt.name);
             for (Object arg : opt.args)
--- a/langtools/test/tools/javac/T6358166.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/T6358166.java	Fri Aug 19 12:17:32 2016 -0700
@@ -56,10 +56,10 @@
         JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + self + ".java");
 
         List<String> addExports = Arrays.asList(
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
 
         test(fm, f, addExports, "-verbose", "-d", ".");
 
--- a/langtools/test/tools/javac/T6403466.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/T6403466.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -58,10 +58,10 @@
                 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
 
             Iterable<String> options = Arrays.asList(
-                "-XaddExports:"
-                    + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
+                "--add-exports",
+                    "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
                     + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
-                "-processorpath", testClassDir,
+                "--processor-path", testClassDir,
                 "-processor", self,
                 "-s", ".",
                 "-d", ".");
--- a/langtools/test/tools/javac/T6404756.out	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/T6404756.out	Fri Aug 19 12:17:32 2016 -0700
@@ -1,4 +1,5 @@
+T6404756.java:10:28: compiler.warn.deprecated.annotation.has.no.effect: kindname.variable
 T6404756.java:10:34: compiler.warn.has.been.deprecated: foo, Foo
 - compiler.err.warnings.and.werror
 1 error
-1 warning
+2 warnings
--- a/langtools/test/tools/javac/T6406771.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/T6406771.java	Fri Aug 19 12:17:32 2016 -0700
@@ -50,8 +50,8 @@
             JavaFileObject f = fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, self+".java"))).iterator().next();
 
             List<String> opts = Arrays.asList(
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
                 "-XDaccessInternalAPI",
                 "-d", ".",
                 "-processorpath", testClasses,
--- a/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/T8003967/DetectMutableStaticFields.java	Fri Aug 19 12:17:32 2016 -0700
@@ -116,6 +116,8 @@
                 "moduleFinderClass", "ofMethod");
         ignore("com/sun/tools/javac/util/JDK9Wrappers$ServiceLoaderHelper",
                 "loadMethod");
+        ignore("com/sun/tools/javac/util/JDK9Wrappers$VMHelper",
+                "vmClass", "getRuntimeArgumentsMethod");
     }
 
     private final List<String> errors = new ArrayList<>();
--- a/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -143,11 +143,11 @@
                     Arrays.asList(new File(System.getProperty("test.src"),
                     this.getClass().getName() + ".java")));
             java.util.List<String> options = Arrays.asList(
-                "-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                "--add-exports", "jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                 "-d", System.getProperty("user.dir")
             );
             JavacTask task = (JavacTask) c.getTask(null, fm, null, options, null, fos);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8160156/LetExpressionsAreUnnecessarilyGeneratedTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2016, 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 8160156
+ * @summary javac is generating let expressions unnecessarily
+ * @library /tools/lib
+ * @modules
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main LetExpressionsAreUnnecessarilyGeneratedTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class LetExpressionsAreUnnecessarilyGeneratedTest extends TestRunner {
+    ToolBox tb;
+
+    public static void main(String... args) throws Exception {
+        new LetExpressionsAreUnnecessarilyGeneratedTest().runTests();
+    }
+
+    public LetExpressionsAreUnnecessarilyGeneratedTest() {
+        super(System.err);
+        tb = new ToolBox();
+    }
+
+    protected void runTests() throws Exception {
+        runTests(m -> new Object[] { Paths.get(m.getName()) });
+    }
+
+    @Test
+    public void testDontGenerateLetExpr(Path testBase) throws Exception {
+        Path src = testBase.resolve("src");
+        tb.writeJavaFiles(src,
+                "package base;\n" +
+                "public abstract class Base {\n" +
+                "    protected int i = 1;\n" +
+                "}",
+
+                "package sub;\n" +
+                "import base.Base;\n" +
+                "public class Sub extends Base {\n" +
+                "    private int i = 4;\n" +
+                "    void m() {\n" +
+                "        new Runnable() {\n" +
+                "            public void run() {\n" +
+                "                Sub.super.i += 10;\n" +
+                "            }\n" +
+                "        };\n" +
+                "    }\n" +
+                "}");
+
+        Path out = testBase.resolve("out");
+        Files.createDirectories(out);
+        Path base = src.resolve("base");
+        Path sub = src.resolve("sub");
+
+        new JavacTask(tb)
+            .outdir(out)
+            .files(tb.findJavaFiles(base))
+            .run(Task.Expect.SUCCESS);
+
+        new JavacTask(tb)
+            .classpath(out)
+            .outdir(out)
+            .files(tb.findJavaFiles(sub))
+            .run(Task.Expect.SUCCESS);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/neg/DeprecatedAnnotationTest/DeprecatedAnnotationTest.out	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,8 @@
+package-info.java:10:9: compiler.warn.deprecated.annotation.has.no.effect: kindname.package
+- compiler.err.warnings.and.werror
+package-info.java:14:30: compiler.warn.deprecated.annotation.has.no.effect: kindname.variable
+package-info.java:16:25: compiler.warn.deprecated.annotation.has.no.effect: kindname.variable
+package-info.java:18:51: compiler.warn.deprecated.annotation.has.no.effect: kindname.variable
+package-info.java:20:40: compiler.warn.deprecated.annotation.has.no.effect: kindname.variable
+1 error
+5 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/neg/DeprecatedAnnotationTest/package-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8068626
+ * @summary Add javac lint warning when the Deprecated annotation is used where it is a no-op
+ *
+ * @compile/fail/ref=DeprecatedAnnotationTest.out -Werror -Xlint:deprecation -XDrawDiagnostics package-info.java
+ */
+
+@Deprecated
+package p;
+
+class DeprecatedAnnotationTest implements AutoCloseable {
+
+    void foo(@Deprecated int p) {
+
+        @Deprecated int l;
+
+        try (@Deprecated DeprecatedAnnotationTest r = new DeprecatedAnnotationTest()) {
+            // ...
+        } catch (@Deprecated Exception e) {
+
+        }
+    }
+
+    @Override
+    public void close() throws Exception {
+        @SuppressWarnings("deprecation")  // verify that we are able to suppress.
+        @Deprecated int x;
+    }
+}
--- a/langtools/test/tools/javac/api/T6358786.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/api/T6358786.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, 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
@@ -49,7 +49,7 @@
             String srcdir = System.getProperty("test.src");
             File file = new File(srcdir, args[0]);
             List<String> options = Arrays.asList(
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
             );
             JavacTaskImpl task = (JavacTaskImpl)tool.getTask(null, fm, null, options, null, fm.getJavaFileObjectsFromFiles(Arrays.asList(file)));
             Elements elements = task.getElements();
--- a/langtools/test/tools/javac/api/T6412669.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/api/T6412669.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, 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
@@ -54,7 +54,7 @@
             String[] opts = {
                 "-proc:only",
                 "-processor", T6412669.class.getName(),
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
             };
             StringWriter sw = new StringWriter();
             JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files);
--- a/langtools/test/tools/javac/api/TestClientCodeWrapper.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/api/TestClientCodeWrapper.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, 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
@@ -133,7 +133,7 @@
         PrintWriter pw = new PrintWriter(sw);
 
         List<String> javacOptions = Arrays.asList(
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
                 "-extdirs", extDirs.getPath(), // for use by filemanager handleOption
                 "-processor", TestClientCodeWrapper.class.getName()
                 );
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Fri Aug 19 12:17:32 2016 -0700
@@ -74,10 +74,10 @@
             fm.getJavaFileObjects(new File[] {file});
         StandardJavaFileManager fm = getLocalFileManager(tool, null, null);
         java.util.List<String> options = Arrays.asList(
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
         task = (JavacTaskImpl)tool.getTask(null, fm, null, options, null, compilationUnits);
         task.getContext().put(ScannerFactory.scannerFactoryKey,
                 new MyScanner.Factory(task.getContext(), this));
--- a/langtools/test/tools/javac/api/TestTrees.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/api/TestTrees.java	Fri Aug 19 12:17:32 2016 -0700
@@ -79,8 +79,7 @@
                 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrcDir, self + ".java")));
 
             Iterable<String> opts = Arrays.asList(
-                "-XaddExports:"
-                + "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
                 "-d", ".",
                 "-XDcompilePolicy=simple");
 
@@ -91,8 +90,7 @@
                 throw new AssertionError("compilation failed");
 
             opts =  Arrays.asList(
-                "-XaddExports:"
-                + "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
                 "-XDaccessInternalAPI",
                 "-d", ".",
                 "-processorpath", testClassDir,
--- a/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Fri Aug 19 12:17:32 2016 -0700
@@ -35,6 +35,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -127,8 +128,9 @@
         tr.checkContains(actualProvides, moduleDescriptor.provides, "Lists of provides don't match");
     }
 
-    protected void compile(Path base) throws IOException {
+    protected void compile(Path base, String... options) throws IOException {
         new JavacTask(tb)
+                .options(options)
                 .files(findJavaFiles(base))
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
--- a/langtools/test/tools/javac/diags/Example.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/Example.java	Fri Aug 19 12:17:32 2016 -0700
@@ -223,7 +223,7 @@
             // source for import statements or a magic comment
             for (File pf: procFiles) {
                 if (pf.getName().equals("CreateBadClassFile.java")) {
-                    pOpts.add("-XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED");
+                    pOpts.add("--add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED");
                 }
             }
 
@@ -248,7 +248,7 @@
         }
 
         if (moduleSourcePathDir != null) {
-            opts.add("-modulesourcepath");
+            opts.add("--module-source-path");
             opts.add(moduleSourcePathDir.getPath());
             files = moduleSourcePathFiles;
         }
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Fri Aug 19 12:17:32 2016 -0700
@@ -122,6 +122,7 @@
 compiler.err.locn.cant.read.file                              # bad class file
 compiler.misc.module.info.invalid.super.class                 # bad class file
 compiler.err.locn.cant.read.directory                         # file system issue
+compiler.err.locn.invalid.arg.for.xpatch                      # command line option error
 compiler.misc.unnamed.module                                  # fragment uninteresting in and of itself
 compiler.misc.kindname.module                                 # fragment uninteresting in and of itself
 compiler.misc.locn.module_path                                # fragment uninteresting in and of itself
--- a/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/AddmodsAllModulePathInvalid/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -22,5 +22,5 @@
  */
 
 // key: compiler.err.addmods.all.module.path.invalid
-// options: -addmods ALL-MODULE-PATH
+// options: --add-modules ALL-MODULE-PATH
 module m {}
--- a/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java	Fri Aug 19 12:17:32 2016 -0700
@@ -24,7 +24,7 @@
 // key: compiler.err.cant.find.module
 // key: compiler.err.doesnt.exist
 
-// options: -XaddExports:undef/undef=ALL-UNNAMED
+// options: --add-exports undef/undef=ALL-UNNAMED
 
 import undef.Any;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/DeprecatedAnnotationHasNoEffect/DeprecatedAnnotationHasNoEffect.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, 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.
+ */
+
+// options: -Xlint:deprecation
+// key: compiler.warn.deprecated.annotation.has.no.effect
+
+class DeprecatedAnnotationHasNoEffect {
+    void foo(@Deprecated int p) {}
+}
--- a/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/IllegalArgumentForOption/IllegalArgumentForOption.java	Fri Aug 19 12:17:32 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.err.illegal.argument.for.option
-// options: -modulepath doesNotExist
+// options: --module-path doesNotExist
 // run: simple
 
 class X {}
--- a/langtools/test/tools/javac/diags/examples/InvalidArgForXPatch/InvalidArgForXpatch.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2016, 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.
- */
-
-// key: compiler.err.locn.invalid.arg.for.xpatch
-// options: -Xpatch:blah
-
-class InvalidArgForXpatch {}
--- a/langtools/test/tools/javac/diags/examples/InvalidDefaultInterface/InvalidDefaultInterface.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/InvalidDefaultInterface/InvalidDefaultInterface.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,7 +25,7 @@
 // key: compiler.misc.bad.class.file.header
 // key: compiler.err.cant.access
 // options: -processor CreateBadClassFile
-// run: exec -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
+// run: exec --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
 
 /* The annotation processor will create an invalid classfile with version 51.0
  * and a non-abstract method in an interface. Loading the classfile will produce
--- a/langtools/test/tools/javac/diags/examples/InvalidStaticInterface/InvalidStaticInterface.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/InvalidStaticInterface/InvalidStaticInterface.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,7 +25,7 @@
 // key: compiler.misc.bad.class.file.header
 // key: compiler.err.cant.access
 // options: -processor CreateBadClassFile
-// run: exec -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
+// run: exec --add-exports jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED
 
 /* The annotation processor will create an invalid classfile with version 51.0
  * and a static method in an interface. Loading the classfile will produce
--- a/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java	Fri Aug 19 12:17:32 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.err.xaddexports.malformed.entry
-// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util
+// options: --add-exports jdk.compiler/com.sun.tools.javac.util
 
 public class XaddexportsMalformedEntry {
 }
--- a/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java	Fri Aug 19 12:17:32 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.err.xaddexports.too.many
-// options: -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED  -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
+// options: --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED  --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
 
 public class XaddexportsTooMany {
 }
--- a/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java	Fri Aug 19 12:17:32 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.err.xaddreads.malformed.entry
-// options: -XaddReads:jdk.compiler
+// options: --add-reads jdk.compiler
 
 public class XaddreadsMalformedEntry {
 }
--- a/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java	Fri Aug 19 12:17:32 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.err.xaddreads.too.many
-// options: -XaddReads:jdk.compiler=ALL-UNNAMED  -XaddReads:jdk.compiler=ALL-UNNAMED
+// options: --add-reads jdk.compiler=ALL-UNNAMED  --add-reads jdk.compiler=ALL-UNNAMED
 
 public class XaddreadsTooMany {
 }
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -88,7 +88,7 @@
                 .run();
 
         // ideally we'd have a better message for this case
-        String[] mpOpts = { "-system", "none", "-modulepath", "modules" };
+        String[] mpOpts = { "--system", "none", "--module-path", "modules" };
         test(mpOpts, compilerErrorMessage);
     }
 
--- a/langtools/test/tools/javac/file/T7018098.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/file/T7018098.java	Fri Aug 19 12:17:32 2016 -0700
@@ -60,9 +60,9 @@
         _assert(!testDir.exists());
 
         compile(
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
             "-XDaccessInternalAPI",
             "-proc:only",
             "-processor", myName,
@@ -73,9 +73,9 @@
         _assert(testDir.exists());
 
         compile(
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
             "-XDaccessInternalAPI",
             "-proc:only",
             "-processor", myName,
--- a/langtools/test/tools/javac/modules/AddLimitMods.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @summary Test -addmods and -limitmods; also test the "enabled" modules.
+ * @summary Test --add-modules and --limit-modules; also test the "enabled" modules.
  * @library /tools/lib
  * @modules
  *      jdk.compiler/com.sun.tools.javac.api
@@ -103,14 +103,14 @@
         Files.createDirectories(modulePath);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(modulePath)
                 .files(findJavaFiles(m3))
                 .run()
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(modulePath)
                 .files(findJavaFiles(m2))
                 .run()
@@ -118,57 +118,57 @@
 
         //real test
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
+                .options("--module-path", modulePath.toString(),
                          "-Xshouldstop:ifNoError=FLOW",
-                         "-limitmods", "java.base")
+                         "--limit-modules", "java.base")
                 .outdir(modulePath)
                 .files(findJavaFiles(m1))
                 .run(Task.Expect.FAIL)
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
+                .options("--module-path", modulePath.toString(),
                          "-Xshouldstop:ifNoError=FLOW",
-                         "-limitmods", "java.base",
-                         "-addmods", "m2")
+                         "--limit-modules", "java.base",
+                         "--add-modules", "m2")
                 .outdir(modulePath)
                 .files(findJavaFiles(m1))
                 .run(Task.Expect.FAIL)
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
+                .options("--module-path", modulePath.toString(),
                          "-Xshouldstop:ifNoError=FLOW",
-                         "-limitmods", "java.base",
-                         "-addmods", "m2,m3")
+                         "--limit-modules", "java.base",
+                         "--add-modules", "m2,m3")
                 .outdir(modulePath)
                 .files(findJavaFiles(m1))
                 .run()
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
+                .options("--module-path", modulePath.toString(),
                          "-Xshouldstop:ifNoError=FLOW",
-                         "-limitmods", "m2")
+                         "--limit-modules", "m2")
                 .outdir(modulePath)
                 .files(findJavaFiles(m1))
                 .run()
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
+                .options("--module-path", modulePath.toString(),
                          "-Xshouldstop:ifNoError=FLOW",
-                         "-limitmods", "m3")
+                         "--limit-modules", "m3")
                 .outdir(modulePath)
                 .files(findJavaFiles(m1))
                 .run(Task.Expect.FAIL)
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
+                .options("--module-path", modulePath.toString(),
                          "-Xshouldstop:ifNoError=FLOW",
-                         "-limitmods", "m3",
-                         "-addmods", "m2")
+                         "--limit-modules", "m3",
+                         "--add-modules", "m2")
                 .outdir(modulePath)
                 .files(findJavaFiles(m1))
                 .run()
@@ -219,11 +219,11 @@
                                               "Test.java:2:18: compiler.err.doesnt.exist: javax.annotation\n"
                                             + "Test.java:5:19: compiler.err.doesnt.exist: javax.xml.bind\n"
                                             + "2 errors\n"),
-            new SimpleEntry<String[], String>(new String[] {"-addmods", "java.annotations.common,java.xml.bind"},
+            new SimpleEntry<String[], String>(new String[] {"--add-modules", "java.annotations.common,java.xml.bind"},
                                               null),
-            new SimpleEntry<String[], String>(new String[] {"-limitmods", "java.xml.ws,jdk.compiler"},
+            new SimpleEntry<String[], String>(new String[] {"--limit-modules", "java.xml.ws,jdk.compiler"},
                                               null),
-            new SimpleEntry<String[], String>(new String[] {"-addmods", "ALL-SYSTEM"},
+            new SimpleEntry<String[], String>(new String[] {"--add-modules", "ALL-SYSTEM"},
                                               null)
     );
 
@@ -244,7 +244,7 @@
         Files.createDirectories(modulePath);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(modulePath)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -258,15 +258,15 @@
         Files.createDirectories(cpOut);
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString())
+                .options("--module-path", modulePath.toString())
                 .outdir(cpOut)
                 .files(findJavaFiles(cpSrc))
                 .run(Task.Expect.FAIL)
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
-                         "-addmods", "ALL-MODULE-PATH")
+                .options("--module-path", modulePath.toString(),
+                         "--add-modules", "ALL-MODULE-PATH")
                 .outdir(cpOut)
                 .files(findJavaFiles(cpSrc))
                 .run()
@@ -278,9 +278,9 @@
                 "1 error");
 
         actual = new JavacTask(tb)
-                   .options("-modulesourcepath", moduleSrc.toString(),
+                   .options("--module-source-path", moduleSrc.toString(),
                             "-XDrawDiagnostics",
-                            "-addmods", "ALL-MODULE-PATH")
+                            "--add-modules", "ALL-MODULE-PATH")
                    .outdir(modulePath)
                    .files(findJavaFiles(moduleSrc))
                    .run(Task.Expect.FAIL)
@@ -294,7 +294,7 @@
         actual = new JavacTask(tb)
                    .options("-Xmodule:java.base",
                             "-XDrawDiagnostics",
-                            "-addmods", "ALL-MODULE-PATH")
+                            "--add-modules", "ALL-MODULE-PATH")
                    .outdir(cpOut)
                    .files(findJavaFiles(cpSrc))
                    .run(Task.Expect.FAIL)
@@ -308,14 +308,14 @@
         actual = new JavacTask(tb, Task.Mode.CMDLINE)
                    .options("-source", "8", "-target", "8",
                             "-XDrawDiagnostics",
-                            "-addmods", "ALL-MODULE-PATH")
+                            "--add-modules", "ALL-MODULE-PATH")
                    .outdir(cpOut)
                    .files(findJavaFiles(cpSrc))
                    .run(Task.Expect.FAIL)
                    .writeAll()
                    .getOutputLines(Task.OutputKind.DIRECT);
 
-        if (!actual.contains("javac: option -addmods not allowed with target 1.8")) {
+        if (!actual.contains("javac: option --add-modules not allowed with target 1.8")) {
             throw new IllegalStateException("incorrect errors; actual=" + actual);
         }
 
@@ -323,7 +323,7 @@
 
         actual = new JavacTask(tb)
                    .options("-XDrawDiagnostics",
-                            "-addmods", "ALL-MODULE-PATH")
+                            "--add-modules", "ALL-MODULE-PATH")
                    .outdir(cpOut)
                    .files(findJavaFiles(cpSrc))
                    .run(Task.Expect.FAIL)
@@ -386,7 +386,7 @@
                           "package api; public class Api { public void test() { } }");
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(modulePath)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -428,7 +428,7 @@
                 tb.writeJavaFiles(m2Runtime, moduleInfo, testClassNamed.toString());
 
                 new JavacTask(tb)
-                   .options("-modulepath", modulePath.toString())
+                   .options("--module-path", modulePath.toString())
                    .outdir(out)
                    .files(findJavaFiles(m2Runtime))
                    .run()
@@ -441,9 +441,9 @@
                     output = new JavaTask(tb)
                        .vmOptions(augmentOptions(options,
                                                  Collections.emptyList(),
-                                                 "-modulepath", modulePath.toString() + File.pathSeparator + out.getParent().toString(),
-                                                 "-classpath", classpathOut.toString(),
-                                                 "-XaddReads:m2=ALL-UNNAMED,automatic",
+                                                 "--module-path", modulePath.toString() + File.pathSeparator + out.getParent().toString(),
+                                                 "--class-path", classpathOut.toString(),
+                                                 "--add-reads", "m2=ALL-UNNAMED,automatic",
                                                  "-m", "m2/test.Test"))
                        .run()
                        .writeAll()
@@ -463,7 +463,7 @@
                                   "public class Test {}\n");
 
                 List<String> auxOptions = success ? Arrays.asList(
-                    "-processorpath", System.getProperty("test.class.path"),
+                    "--processor-path", System.getProperty("test.class.path"),
                     "-processor", CheckVisibleModule.class.getName(),
                     "-Aoutput=" + output,
                     "-XDaccessInternalAPI=true"
@@ -471,8 +471,8 @@
                 new JavacTask(tb)
                    .options(augmentOptions(options,
                                            auxOptions,
-                                           "-modulepath", modulePath.toString(),
-                                           "-classpath", classpathOut.toString(),
+                                           "--module-path", modulePath.toString(),
+                                           "--class-path", classpathOut.toString(),
                                            "-Xshouldstop:ifNoError=FLOW"))
                    .outdir(modulePath)
                    .files(findJavaFiles(m2))
@@ -578,14 +578,14 @@
     };
 
     private static final String[][] OPTIONS_VARIANTS = {
-        {"-addmods", "automatic"},
-        {"-addmods", "m1,automatic"},
-        {"-addmods", "jdk.compiler,automatic"},
-        {"-addmods", "m1,jdk.compiler,automatic"},
-        {"-addmods", "ALL-SYSTEM,automatic"},
-        {"-limitmods", "java.base", "-addmods", "automatic"},
-        {"-limitmods", "java.base", "-addmods", "ALL-SYSTEM,automatic"},
-        {"-limitmods", "m2", "-addmods", "automatic"},
-        {"-limitmods", "jdk.compiler", "-addmods", "automatic"},
+        {"--add-modules", "automatic"},
+        {"--add-modules", "m1,automatic"},
+        {"--add-modules", "jdk.compiler,automatic"},
+        {"--add-modules", "m1,jdk.compiler,automatic"},
+        {"--add-modules", "ALL-SYSTEM,automatic"},
+        {"--limit-modules", "java.base", "--add-modules", "automatic"},
+        {"--limit-modules", "java.base", "--add-modules", "ALL-SYSTEM,automatic"},
+        {"--limit-modules", "m2", "--add-modules", "automatic"},
+        {"--limit-modules", "jdk.compiler", "--add-modules", "automatic"},
     };
 }
--- a/langtools/test/tools/javac/modules/AddReadsTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/AddReadsTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary Test the -XaddReads option
+ * @summary Test the --add-reads option
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -73,7 +73,7 @@
 
         String log = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                         "-modulesourcepath", src.toString())
+                         "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -85,8 +85,8 @@
 
         //test add dependencies:
         new JavacTask(tb)
-                .options("-XaddReads:m2=m1",
-                         "-modulesourcepath", src.toString(),
+                .options("--add-reads", "m2=m1",
+                         "--module-source-path", src.toString(),
                          "-processor", VerifyRequires.class.getName())
                 .outdir(classes)
                 .files(findJavaFiles(src))
@@ -104,8 +104,8 @@
 
         //cyclic dependencies OK when created through addReads:
         new JavacTask(tb)
-                .options("-XaddReads:m2=m1,m1=m2",
-                         "-modulesourcepath", src.toString())
+                .options("--add-reads", "m2=m1,m1=m2",
+                         "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run()
@@ -115,8 +115,8 @@
                           "module m2 { requires m1; }");
 
         new JavacTask(tb)
-                .options("-XaddReads:m1=m2",
-                         "-modulesourcepath", src.toString())
+                .options("--add-reads", "m1=m2",
+                         "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run()
@@ -165,8 +165,8 @@
                           "package impl; public class Impl { api.Api api; }");
 
         new JavacTask(tb)
-          .options("-classpath", jar.toString(),
-                   "-XaddReads:m1=ALL-UNNAMED",
+          .options("--class-path", jar.toString(),
+                   "--add-reads", "m1=ALL-UNNAMED",
                    "-XDrawDiagnostics")
           .outdir(classes)
           .files(findJavaFiles(moduleSrc))
@@ -191,9 +191,9 @@
                           "package impl; public class Impl { { api.Api.test(); } }");
 
         new JavacTask(tb)
-          .options("-classpath", jar.toString(),
-                   "-modulesourcepath", moduleSrc.toString(),
-                   "-XaddReads:m1=ALL-UNNAMED",
+          .options("--class-path", jar.toString(),
+                   "--module-source-path", moduleSrc.toString(),
+                   "--add-reads", "m1=ALL-UNNAMED",
                    "-XDrawDiagnostics")
           .outdir(classes)
           .files(m1.resolve("impl").resolve("Impl.java"))
@@ -213,8 +213,8 @@
                           "package impl; public class Impl { api.Api a; }");
 
         new JavacTask(tb)
-          .options("-classpath", jar.toString(),
-                   "-XaddReads:java.base=ALL-UNNAMED",
+          .options("--class-path", jar.toString(),
+                   "--add-reads", "java.base=ALL-UNNAMED",
                    "-Xmodule:java.base")
           .outdir(classes)
           .files(src.resolve("impl").resolve("Impl.java"))
@@ -233,7 +233,7 @@
                           "package impl; public class Impl { javax.swing.JButton b; }");
 
         new JavacTask(tb)
-          .options("-XaddReads:java.base=java.desktop",
+          .options("--add-reads", "java.base=java.desktop",
                    "-Xmodule:java.base")
           .outdir(classes)
           .files(findJavaFiles(src))
@@ -285,7 +285,7 @@
         tb.createDirectories(classes);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", src.toString())
+                .options("--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run()
@@ -300,9 +300,9 @@
                           "package impl; public class Impl { }");
 
         new JavacTask(tb)
-          .options("-XaddReads:m1=ALL-UNNAMED",
+          .options("--add-reads", "m1=ALL-UNNAMED",
                    "-Xmodule:m1",
-                   "-modulepath", classes.toString())
+                   "--module-path", classes.toString())
           .outdir(unnamedClasses)
           .files(findJavaFiles(unnamedSrc))
           .run()
--- a/langtools/test/tools/javac/modules/AnnotationProcessing.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/AnnotationProcessing.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,6 +23,7 @@
 
 /**
  * @test
+ * @bug 8133884 8162711
  * @summary Verify that annotation processing works.
  * @library /tools/lib
  * @modules
@@ -43,6 +44,7 @@
 import java.util.stream.Collectors;
 
 import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
 import javax.annotation.processing.RoundEnvironment;
 import javax.annotation.processing.SupportedAnnotationTypes;
 import javax.annotation.processing.SupportedOptions;
@@ -53,13 +55,15 @@
 import javax.lang.model.element.ModuleElement.UsesDirective;
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeKind;
 import javax.lang.model.util.ElementFilter;
 import javax.lang.model.util.ElementScanner9;
+import javax.tools.Diagnostic.Kind;
 
 import toolbox.JavacTask;
 import toolbox.Task;
-import toolbox.ToolBox;
+import toolbox.Task.Mode;
 
 public class AnnotationProcessing extends ModuleTestBase {
 
@@ -81,7 +85,7 @@
                           "package impl; public class Impl { }");
 
         String log = new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString(),
+                .options("--module-source-path", moduleSrc.toString(),
                          "-processor", AP.class.getName(),
                          "-AexpectedEnclosedElements=m1=>impl")
                 .outdir(classes)
@@ -113,7 +117,7 @@
                           "package impl2; public class Impl2 { }");
 
         String log = new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString(),
+                .options("--module-source-path", moduleSrc.toString(),
                          "-processor", AP.class.getName(),
                          "-AexpectedEnclosedElements=m1=>impl1,m2=>impl2")
                 .outdir(classes)
@@ -300,6 +304,76 @@
 
     }
 
+    @Test
+    public void testQualifiedClassForProcessing(Path base) throws Exception {
+        Path moduleSrc = base.resolve("module-src");
+        Path m1 = moduleSrc.resolve("m1");
+        Path m2 = moduleSrc.resolve("m2");
+
+        Path classes = base.resolve("classes");
+
+        Files.createDirectories(classes);
+
+        tb.writeJavaFiles(m1,
+                          "module m1 { }",
+                          "package impl; public class Impl { int m1; }");
+
+        tb.writeJavaFiles(m2,
+                          "module m2 { }",
+                          "package impl; public class Impl { int m2; }");
+
+        new JavacTask(tb)
+            .options("--module-source-path", moduleSrc.toString())
+            .outdir(classes)
+            .files(findJavaFiles(moduleSrc))
+            .run()
+            .writeAll()
+            .getOutput(Task.OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList("Note: field: m1");
+
+        for (Mode mode : new Mode[] {Mode.API, Mode.CMDLINE}) {
+            List<String> log = new JavacTask(tb, mode)
+                    .options("-processor", QualifiedClassForProcessing.class.getName(),
+                             "--module-path", classes.toString())
+                    .classes("m1/impl.Impl")
+                    .outdir(classes)
+                    .run()
+                    .writeAll()
+                    .getOutputLines(Task.OutputKind.DIRECT);
+
+            if (!expected.equals(log))
+                throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    @SupportedAnnotationTypes("*")
+    public static final class QualifiedClassForProcessing extends AbstractProcessor {
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (processingEnv.getElementUtils().getModuleElement("m1") == null) {
+                throw new AssertionError("No m1 module found.");
+            }
+
+            Messager messager = processingEnv.getMessager();
+
+            for (TypeElement clazz : ElementFilter.typesIn(roundEnv.getRootElements())) {
+                for (VariableElement field : ElementFilter.fieldsIn(clazz.getEnclosedElements())) {
+                    messager.printMessage(Kind.NOTE, "field: " + field.getSimpleName());
+                }
+            }
+
+            return false;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+
+    }
+
     private static void assertNonNull(String msg, Object val) {
         if (val == null) {
             throw new AssertionError(msg);
--- a/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/AnnotationProcessorsInModulesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -136,7 +136,7 @@
                 annotationProcessor2);
 
         String log = new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(processorCompiledModules)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -159,7 +159,7 @@
     public void testUseOnlyOneProcessor(Path base) throws Exception {
         initialization(base);
         String log = new JavacTask(tb)
-                .options("-processormodulepath", processorCompiledModules.toString(),
+                .options("--processor-module-path", processorCompiledModules.toString(),
                         "-processor", "mypkg2.MyProcessor2")
                 .outdir(classes)
                 .sources(testClass)
@@ -175,7 +175,7 @@
     public void testAnnotationProcessorExecutionOrder(Path base) throws Exception {
         initialization(base);
         List<String> log = new JavacTask(tb)
-                .options("-processormodulepath", processorCompiledModules.toString(),
+                .options("--processor-module-path", processorCompiledModules.toString(),
                         "-processor", "mypkg1.MyProcessor1,mypkg2.MyProcessor2")
                 .outdir(classes)
                 .sources(testClass)
@@ -188,7 +188,7 @@
         }
 
         log = new JavacTask(tb)
-                .options("-processormodulepath", processorCompiledModules.toString(),
+                .options("--processor-module-path", processorCompiledModules.toString(),
                         "-processor", "mypkg2.MyProcessor2,mypkg1.MyProcessor1")
                 .outdir(classes)
                 .sources(testClass)
@@ -205,7 +205,8 @@
     public void testErrorOutputIfOneProcessorNameIsIncorrect(Path base) throws Exception {
         initialization(base);
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(),
+                .options("-XDrawDiagnostics",
+                         "--processor-module-path", processorCompiledModules.toString(),
                          "-processor", "mypkg2.MyProcessor2,noPackage.noProcessor,mypkg1.MyProcessor1")
                 .outdir(classes)
                 .sources(testClass)
@@ -221,8 +222,9 @@
     public void testOptionsExclusion(Path base) throws Exception {
         initialization(base);
         List<String> log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-processormodulepath", processorCompiledModules.toString(),
-                        "-processorpath", processorCompiledModules.toString())
+                .options("-XDrawDiagnostics",
+                        "--processor-module-path", processorCompiledModules.toString(),
+                        "--processor-path", processorCompiledModules.toString())
                 .outdir(classes)
                 .sources(testClass)
                 .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/AutomaticModules.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/AutomaticModules.java	Fri Aug 19 12:17:32 2016 -0700
@@ -93,7 +93,7 @@
                           "package impl; public class Impl { public void e(api.Api api) { api.actionPerformed(null); } }");
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString())
+                .options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString())
                 .outdir(classes)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -151,7 +151,7 @@
                           "package impl; public class Impl { public void e(api.Api api) { api.run(\"\"); } }");
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString(), "-modulepath", modulePath.toString(), "-classpath", baseJar.toString())
+                .options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString(), "--class-path", baseJar.toString())
                 .outdir(classes)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -197,7 +197,7 @@
                           "package dep; public class Dep { api.Api api; }");
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString())
+                .options("--module-path", modulePath.toString())
                 .outdir(depClasses)
                 .files(findJavaFiles(depSrc))
                 .run()
@@ -221,7 +221,7 @@
                           "package test; public class Test { }");
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString())
+                .options("--module-path", modulePath.toString())
                 .outdir(testClasses)
                 .files(findJavaFiles(testSrc))
                 .run()
@@ -273,9 +273,9 @@
         Files.createDirectories(classes);
 
         List<String> log = new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString(),
-                         "-modulepath", modulePath.toString(),
-                         "-addmods", "automaticB",
+                .options("--module-source-path", moduleSrc.toString(),
+                         "--module-path", modulePath.toString(),
+                         "--add-modules", "automaticB",
                          "-XDrawDiagnostics")
                 .outdir(classes)
                 .files(findJavaFiles(moduleSrc))
@@ -291,8 +291,8 @@
         }
 
         log = new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString(),
-                         "-modulepath", modulePath.toString(),
+                .options("--module-source-path", moduleSrc.toString(),
+                         "--module-path", modulePath.toString(),
                          "-XDrawDiagnostics")
                 .outdir(classes)
                 .files(findJavaFiles(moduleSrc))
--- a/langtools/test/tools/javac/modules/DoclintOtherModules.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/DoclintOtherModules.java	Fri Aug 19 12:17:32 2016 -0700
@@ -61,7 +61,7 @@
         Files.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString(), "-Xlint:deprecation", "-Xdoclint:-reference", "-Werror")
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString(), "-Xlint:deprecation", "-Xdoclint:-reference", "-Werror")
                 .outdir(classes)
                 .files(findJavaFiles(m1))
                 .run(Task.Expect.SUCCESS)
--- a/langtools/test/tools/javac/modules/DuplicateClassTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/DuplicateClassTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -60,7 +60,7 @@
         Files.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-modulesourcepath", base.toString())
+                .options("--module-source-path", base.toString())
                 .outdir(classes)
                 .files(findJavaFiles(base))
                 .run()
--- a/langtools/test/tools/javac/modules/EdgeCases.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/EdgeCases.java	Fri Aug 19 12:17:32 2016 -0700
@@ -73,7 +73,7 @@
         tb.createDirectories(classes);
 
         List<String> log = new JavacTask(tb)
-                .options("-XaddExports:undef/undef=ALL-UNNAMED", "-XDrawDiagnostics")
+                .options("--add-exports", "undef/undef=ALL-UNNAMED", "-XDrawDiagnostics")
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -167,7 +167,7 @@
 
         String log = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                         "-modulesourcepath", src.toString())
+                         "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -222,16 +222,16 @@
         tb.createDirectories(classes);
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
-                         "-modulesourcepath", src.toString())
+                .options("--module-path", modulePath.toString(),
+                         "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src_m2))
                 .run()
                 .writeAll();
 
         new JavacTask(tb)
-                .options("-modulepath", modulePath.toString(),
-                         "-modulesourcepath", src.toString())
+                .options("--module-path", modulePath.toString(),
+                         "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src_m3))
                 .run()
@@ -250,7 +250,7 @@
         tb.createDirectories(classes);
 
         new JavacTask(tb)
-                .options("-sourcepath", src_m1.toString(),
+                .options("--source-path", src_m1.toString(),
                          "-XDrawDiagnostics")
                 .outdir(classes)
                 .files(findJavaFiles(src_m1.resolve("test")))
@@ -261,7 +261,7 @@
                           "module m1 {}");
 
         new JavacTask(tb)
-                .options("-sourcepath", src_m1.toString())
+                .options("--source-path", src_m1.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src_m1.resolve("test")))
                 .run()
@@ -286,7 +286,7 @@
         tb.createDirectories(classes);
 
         List<String> log = new JavacTask(tb)
-                .options("-modulesourcepath", src.toString(),
+                .options("--module-source-path", src.toString(),
                          "-XDrawDiagnostics")
                 .outdir(classes)
                 .files(findJavaFiles(src))
--- a/langtools/test/tools/javac/modules/EnvVarTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/EnvVarTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -63,7 +63,7 @@
 
         tb.out.println("test that addExports can be given to javac");
         new JavacTask(tb)
-                .options("-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
+                .options("--add-exports", "jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Expect.SUCCESS)
@@ -71,7 +71,7 @@
 
         tb.out.println("test that addExports can be provided with env variable");
         new JavacTask(tb, Mode.EXEC)
-                .envVar("_JAVAC_OPTIONS", "-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
+                .envVar("_JAVAC_OPTIONS", "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED")
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Expect.SUCCESS)
@@ -80,7 +80,7 @@
         tb.out.println("test that addExports can be provided with env variable using @file");
         Path atFile = src.resolve("at-file.txt");
         tb.writeFile(atFile,
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED");
+                "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED");
 
         new JavacTask(tb, Mode.EXEC)
                 .envVar("_JAVAC_OPTIONS", "@" + atFile)
--- a/langtools/test/tools/javac/modules/GraphsTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/GraphsTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -117,7 +117,7 @@
                 .write(base.resolve("positiveSrc"));
 
         new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules)
+                .options("-XDrawDiagnostics", "-p", modules + File.pathSeparator + jarModules)
                 .outdir(Files.createDirectories(base.resolve("positive")))
                 .files(findJavaFiles(positiveSrc))
                 .run()
@@ -126,7 +126,7 @@
         Path negativeSrc = m.classes("package p; public class Negative { closedO.O o; closedN.N n; closedL.L l; }")
                 .write(base.resolve("negativeSrc"));
         List<String> log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-mp", modules + File.pathSeparator + jarModules)
+                .options("-XDrawDiagnostics", "-p", modules + File.pathSeparator + jarModules)
                 .outdir(Files.createDirectories(base.resolve("negative")))
                 .files(findJavaFiles(negativeSrc))
                 .run(Task.Expect.FAIL)
@@ -144,8 +144,8 @@
         m.write(modSrc);
         List<String> out = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", modSrc.toString(),
-                        "-mp", jarModules.toString()
+                        "--module-source-path", modSrc.toString(),
+                        "-p", jarModules.toString()
                 )
                 .outdir(Files.createDirectories(base.resolve("negative")))
                 .files(findJavaFiles(modSrc))
--- a/langtools/test/tools/javac/modules/HelloWorldTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/HelloWorldTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -76,7 +76,7 @@
         new JavacTask(tb)
             .options("-source", "8",
                 "-target", "8",
-                "-bootclasspath", smallRtJar.toString())
+                "--boot-class-path", smallRtJar.toString())
             .outdir(classes)
             .files(src.resolve("HelloWorld.java"))
             .run();
@@ -131,7 +131,7 @@
         Files.createDirectories(classes);
 
         new JavacTask(tb)
-            .options("-modulesourcepath", src.toString())
+            .options("--module-source-path", src.toString())
             .outdir(classes)
             .files(src_m1.resolve("p/HelloWorld.java"))
             .run()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/InheritRuntimeEnvironmentTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,421 @@
+/*
+ * Copyright (c) 2015, 2016, 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 8156998
+ * @summary Test --inherit-runtime-environment
+ * @library /tools/lib
+ * @modules
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavaTask ModuleTestBase
+ * @run main InheritRuntimeEnvironmentTest
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import toolbox.ModuleBuilder;
+import toolbox.JavaTask;
+import toolbox.JavacTask;
+import toolbox.Task;
+
+/**
+ * Tests that javac picks up runtime options with --inherit-runtime-environment.
+ * For each option, javac is first run using the option directly, as a control.
+ * javac is then run again, with the same option(s) being passed to the runtime,
+ * and --inherit-runtime-environment being used by javac.
+ * @author jjg
+ */
+public class InheritRuntimeEnvironmentTest extends ModuleTestBase {
+    public static void main(String... args) throws Exception {
+        InheritRuntimeEnvironmentTest t = new InheritRuntimeEnvironmentTest();
+        t.runTests();
+    }
+
+    /**
+     * Tests that code being compiled can access JDK-internal API using -add-exports.
+     * @param base
+     * @throws Exception
+     */
+    @Test
+    public void testAddExports(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "class C { com.sun.tools.javac.main.Main main; }");
+
+        new TestCase(base)
+                .testOpts("--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED")
+                .files(findJavaFiles(src))
+                .run();
+    }
+
+    /**
+     * Tests that code in the unnamed module can access a module on the module path using --add-modules.
+     */
+    @Test
+    public void testAddModules(Path base) throws Exception {
+        Path modules = base.resolve("modules");
+        new ModuleBuilder(tb, "m1")
+                .exports("pkg1")
+                .classes("package pkg1; public class C1 { }")
+                .build(modules);
+
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "class C { pkg1.C1 c1; }");
+
+        new TestCase(base)
+                .testOpts("--module-path", modules.toString(), "--add-modules", "m1")
+                .files(findJavaFiles(src))
+                .run();
+    }
+
+    /**
+     * Tests that a module on the module path is not visible when --limit-modules is used to
+     * restrict the set of observable modules.
+     */
+    @Test
+    public void testLimitModules(Path base) throws Exception {
+        Path modules = base.resolve("modules");
+        new ModuleBuilder(tb, "m1")
+                .exports("pkg1")
+                .classes("package pkg1; public class C1 { }")
+                .build(modules);
+
+        Path src = base.resolve("src");
+        new ModuleBuilder(tb, "m2")
+                .requires("m1")
+                .classes("package pkg2; public class C2 { pkg1.C1 c1; }")
+                .write(src);
+
+        // This is the control, to verify that by default, the module being compiled will
+        // be able to read modules on the module path
+        new TestCase(base)
+                .testOpts("--module-path", modules.toString())
+                .otherOpts("--module-source-path", src.toString())
+                .files(findJavaFiles(src))
+                .run();
+
+        // This is the test, to verify that the module being compiled will not be able to read
+        // modules on the module path when a --limit-modules is used
+        new TestCase(base)
+                .testOpts("--module-path", modules.toString(), "--limit-modules", "jdk.compiler")
+                .otherOpts("-XDrawDiagnostics",
+                        "--module-source-path", src.toString())
+                .files(findJavaFiles(src))
+                .expect(Task.Expect.FAIL, "compiler.err.module.not.found")
+                .run();
+    }
+
+    /**
+     * Tests that a module being compiled can see another module on the module path
+     * using --module-path.
+     */
+    @Test
+    public void testModulePath(Path base) throws Exception {
+        Path modules = base.resolve("modules");
+        new ModuleBuilder(tb, "m1")
+                .exports("pkg1")
+                .classes("package pkg1; public class C1 { }")
+                .build(modules);
+
+        Path src = base.resolve("src");
+        new ModuleBuilder(tb, "m2")
+                .requires("m1")
+                .classes("package pkg2; public class C2 { pkg1.C1 c1; }")
+                .write(src);
+
+        new TestCase(base)
+                .testOpts("--module-path", modules.toString())
+                .otherOpts("--module-source-path", src.toString())
+                .files(findJavaFiles(src))
+                .run();
+    }
+
+    /**
+     * Tests that a module being compiled can see classes patches into an existing module
+     * with --patch-module
+     */
+    @Test
+    public void testPatchModule(Path base) throws Exception {
+        Path patchSrc = base.resolve("patchSrc");
+        tb.writeJavaFiles(patchSrc,
+                "package java.util; public class Xyzzy { }");
+        Path patch = base.resolve("patch");
+        Files.createDirectories(patch);
+
+        new JavacTask(tb)
+                .options("-Xmodule:java.base")
+                .outdir(patch)
+                .sourcepath(patchSrc)
+                .files(findJavaFiles(patchSrc))
+                .run()
+                .writeAll();
+
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "public class C { java.util.Xyzzy x; }");
+
+        new TestCase(base)
+                .testOpts("--patch-module", "java.base=" + patch)
+                .files(findJavaFiles(src))
+                .run();
+    }
+
+    /**
+     * Tests that options in @files are also effective.
+     * The test is similar to testModulePath, except that the test options are provided in an @-file.
+     */
+    @Test
+    public void testAtFile(Path base) throws Exception {
+        Path modules = base.resolve("modules");
+        new ModuleBuilder(tb, "m1")
+                .exports("pkg1")
+                .classes("package pkg1; public class C1 { }")
+                .build(modules);
+
+        Path src = base.resolve("src");
+        new ModuleBuilder(tb, "m2")
+                .requires("m1")
+                .classes("package pkg2; public class C2 { pkg1.C1 c1; }")
+                .write(src);
+
+        Path atFile = base.resolve("atFile");
+        tb.writeFile(atFile, "--module-path " + modules);
+
+        new TestCase(base)
+                .testOpts("@" + atFile)
+                .otherOpts("--module-source-path", src.toString())
+                .files(findJavaFiles(src))
+                .run();
+    }
+
+    /**
+     * Tests that --inherit-runtime-environment works in conjunction with
+     * environment variables.
+     * This is a variant of testAddExports.
+     * The use of environment variables is sufficiently custom that it is
+     * not easy to do this directly with a simple TestCase.
+     */
+    @Test
+    public void testEnvVars(Path base) throws Exception {
+        Path src = base.resolve("src");
+        tb.writeJavaFiles(src,
+                "class C { com.sun.tools.javac.main.Main main; }");
+        List<String> testOpts =
+                Arrays.asList("--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED");
+        List<Path> files = Arrays.asList(findJavaFiles(src));
+
+        String envName = "_JAVAC_OPTIONS";
+        String envValue = String.join(" ", testOpts);
+
+        out.println("  javac:");
+        Path javacOutDir = base.resolve("out-javac");
+        Files.createDirectories(javacOutDir);
+
+        out.println("    env: " + envName + "=" + envValue);
+        out.println("    outdir: " + javacOutDir);
+        out.println("    files: " + files);
+
+        new JavacTask(tb, Task.Mode.EXEC)
+                .envVar(envName, envValue)
+                .outdir(javacOutDir)
+                .files(files)
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+
+        out.println("  java:");
+        Path javaOutDir = base.resolve("out-java");
+        Files.createDirectories(javaOutDir);
+
+        Path atFile = base.resolve("atFile");
+        tb.writeFile(atFile, String.join(" ", testOpts));
+
+        List<String> vmOpts = Arrays.asList(
+                "@" + atFile,
+                "--module", "jdk.compiler/com.sun.tools.javac.Main"
+        );
+
+        List<String> classArgs = join(
+                Arrays.asList("-d", javaOutDir.toString()),
+                files.stream()
+                        .map(p -> p.toString())
+                        .collect(Collectors.toList())
+        );
+
+        envValue = "--inherit-runtime-environment";
+
+        out.println("    env: " + envName + "=" + envValue);
+        out.println("    vmOpts: " + vmOpts);
+        out.println("    classArgs: " + classArgs);
+
+        new JavaTask(tb)
+                .envVar(envName, envValue)
+                .vmOptions(vmOpts)
+                .classArgs(classArgs)
+                .run()
+                .writeAll()
+                .getOutput(Task.OutputKind.STDERR);
+    }
+
+    /**
+     * Runs javac with given test options,  first directly, and then again, specifying the
+     * options to the runtime, and using --inherit-runtime-environment.
+     */
+    class TestCase {
+        final Path base;
+        List<String> testOpts = Collections.emptyList();
+        List<String> otherOpts = Collections.emptyList();
+        List<Path> files = Collections.emptyList();
+        Task.Expect expect = Task.Expect.SUCCESS;
+        String expectedText;
+
+        /**
+         * Creates a test case, specifying a base directory for work files.
+         */
+        TestCase(Path base) {
+            this.base = base;
+        }
+
+        /**
+         * Set the "test options" to be passed to javac or to the runtime.
+         */
+        TestCase testOpts(String... testOpts) {
+            this.testOpts = Arrays.asList(testOpts);
+            return this;
+        }
+
+        /**
+         * Sets additional options required for the compilation.
+         */
+        TestCase otherOpts(String... otherOpts) {
+            this.otherOpts = Arrays.asList(otherOpts);
+            return this;
+        }
+
+        /**
+         * Sets the files to be compiled.
+         */
+        TestCase files(Path... files) {
+            this.files = Arrays.asList(files);
+            return this;
+        }
+
+        /**
+         * Sets the expected output, and any expected output from javac.
+         * The default is {@code Expect.SUCCESS} and no specific output expected.
+         */
+        TestCase expect(Task.Expect expect, String expectedText) {
+            this.expect = expect;
+            this.expectedText = expectedText;
+            return this;
+        }
+
+        /**
+         * Runs the test case.
+         * First, javac is run passing the test options directly to javac.
+         * Then, javac is run again, passing the test options to the runtime,
+         * and using --inherit-runtime-environment.
+         */
+        void run() throws IOException {
+            runJavac();
+            runJava();
+        }
+
+        private void runJavac() throws IOException {
+            out.println("  javac:");
+            Path javacOutDir = base.resolve("out-javac");
+            Files.createDirectories(javacOutDir);
+
+            List<String> options = join(testOpts, otherOpts);
+
+            out.println("    options: " + options);
+            out.println("    outdir: " + javacOutDir);
+            out.println("    files: " + files);
+
+            String log = new JavacTask(tb, Task.Mode.CMDLINE)
+                    .options(options)
+                    .outdir(javacOutDir)
+                    .files(files)
+                    .run(expect)
+                    .writeAll()
+                    .getOutput(Task.OutputKind.DIRECT);
+
+            if (expectedText != null && !log.contains(expectedText))
+                error("expected text not found");
+        }
+
+        private void runJava() throws IOException {
+            out.println("  java:");
+            Path javaOutDir = base.resolve("out-java");
+            Files.createDirectories(javaOutDir);
+
+            List<String> vmOpts = join(
+                    testOpts,
+                    Arrays.asList("--module", "jdk.compiler/com.sun.tools.javac.Main")
+            );
+
+            List<String> classArgs = join(
+                    Arrays.asList("--inherit-runtime-environment",
+                            "-d", javaOutDir.toString()),
+                    otherOpts,
+                    files.stream()
+                            .map(p -> p.toString())
+                            .collect(Collectors.toList())
+            );
+
+            out.println("    vmOpts: " + vmOpts);
+            out.println("    classArgs: " + classArgs);
+
+            String log = new JavaTask(tb)
+                    .vmOptions(vmOpts)
+                    .classArgs(classArgs)
+                    .run(expect)
+                    .writeAll()
+                    .getOutput(Task.OutputKind.STDERR);
+
+            if (expectedText != null && !log.contains(expectedText))
+                error("expected text not found");
+        }
+    }
+
+    /**
+     * Join a series of lists.
+     */
+    @SafeVarargs
+    private <T> List<T> join(List<T>... lists) {
+        return Arrays.stream(lists)
+            .flatMap(list -> list.stream())
+            .collect(Collectors.toList());
+    }
+
+}
+
--- a/langtools/test/tools/javac/modules/MOptionTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/MOptionTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -58,7 +58,7 @@
                 "package test; public class Test {}");
 
         new JavacTask(tb)
-                .options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString())
+                .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
 
@@ -81,7 +81,7 @@
         Thread.sleep(2000); //timestamps
 
         new JavacTask(tb)
-                .options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString())
+                .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
 
@@ -98,7 +98,7 @@
         Files.setLastModifiedTime(testTest, FileTime.fromMillis(System.currentTimeMillis()));
 
         new JavacTask(tb)
-                .options("-m", "m1", "-modulesourcepath", src.toString(), "-d", build.toString())
+                .options("-m", "m1", "--module-source-path", src.toString(), "-d", build.toString())
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
 
@@ -125,7 +125,7 @@
         String log = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
                     "-m", "m1",
-                    "-modulesourcepath", src.toString())
+                    "--module-source-path", src.toString())
                 .run(Task.Expect.FAIL)
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
@@ -174,7 +174,7 @@
                 "package p2; public class C2 {}");
 
         new JavacTask(tb)
-                .options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString())
+                .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
 
@@ -215,7 +215,7 @@
         Thread.sleep(2000); //timestamps
 
         new JavacTask(tb)
-                .options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString())
+                .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
 
@@ -241,7 +241,7 @@
         Files.setLastModifiedTime(C2Source, FileTime.fromMillis(System.currentTimeMillis()));
 
         new JavacTask(tb)
-                .options("-m", "m1,m2", "-modulesourcepath", src.toString(), "-d", build.toString())
+                .options("-m", "m1,m2", "--module-source-path", src.toString(), "-d", build.toString())
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
 
--- a/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/MissingJarInModulePathTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,7 +25,7 @@
  * @test
  * @bug 8154824
  * @summary Compiler should handle java.nio.file.FileSystemNotFoundException gracefully and not abort
- * @compile/fail/ref=MissingJarInModulePathTest.out -XDrawDiagnostics -Xlint:path -Werror -modulepath missing.jar MissingJarInModulePathTest.java
+ * @compile/fail/ref=MissingJarInModulePathTest.out -XDrawDiagnostics -Xlint:path -Werror --module-path missing.jar MissingJarInModulePathTest.java
  */
 
 class MissingJarInModulePathTest {}
--- a/langtools/test/tools/javac/modules/ModuleFinderTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ModuleFinderTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -78,7 +78,7 @@
 
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-XDrawDiagnostics", "-modulepath", modules.toString())
+                .options("-XDrawDiagnostics", "--module-path", modules.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src2))
                 .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/ModuleInfoTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ModuleInfoTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -188,7 +188,7 @@
         Files.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -216,7 +216,7 @@
         Files.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -242,7 +242,7 @@
         Files.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -289,7 +289,7 @@
         Files.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -315,7 +315,7 @@
         Files.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -356,7 +356,7 @@
             tb.writeFile(src_m1.resolve("module-info.java"), moduleInfo);
 
             String log = new JavacTask(tb)
-                    .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                    .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                     .outdir(classes)
                     .files(findJavaFiles(src))
                     .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/ModulePathTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ModulePathTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary tests for -modulepath
+ * @summary tests for --module-path
  * @library /tools/lib
  * @modules
  *      jdk.compiler/com.sun.tools.javac.api
@@ -62,13 +62,13 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", "doesNotExist")
+                        "--module-path", "doesNotExist")
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, doesNotExist"))
+        if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, doesNotExist"))
             throw new Exception("expected output not found");
     }
 
@@ -80,13 +80,13 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", "dummy.txt")
+                        "--module-path", "dummy.txt")
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, dummy.txt"))
+        if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, dummy.txt"))
             throw new Exception("expected output not found");
     }
 
@@ -98,13 +98,13 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", "dummy.jimage")
+                        "--module-path", "dummy.jimage")
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("- compiler.err.illegal.argument.for.option: -modulepath, dummy.jimage"))
+        if (!log.contains("- compiler.err.illegal.argument.for.option: --module-path, dummy.jimage"))
             throw new Exception("expected output not found");
     }
 
@@ -132,7 +132,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .outdir(classes)
-                .options("-modulepath", modClasses.toString())
+                .options("--module-path", modClasses.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -153,7 +153,7 @@
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .outdir(classes)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", modClasses.toString())
+                        "--module-path", modClasses.toString())
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
@@ -190,7 +190,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .outdir(classes)
-                .options("-modulepath", moduleJar.toString(), "-addmods", "m1")
+                .options("--module-path", moduleJar.toString(), "--add-modules", "m1")
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -226,7 +226,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .outdir(classes)
-                .options("-modulepath", moduleJar.toString())
+                .options("--module-path", moduleJar.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -240,7 +240,7 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", "dummy.jar")
+                        "--module-path", "dummy.jar")
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
@@ -277,7 +277,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .outdir(classes)
-                .options("-modulepath", jmod.toString())
+                .options("--module-path", jmod.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -291,7 +291,7 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", "dummy.jmod")
+                        "--module-path", "dummy.jmod")
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
@@ -311,7 +311,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", modules + "/./../modules")
+                        "--module-path", modules + "/./../modules")
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -327,7 +327,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", modules + "/./../modules" + PATH_SEP + modules)
+                        "--module-path", modules + "/./../modules" + PATH_SEP + modules)
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -343,8 +343,8 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", modules.toString(),
-                        "-modulepath", modules.toString())
+                        "--module-path", modules.toString(),
+                        "--module-path", modules.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -370,7 +370,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", deepModuleDir + PATH_SEP + modules)
+                        "--module-path", deepModuleDir + PATH_SEP + modules)
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -400,7 +400,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", modules.toString())
+                        "--module-path", modules.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
--- a/langtools/test/tools/javac/modules/ModuleSourcePathTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ModuleSourcePathTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -62,14 +62,14 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-sourcepath", sp.toString().replace('/', File.separatorChar),
-                        "-modulesourcepath", msp.toString().replace('/', File.separatorChar),
+                        "--source-path", sp.toString().replace('/', File.separatorChar),
+                        "--module-source-path", msp.toString().replace('/', File.separatorChar),
                         "dummyClass")
                 .run(Task.Expect.FAIL)
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
 
-        if (!log.contains("cannot specify both -sourcepath and -modulesourcepath"))
+        if (!log.contains("cannot specify both --source-path and --module-source-path"))
             throw new Exception("expected diagnostic not found");
     }
 
@@ -83,7 +83,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(prefixAll(findJavaFiles(src), Paths.get("./")))
                 .run()
@@ -100,7 +100,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", "./" + src)
+                        "--module-source-path", "./" + src)
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run()
@@ -123,7 +123,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/{src1,src2/inner_dir}")
+                        "--module-source-path", base + "/{src1,src2/inner_dir}")
                 .files(base.resolve("src1/m0/pkg0/A.java"), base.resolve("src2/inner_dir/m1/pkg1/A.java"))
                 .outdir(modules)
                 .run()
@@ -154,12 +154,12 @@
         for (String sourcepath : sourcePaths) {
             String log = new JavacTask(tb, Task.Mode.CMDLINE)
                     .options("-XDrawDiagnostics",
-                            "-modulesourcepath", sourcepath.replace('/', File.separatorChar))
+                            "--module-source-path", sourcepath.replace('/', File.separatorChar))
                     .run(Task.Expect.FAIL)
                     .writeAll()
                     .getOutput(Task.OutputKind.DIRECT);
 
-            if (!log.contains("- compiler.err.illegal.argument.for.option: -modulesourcepath, mismatched braces"))
+            if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, mismatched braces"))
                 throw new Exception("expected output for path [" + sourcepath + "] not found");
         }
     }
@@ -182,7 +182,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath",
+                        "--module-source-path",
                         base + "/{src/{{src1,src2,src3},{srcB,srcC}/{src1,src2/srcX{X,Y}/}},.}"
                                 .replace('/', File.separatorChar))
                 .files(findJavaFiles(base.resolve(modulePaths[modulePaths.length - 1])))
@@ -207,7 +207,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/{dummy.txt,src}")
+                        "--module-source-path", base + "/{dummy.txt,src}")
                 .files(src.resolve("kettle$/electric/Heater.java"))
                 .outdir(modules)
                 .run()
@@ -227,7 +227,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/{src}")
+                        "--module-source-path", base + "/{src}")
                 .files(src.resolve("kettle$/electric/Heater.java"))
                 .outdir(modules)
                 .run()
@@ -246,7 +246,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/{}")
+                        "--module-source-path", base + "/{}")
                 .files(base.resolve("kettle$/electric/Heater.java"))
                 .outdir(modules)
                 .run()
@@ -267,7 +267,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", "{" + src + "," + src + "/car}")
+                        "--module-source-path", "{" + src + "," + src + "/car}")
                 .files(findJavaFiles(src))
                 .outdir(modules)
                 .run()
@@ -286,7 +286,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/src/./../src")
+                        "--module-source-path", base + "/src/./../src")
                 .files(src.resolve("kettle/electric/Heater.java"))
                 .outdir(modules)
                 .run()
@@ -305,7 +305,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/{src,src,src}")
+                        "--module-source-path", base + "/{src,src,src}")
                 .files(src.resolve("m1/a/A.java"))
                 .outdir(modules)
                 .run()
@@ -323,7 +323,7 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/not_exist" + PATH_SEP + base + "/{not_exist,}")
+                        "--module-source-path", base + "/not_exist" + PATH_SEP + base + "/{not_exist,}")
                 .files(base.resolve("m1/a/A.java"))
                 .outdir(modules)
                 .run(Task.Expect.FAIL)
@@ -342,7 +342,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "{/not_exist,/}")
+                        "--module-source-path", base + "{/not_exist,/}")
                 .files(base.resolve("m1/a/A.java"))
                 .outdir(modules)
                 .run()
@@ -361,7 +361,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/{,{,,,,src,,,}}")
+                        "--module-source-path", base + "/{,{,,,,src,,,}}")
                 .files(src.resolve("m1/a/A.java"))
                 .outdir(modules)
                 .run()
@@ -380,7 +380,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", base + "/*/classes/")
+                        "--module-source-path", base + "/*/classes/")
                 .files(base.resolve("kettle/classes/electric/Heater.java"))
                 .outdir(modules)
                 .run()
@@ -403,7 +403,7 @@
 
         new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src + "{/*/gensrc/,/*/classes/}" + PATH_SEP
+                        "--module-source-path", src + "{/*/gensrc/,/*/classes/}" + PATH_SEP
                                 + src + "/*/special/classes")
                 .files(findJavaFiles(src))
                 .outdir(modules)
@@ -432,12 +432,12 @@
         for (String sourcepath : sourcePaths) {
             String log = new JavacTask(tb, Task.Mode.CMDLINE)
                     .options("-XDrawDiagnostics",
-                            "-modulesourcepath", sourcepath.replace('/', File.separatorChar))
+                            "--module-source-path", sourcepath.replace('/', File.separatorChar))
                     .run(Task.Expect.FAIL)
                     .writeAll()
                     .getOutput(Task.OutputKind.DIRECT);
 
-            if (!log.contains("- compiler.err.illegal.argument.for.option: -modulesourcepath, illegal use of *"))
+            if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, illegal use of *"))
                 throw new Exception("expected output for path [" + sourcepath + "] not found");
         }
     }
--- a/langtools/test/tools/javac/modules/ModuleTestBase.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ModuleTestBase.java	Fri Aug 19 12:17:32 2016 -0700
@@ -21,28 +21,10 @@
  * questions.
  */
 
-import java.io.File;
 import java.io.IOException;
-import java.io.PrintStream;
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.stream.Collectors;
 
-import toolbox.JavacTask;
 import toolbox.TestRunner;
 import toolbox.ToolBox;
 
--- a/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ModulesAndClassPathTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -46,7 +46,6 @@
 import toolbox.JarTask;
 import toolbox.JavacTask;
 import toolbox.Task;
-import toolbox.ToolBox;
 
 public class ModulesAndClassPathTest extends ModuleTestBase {
 
@@ -70,7 +69,7 @@
                           "package impl; public class Impl { api.Api api; }");
 
         List<String> modLog = new JavacTask(tb)
-                                .options("-classpath", jar.toString(),
+                                .options("--class-path", jar.toString(),
                                          "-XDrawDiagnostics")
                                 .outdir(classes)
                                 .files(findJavaFiles(moduleSrc))
@@ -86,8 +85,8 @@
         }
 
         new JavacTask(tb)
-          .options("-classpath", jar.toString(),
-                   "-XaddReads:m1=ALL-UNNAMED")
+          .options("--class-path", jar.toString(),
+                   "--add-reads", "m1=ALL-UNNAMED")
           .outdir(classes)
           .files(findJavaFiles(moduleSrc))
           .run()
@@ -95,8 +94,8 @@
           .getOutputLines(Task.OutputKind.DIRECT);
 
         new JavacTask(tb)
-          .options("-classpath", jar.toString() + File.pathSeparator + System.getProperty("test.classes"),
-                   "-XaddReads:m1=ALL-UNNAMED",
+          .options("--class-path", jar.toString() + File.pathSeparator + System.getProperty("test.classes"),
+                   "--add-reads", "m1=ALL-UNNAMED",
                    "-processor", ProcessorImpl.class.getName())
           .outdir(classes)
           .files(findJavaFiles(moduleSrc))
@@ -121,7 +120,7 @@
                           "package impl; public class Impl { api.Api api; }");
 
         List<String> modLog = new JavacTask(tb)
-                                .options("-classpath", jar.toString(),
+                                .options("--class-path", jar.toString(),
                                          "-sourcepath", m1.toString(),
                                          "-XDrawDiagnostics")
                                 .outdir(classes)
@@ -154,7 +153,7 @@
                           "package impl; public class Impl { api.Api api; }");
 
         new JavacTask(tb)
-          .options("-classpath", jar.toString(),
+          .options("--class-path", jar.toString(),
                    "-XDrawDiagnostics")
           .outdir(classes)
           .files(m1.resolve("module-info.java"))
@@ -163,7 +162,7 @@
           .getOutputLines(Task.OutputKind.DIRECT);
 
         List<String> modLog = new JavacTask(tb)
-                                .options("-classpath", jar.toString(),
+                                .options("--class-path", jar.toString(),
                                          "-XDrawDiagnostics")
                                 .outdir(classes)
                                 .files(m1.resolve("impl").resolve("Impl.java"))
--- a/langtools/test/tools/javac/modules/MultiModuleModeTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/MultiModuleModeTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -60,7 +60,7 @@
 
         String log = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -83,7 +83,7 @@
 
         String log = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(join(findJavaFiles(src), findJavaFiles(misc)))
                 .run(Task.Expect.FAIL)
@@ -104,7 +104,7 @@
 
         String log = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -124,7 +124,7 @@
         Files.createDirectories(modules);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", src.toString())
+                .options("--module-source-path", src.toString())
                 .outdir(modules)
                 .files(src.resolve("m2/module-info.java"))
                 .run()
@@ -139,7 +139,7 @@
         Files.createDirectories(modules1);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", src1.toString())
+                .options("--module-source-path", src1.toString())
                 .outdir(modules1)
                 .files(src1.resolve("m1/module-info.java"))
                 .run()
@@ -151,8 +151,8 @@
         Files.createDirectories(modules2);
 
         new JavacTask(tb)
-                .options("-modulepath", modules1.toString(),
-                        "-modulesourcepath", src2.toString())
+                .options("--module-path", modules1.toString(),
+                        "--module-source-path", src2.toString())
                 .outdir(modules2)
                 .files(src2.resolve("m2/module-info.java"))
                 .run()
--- a/langtools/test/tools/javac/modules/NPEEmptyFileTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/NPEEmptyFileTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -51,7 +51,7 @@
         Path emptyJavaFile = base.resolve("Test.java");
         tb.writeFile(emptyJavaFile, "");
         new JavacTask(tb, Task.Mode.EXEC)
-                .options("-modulesourcepath", modules.toString(),
+                .options("--module-source-path", modules.toString(),
                         "-d", modules.toString(), emptyJavaFile.toString())
                 .run()
                 .writeAll();
--- a/langtools/test/tools/javac/modules/OutputDirTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/OutputDirTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -63,7 +63,7 @@
     public void testError(Path base) throws Exception {
         String log = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
@@ -78,7 +78,7 @@
         new JavacTask(tb)
                 .options("-XDrawDiagnostics",
                         "-proc:only",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .files(findJavaFiles(src))
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
@@ -90,7 +90,7 @@
         new JavacTask(tb)
                 .options("-XDrawDiagnostics",
                         "-d", classes.toString(),
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .files(findJavaFiles(src))
                 .run(Task.Expect.SUCCESS)
                 .writeAll();
@@ -120,7 +120,7 @@
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .outdir(modClasses) // an exploded module
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
@@ -157,7 +157,7 @@
                 .outdir(classes) // within an exploded module
                 .options("-XDrawDiagnostics",
                         "-Xlint", "-Werror",
-                        "-modulepath", modClasses.toString())
+                        "--module-path", modClasses.toString())
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
--- a/langtools/test/tools/javac/modules/PackageConflictTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/PackageConflictTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -82,7 +82,7 @@
         Files.createDirectories(classes);
 
         new JavacTask(tb)
-          .options("-Werror", "-modulesourcepath", base.toString())
+          .options("-Werror", "--module-source-path", base.toString())
           .outdir(classes)
           .files(findJavaFiles(base))
           .run()
@@ -107,7 +107,7 @@
         Files.createDirectories(classes);
 
         List<String> log = new JavacTask(tb)
-                       .options("-XDrawDiagnostics", "-modulesourcepath", base.toString())
+                       .options("-XDrawDiagnostics", "--module-source-path", base.toString())
                        .outdir(classes)
                        .files(findJavaFiles(base))
                        .run(Task.Expect.FAIL)
@@ -137,7 +137,7 @@
                 .write(modSrc);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-mp", modules.toString())
+                .options("-XDrawDiagnostics", "-p", modules.toString())
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(modSrc.resolve("M")))
                 .run(Task.Expect.FAIL)
@@ -162,7 +162,7 @@
                 .write(modSrc);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", modSrc.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", modSrc.toString())
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(modSrc))
                 .run(Task.Expect.SUCCESS)
@@ -189,7 +189,7 @@
                 .write(modSrc);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-mp", modules.toString())
+                .options("-XDrawDiagnostics", "-p", modules.toString())
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(modSrc.resolve("M")))
                 .run(Task.Expect.SUCCESS)
@@ -220,7 +220,7 @@
                 .write(modSrc);
 
         List<String> log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-mp", modules.toString())
+                .options("-XDrawDiagnostics", "-p", modules.toString())
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(modSrc.resolve("K")))
                 .run(Task.Expect.FAIL)
@@ -252,7 +252,7 @@
                 .classes("package p; public class DependsOnN { boolean f = pkg.A.flagN; } ")
                 .write(modSrc);
         new JavacTask(tb)
-                .options("-modulesourcepath", modSrc.toString())
+                .options("--module-source-path", modSrc.toString())
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(modSrc.resolve("K")))
                 .run(Task.Expect.SUCCESS)
@@ -265,7 +265,7 @@
 
         List<String> output = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", modSrc.toString())
+                        "--module-source-path", modSrc.toString())
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(modSrc.resolve("K")))
                 .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/PackageMultipleModules.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/PackageMultipleModules.java	Fri Aug 19 12:17:32 2016 -0700
@@ -39,7 +39,6 @@
 
 import toolbox.JavacTask;
 import toolbox.Task;
-import toolbox.ToolBox;
 
 public class PackageMultipleModules extends ModuleTestBase {
 
@@ -64,7 +63,7 @@
         Files.createDirectories(classes);
 
         List<String> log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", base.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", base.toString())
                 .outdir(classes)
                 .files(findJavaFiles(base))
                 .run(Task.Expect.FAIL)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/modules/PatchModulesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2016, 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 8160489
+ * @summary tests for --patch-modules
+ * @library /tools/lib
+ * @modules
+ *      jdk.compiler/com.sun.tools.javac.api
+ *      jdk.compiler/com.sun.tools.javac.file
+ *      jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
+ * @run main PatchModulesTest
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.tools.JavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.file.BaseFileManager;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.file.Locations;
+
+import static java.util.Arrays.asList;
+
+
+public class PatchModulesTest extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        PatchModulesTest t = new PatchModulesTest();
+        t.init();
+        t.runTests();
+    }
+
+    private static String PS = File.pathSeparator;
+
+    void init() throws IOException {
+        tb.createDirectories("a", "b", "c", "d", "e");
+        tb.writeJavaFiles(Paths.get("."), "class C { }");
+    }
+
+    @Test
+    public void testSimple(Path base) throws Exception {
+        test(asList("java.base=a"),
+            "{java.base=[a]}");
+    }
+
+    @Test
+    public void testPair(Path base) throws Exception {
+        test(asList("java.base=a", "java.compiler=b"),
+            "{java.base=[a], java.compiler=[b]}");
+    }
+
+    @Test
+    public void testMultiple(Path base) throws Exception {
+        test(asList("java.base=a:b"),
+            "{java.base=[a, b]}");
+    }
+
+    @Test
+    public void testLastOneWins(Path base) throws Exception {
+        test(asList("java.base=a", "java.compiler=b", "java.base=c"),
+            "{java.base=[c], java.compiler=[b]}");
+    }
+
+    void test(List<String> patches, String expect) throws Exception {
+        JavacTool tool = (JavacTool) ToolProvider.getSystemJavaCompiler();
+        StringWriter sw = new StringWriter();
+        try (PrintWriter pw = new PrintWriter(sw)) {
+            JavacFileManager fm = tool.getStandardFileManager(null, null, null);
+            List<String> opts = patches.stream()
+                .map(p -> "--patch-module=" + p.replace(":", PS))
+                .collect(Collectors.toList());
+            Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects("C.java");
+            JavacTask task = tool.getTask(pw, fm, null, opts, null, files);
+
+            Field locationsField = BaseFileManager.class.getDeclaredField("locations");
+            locationsField.setAccessible(true);
+            Object locations = locationsField.get(fm);
+
+            Field patchMapField = Locations.class.getDeclaredField("patchMap");
+            patchMapField.setAccessible(true);
+            Map<?,?> patchMap = (Map<?,?>) patchMapField.get(locations);
+            String found = patchMap.toString();
+
+            if (!found.equals(expect)) {
+                tb.out.println("Expect: " + expect);
+                tb.out.println("Found:  " + found);
+                error("output not as expected");
+            }
+        }
+    }
+}
+
--- a/langtools/test/tools/javac/modules/PluginsInModulesTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/PluginsInModulesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -107,7 +107,7 @@
                 plugin1);
 
         String log = new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(processorCompiledModules)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -130,7 +130,7 @@
     public void testUseOnlyOneProcessor(Path base) throws Exception {
         initialization(base);
         List<String> log = new JavacTask(tb)
-                .options("-processormodulepath", processorCompiledModules.toString(),
+                .options("--processor-module-path", processorCompiledModules.toString(),
                         "-Xplugin:simpleplugin1")
                 .outdir(classes)
                 .sources(testClass)
--- a/langtools/test/tools/javac/modules/ProvidesTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ProvidesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -77,7 +77,7 @@
         Files.createDirectories(modules);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", src.toString())
+                .options("--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.SUCCESS)
@@ -160,7 +160,7 @@
 
         List<String> output = new JavacTask(tb)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", modules.toString())
+                        "--module-source-path", modules.toString())
                 .outdir(Files.createDirectories(base.resolve("classes")))
                 .files(findJavaFiles(modules))
                 .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/QueryBeforeEnter.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/QueryBeforeEnter.java	Fri Aug 19 12:17:32 2016 -0700
@@ -94,7 +94,7 @@
         Files.createDirectories(modulePath);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(modulePath)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -131,8 +131,8 @@
                 (com.sun.source.util.JavacTask) javaCompiler.getTask(null,
                                                               null,
                                                               d -> { throw new IllegalStateException(d.toString()); },
-                                                              Arrays.asList("-modulepath", modulePath.toString(),
-                                                                            "-classpath", cp.toString(),
+                                                              Arrays.asList("--module-path", modulePath.toString(),
+                                                                            "--class-path", cp.toString(),
                                                                             "-sourcepath", src.toString()),
                                                               null,
                                                               fm.getJavaFileObjects(src.resolve("test").resolve("Test2.java")));
@@ -170,7 +170,7 @@
         Files.createDirectories(modulePath);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", moduleSrc.toString())
+                .options("--module-source-path", moduleSrc.toString())
                 .outdir(modulePath)
                 .files(findJavaFiles(moduleSrc))
                 .run()
@@ -207,8 +207,8 @@
                 (com.sun.source.util.JavacTask) javaCompiler.getTask(null,
                                                               null,
                                                               d -> { throw new IllegalStateException(d.toString()); },
-                                                              Arrays.asList("-modulepath", modulePath.toString(),
-                                                                            "-classpath", cp.toString(),
+                                                              Arrays.asList("--module-path", modulePath.toString(),
+                                                                            "--class-path", cp.toString(),
                                                                             "-sourcepath", src.toString()),
                                                               null,
                                                               fm.getJavaFileObjects(findJavaFiles(src)));
@@ -245,7 +245,7 @@
         Files.createDirectories(modulePath);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", modulePathSrc.toString())
+                .options("--module-source-path", modulePathSrc.toString())
                 .outdir(modulePath)
                 .files(findJavaFiles(modulePathSrc))
                 .run()
@@ -289,9 +289,9 @@
                 (com.sun.source.util.JavacTask) javaCompiler.getTask(null,
                                                               null,
                                                               d -> { throw new IllegalStateException(d.toString()); },
-                                                              Arrays.asList("-modulepath", modulePath.toString(),
-                                                                            "-classpath", cp.toString(),
-                                                                            "-modulesourcepath", moduleSrc.toString(),
+                                                              Arrays.asList("--module-path", modulePath.toString(),
+                                                                            "--class-path", cp.toString(),
+                                                                            "--module-source-path", moduleSrc.toString(),
                                                                             "-d", out.toString()),
                                                               null,
                                                               fm.getJavaFileObjects(findJavaFiles(moduleSrc)));
@@ -339,7 +339,7 @@
                 (com.sun.source.util.JavacTask) javaCompiler.getTask(null,
                                                               null,
                                                               d -> { throw new IllegalStateException(d.toString()); },
-                                                              Arrays.asList("-processorpath", processorPath,
+                                                              Arrays.asList("--processor-path", processorPath,
                                                                             "-processor", AP.class.getName(),
                                                                             "-Xplugin:test"),
                                                               null,
@@ -347,7 +347,7 @@
             task.call();
         }
 
-        Main.compile(new String[] {"-processorpath", processorPath,
+        Main.compile(new String[] {"--processor-path", processorPath,
                                    "-Xplugin:test",
                                    testSource.toString()});
     }
--- a/langtools/test/tools/javac/modules/RequiresPublicTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/RequiresPublicTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -80,7 +80,7 @@
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics")
                 .files(findJavaFiles(src))
-                .outdir(classes.toString()) // should allow Path here
+                .outdir(classes)
                 .run(Task.Expect.FAIL)
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
@@ -96,7 +96,7 @@
         Files.createDirectories(classes);
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulesourcepath", src.toString())
+                .options("--module-source-path", src.toString())
                 .files(findJavaFiles(src))
                 .outdir(classes)
                 .run()
@@ -113,7 +113,7 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulesourcepath", src.toString())
+                        "--module-source-path", src.toString())
                 .files(findJavaFiles(src))
                 .outdir(classes)
                 .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/ResolveTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ResolveTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -93,7 +93,7 @@
         Files.createDirectories(modules);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -117,7 +117,7 @@
         Files.createDirectories(modules);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -143,7 +143,7 @@
         Files.createDirectories(modules);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -167,7 +167,7 @@
         Files.createDirectories(modules);
 
         String log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -191,7 +191,7 @@
         Files.createDirectories(modules);
 
         new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run()
@@ -211,7 +211,7 @@
         Files.createDirectories(modules);
 
         new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run()
--- a/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/ServiceProvidedButNotExportedOrUsedTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -90,7 +90,7 @@
         Files.createDirectories(modules);
 
         List<String> output = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/SingleModuleModeTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/SingleModuleModeTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -128,7 +128,7 @@
 
         new JavacTask(tb)
                 .options("-processor", VerifyUsesProvides.class.getName(),
-                         "-processorpath", System.getProperty("test.classes"))
+                         "--processor-path", System.getProperty("test.classes"))
                 .outdir(classes)
                 .classpath(classes)
                 .files(src.resolve("C.java"))
@@ -147,7 +147,7 @@
 
         new JavacTask(tb)
                 .options("-processor", VerifyUsesProvides.class.getName(),
-                         "-processorpath", System.getProperty("test.classes"))
+                         "--processor-path", System.getProperty("test.classes"))
                 .outdir(classes)
                 .sourcepath(src)
                 .classpath(classes)
--- a/langtools/test/tools/javac/modules/SubpackageTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/SubpackageTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -110,7 +110,7 @@
         Files.createDirectories(modules);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", src.toString())
+                .options("--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run()
--- a/langtools/test/tools/javac/modules/UpgradeModulePathTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/UpgradeModulePathTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -66,8 +66,8 @@
                 "package p; class A { void main() { pkg2.E.class.getName(); } }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulepath", modules.toString(),
-                        "-upgrademodulepath", upgradeModules.toString())
+                .options("--module-path", modules.toString(),
+                        "--upgrade-module-path", upgradeModules.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -92,7 +92,7 @@
                 "package p; class A { void main() { pkg2.E.class.getName(); } }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-upgrademodulepath", upgradeModule + File.pathSeparator + module)
+                .options("--upgrade-module-path", upgradeModule + File.pathSeparator + module)
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -126,9 +126,9 @@
                 "package p; class A { void main() { pkg2.E.class.getName(); } }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulepath", module.toString(),
-                        "-modulesourcepath", src + File.pathSeparator + s,
-                        "-upgrademodulepath", upgradeModule + File.pathSeparator + upgradeModule3)
+                .options("--module-path", module.toString(),
+                        "--module-source-path", src + File.pathSeparator + s,
+                        "--upgrade-module-path", upgradeModule + File.pathSeparator + upgradeModule3)
                 .outdir(module)
                 .files(findJavaFiles(src))
                 .run()
@@ -154,8 +154,8 @@
                 "package p; class A { void main() { pkg2.E.class.getName(); } }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulepath", upgradeModule + File.pathSeparator + module,
-                        "-upgrademodulepath", upgradeModule.toString())
+                .options("--module-path", upgradeModule + File.pathSeparator + module,
+                        "--upgrade-module-path", upgradeModule.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -178,13 +178,13 @@
 
         String output = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", module.toString(),
-                        "-upgrademodulepath", dummy.toString())
+                        "--module-path", module.toString(),
+                        "--upgrade-module-path", dummy.toString())
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
                 .writeAll()
                 .getOutput(Task.OutputKind.DIRECT);
-        if (!output.contains("compiler.err.illegal.argument.for.option: -upgrademodulepath, " + dummy)) {
+        if (!output.contains("compiler.err.illegal.argument.for.option: --upgrade-module-path, " + dummy)) {
             throw new Exception("Expected output was not found");
         }
     }
@@ -217,8 +217,8 @@
                 "package p; class A { void main() { pkg1.A.class.getName(); pkg2.BC.class.getName(); pkg3.DC.class.getName(); } }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulepath", module.toString(),
-                        "-upgrademodulepath", upgradeModule.toString())
+                .options("--module-path", module.toString(),
+                        "--upgrade-module-path", upgradeModule.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -229,8 +229,8 @@
 
         String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", module.toString(),
-                        "-upgrademodulepath", upgradeModule.toString())
+                        "--module-path", module.toString(),
+                        "--upgrade-module-path", upgradeModule.toString())
                 .files(findJavaFiles(src2))
                 .run(Task.Expect.FAIL)
                 .writeAll()
@@ -265,9 +265,9 @@
                 "package p; class A { void main() { pkg2.EC2.class.getName(); } }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulepath", module.toString(),
-                        "-upgrademodulepath", upgradeModule1.toString(),
-                        "-upgrademodulepath", upgradeModule2.toString())
+                .options("--module-path", module.toString(),
+                        "--upgrade-module-path", upgradeModule1.toString(),
+                        "--upgrade-module-path", upgradeModule2.toString())
                 .files(findJavaFiles(src))
                 .run()
                 .writeAll();
@@ -278,9 +278,9 @@
 
         final String log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", module.toString(),
-                        "-upgrademodulepath", upgradeModule1.toString(),
-                        "-upgrademodulepath", upgradeModule2.toString())
+                        "--module-path", module.toString(),
+                        "--upgrade-module-path", upgradeModule1.toString(),
+                        "--upgrade-module-path", upgradeModule2.toString())
                 .files(findJavaFiles(src2))
                 .run(Task.Expect.FAIL)
                 .writeAll()
--- a/langtools/test/tools/javac/modules/UsesTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/UsesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -154,7 +154,7 @@
         Files.createDirectories(modules);
 
         new JavacTask(tb)
-                .options("-modulesourcepath", src.toString())
+                .options("--module-source-path", src.toString())
                 .outdir(modules)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.SUCCESS)
@@ -175,7 +175,7 @@
                 .write(modSrc);
 
         new JavacTask(tb)
-                .options("-mp", modules.toString())
+                .options("-p", modules.toString())
                 .outdir(modules)
                 .files(findJavaFiles(modSrc.resolve("m2")))
                 .run(Task.Expect.SUCCESS)
@@ -196,7 +196,7 @@
                 .write(modSrc);
 
         new JavacTask(tb)
-                .options("-mp", modules.toString())
+                .options("-p", modules.toString())
                 .outdir(modules)
                 .files(findJavaFiles(modSrc.resolve("m2")))
                 .run(Task.Expect.SUCCESS)
@@ -255,7 +255,7 @@
                 "module m2 { requires m1; uses p.C; }");
 
         List<String> output = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(Files.createDirectories(base.resolve("modules")))
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -279,7 +279,7 @@
                 "module m2 { requires m1; uses p.C; }");
 
         List<String> output = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "--module-source-path", src.toString())
                 .outdir(Files.createDirectories(base.resolve("modules")))
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
--- a/langtools/test/tools/javac/modules/XModuleTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/modules/XModuleTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -112,7 +112,7 @@
         tb.createDirectories(classes);
 
         String log = new JavacTask(tb)
-                .options("-Xmodule:java.compiler", "-classpath", cpClasses.toString())
+                .options("-Xmodule:java.compiler", "--class-path", cpClasses.toString())
                 .outdir(classes)
                 .files(src.resolve("javax/lang/model/element/Extra.java"))
                 .run()
@@ -197,7 +197,7 @@
         tb.createDirectories(classes);
 
         List<String> log = new JavacTask(tb)
-                .options("-XDrawDiagnostics", "-Xmodule:java.compiler", "-modulesourcepath", src.toString())
+                .options("-XDrawDiagnostics", "-Xmodule:java.compiler", "--module-source-path", src.toString())
                 .outdir(classes)
                 .files(findJavaFiles(src))
                 .run(Task.Expect.FAIL)
@@ -229,7 +229,7 @@
 
         List<String> expected = Arrays.asList("javac: option -Xmodule: can only be specified once",
                                               "Usage: javac <options> <source files>",
-                                              "use -help for a list of possible options");
+                                              "use --help for a list of possible options");
 
         if (!expected.equals(log))
             throw new Exception("expected output not found: " + log);
@@ -247,7 +247,7 @@
         tb.writeJavaFiles(src, "package p; interface A extends pkg1.E { }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulepath", modules.toString(),
+                .options("--module-path", modules.toString(),
                         "-Xmodule:m1")
                 .files(findJavaFiles(src))
                 .run()
@@ -263,7 +263,7 @@
 
         List<String> log = new JavacTask(tb, Task.Mode.CMDLINE)
                 .options("-XDrawDiagnostics",
-                        "-modulepath", modules.toString(),
+                        "--module-path", modules.toString(),
                         "-Xmodule:m1")
                 .files(findJavaFiles(src2))
                 .run(Task.Expect.FAIL)
@@ -295,8 +295,8 @@
         tb.writeJavaFiles(src, "package p; interface A extends pkg1.D { }");
 
         new JavacTask(tb, Task.Mode.CMDLINE)
-                .options("-modulepath", modules.toString(),
-                        "-upgrademodulepath", upgrade.toString(),
+                .options("--module-path", modules.toString(),
+                        "--upgrade-module-path", upgrade.toString(),
                         "-Xmodule:m1")
                 .files(findJavaFiles(src))
                 .run()
--- a/langtools/test/tools/javac/options/modes/AtFilesTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/AtFilesTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,13 +29,13 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main AtFilesTest
  */
 
 import java.io.IOException;
 
-public class AtFilesTest extends Tester {
+public class AtFilesTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         AtFilesTest t = new AtFilesTest();
         t.runTests();
--- a/langtools/test/tools/javac/options/modes/DocLintTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/DocLintTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,14 +29,14 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main DocLintTest
  */
 
 import com.sun.tools.javac.main.Main;
 import java.io.IOException;
 
-public class DocLintTest extends Tester {
+public class DocLintTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         DocLintTest t = new DocLintTest();
         t.runTests();
--- a/langtools/test/tools/javac/options/modes/FSInfoTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/FSInfoTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,7 +29,7 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main FSInfoTest
  */
 
@@ -37,7 +37,7 @@
 import com.sun.tools.javac.file.FSInfo;
 import java.io.IOException;
 
-public class FSInfoTest extends Tester {
+public class FSInfoTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         FSInfoTest t = new FSInfoTest();
         t.writeFile("C.java", "class C { }");
--- a/langtools/test/tools/javac/options/modes/InfoOptsTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/InfoOptsTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,13 +29,13 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main InfoOptsTest
  */
 
 import java.io.IOException;
 
-public class InfoOptsTest extends Tester {
+public class InfoOptsTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         InfoOptsTest t = new InfoOptsTest();
         t.runTests();
--- a/langtools/test/tools/javac/options/modes/NoOperandsTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/NoOperandsTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,14 +29,14 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main NoOperandsTest
  */
 
 import com.sun.tools.javac.main.Main;
 import java.io.IOException;
 
-public class NoOperandsTest extends Tester {
+public class NoOperandsTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         NoOperandsTest t = new NoOperandsTest();
         t.runTests();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/options/modes/OptionModesTester.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,376 @@
+/*
+ * Copyright (c) 2014, 2016, 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.
+ */
+
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
+import java.io.ByteArrayOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class OptionModesTester {
+
+    /** Marker annotation for test methods to be invoked by runTests. */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface Test { }
+
+    /**
+     * Run all methods annotated with @Test, and throw an exception if any
+     * errors are reported..
+     * Typically called on a tester object in main()
+     * @throws Exception if any errors occurred
+     */
+    void runTests() throws Exception {
+        for (Method m: getClass().getDeclaredMethods()) {
+            Annotation a = m.getAnnotation(Test.class);
+            if (a != null) {
+                try {
+                    out.println("Running test " + m.getName());
+                    m.invoke(this);
+                } catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
+                }
+                out.println();
+            }
+        }
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    TestResult runMain(String[] opts, String[] files) {
+        out.println("Main " + Arrays.toString(opts) + " " + Arrays.toString(files));
+        return run(new TestResult(opts), (tr, c, pw) -> {
+            com.sun.tools.javac.main.Main compiler =
+                new com.sun.tools.javac.main.Main("javac", pw);
+            int rc = compiler.compile(join(opts, files), c).exitCode;
+            tr.setResult(rc);
+        });
+    }
+
+    TestResult runCall(String[] opts, String[] files) {
+        out.println("Call " + Arrays.toString(opts) + " " + Arrays.toString(files));
+        return run(new TestResult(opts), (tr, c, pw) -> {
+            boolean ok = JavacTool.create()
+                    .getTask(pw, null, null, Arrays.asList(opts), null, getFiles(files), c)
+                    .call();
+            tr.setResult(ok);
+        });
+    }
+
+    TestResult runParse(String[] opts, String[] files) {
+        out.println("Parse " + Arrays.toString(opts) + " " + Arrays.toString(files));
+        return run(new TestResult(opts), (tr, c, pw) -> {
+            JavacTool.create()
+                    .getTask(pw, null, null, Arrays.asList(opts), null, getFiles(files), c)
+                    .parse();
+            tr.setResult(true);
+        });
+    }
+
+    TestResult runAnalyze(String[] opts, String[] files) {
+        out.println("Analyze " + Arrays.toString(opts) + " " + Arrays.toString(files));
+        return run(new TestResult(opts), (tr, c, pw) -> {
+            JavacTool.create()
+                    .getTask(pw, null, null, Arrays.asList(opts), null, getFiles(files), c)
+                    .analyze();
+            tr.setResult(true);
+        });
+    }
+
+    interface Runnable {
+        void run(TestResult tr, Context c, PrintWriter pw) throws IOException;
+    }
+
+    TestResult run(TestResult tr, Runnable r) {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        StreamOutput sysOut = new StreamOutput(System.out, System::setOut);
+        StreamOutput sysErr = new StreamOutput(System.err, System::setErr);
+        Context context = new Context();
+        JavacFileManager.preRegister(context);
+        try {
+            r.run(tr, context, pw);
+        } catch (IllegalArgumentException | IllegalStateException | IOException e) {
+            tr.setThrown(e);
+        } finally {
+            try {
+                ((JavacFileManager) context.get(JavaFileManager.class)).close();
+            } catch (IOException e) {
+                throw new UncheckedIOException(e);
+            }
+            tr.setLogs(sw.toString(), sysOut.close(), sysErr.close());
+        }
+        tr.setContext(context);
+        tr.show();
+        return tr;
+    }
+
+    enum Log { DIRECT, STDOUT, STDERR };
+
+    class TestResult {
+        final List<String> args;
+        Throwable thrown;
+        List<Throwable> suppressed = new ArrayList<>();
+        Object rc; // Number or Boolean
+        Map<Log, String> logs;
+        Context context;
+
+        TestResult(String... args) {
+            this.args = Arrays.asList(args);
+        }
+
+        TestResult(List<String> args, Iterable<? extends JavaFileObject> files) {
+            this.args = new ArrayList<>();
+            this.args.addAll(args);
+            for (JavaFileObject f: files)
+                this.args.add(f.getName());
+        }
+
+        void setResult(int rc) {
+            this.rc = rc;
+        }
+
+        void setResult(boolean ok) {
+            this.rc = ok ? 0 : 1;
+        }
+
+        void setSuppressed(Throwable thrown) {
+            this.suppressed.add(thrown);
+        }
+
+        void setThrown(Throwable thrown) {
+            this.thrown = thrown;
+        }
+
+        void setLogs(String direct, String stdOut, String stdErr) {
+            logs = new EnumMap<>(Log.class);
+            logs.put(Log.DIRECT, direct);
+            logs.put(Log.STDOUT, stdOut);
+            logs.put(Log.STDERR, stdErr);
+        }
+
+        void setContext(Context context) {
+            this.context = context;
+        }
+
+        final void show() {
+            String NL = System.getProperty("line.separator");
+            boolean needSep = false;
+            if (rc != null) {
+                out.print("rc:" + rc);
+                needSep = true;
+            }
+            if (thrown != null) {
+                if (needSep) out.print("; ");
+                out.print("thrown:" + thrown);
+                needSep = true;
+            }
+            if (!suppressed.isEmpty()) {
+                if (needSep) out.print("; ");
+                out.print("suppressed:" + suppressed);
+                needSep = true;
+            }
+            if (needSep)
+                out.println();
+            logs.forEach((k, v) -> {
+                if (!v.isEmpty()) {
+                    out.println("javac/" + k + ":");
+                    if (v.endsWith(NL))
+                        out.print(v);
+                    else
+                        out.println(v);
+                }
+
+            });
+        }
+
+        TestResult checkOK() {
+            if (thrown != null) {
+                error("unexpected exception thrown: " + thrown);
+            } else if (rc == null) {
+                error("no result set");
+            } else if (rc != (Integer) 0 && rc != (Boolean) true) {
+                error("compilation failed unexpectedly; rc=" + rc);
+            }
+            return this;
+        }
+
+        TestResult checkResult(int expect) {
+            if (thrown != null) {
+                error("unexpected exception thrown: " + thrown);
+            } else if (rc != (Integer) expect) {
+                error("unexpected result: " + rc +", expected:" + expect);
+            }
+            return this;
+        }
+
+        TestResult checkResult(boolean expect) {
+            if (thrown != null) {
+                error("unexpected exception thrown: " + thrown);
+            } else if (rc != (Integer) (expect ? 0 : 1)) {
+                error("unexpected result: " + rc +", expected:" + expect);
+            }
+            return this;
+        }
+
+        TestResult checkLog(String... expects) {
+            return checkLog(Log.DIRECT, expects);
+        }
+
+        TestResult checkLog(Log l, String... expects) {
+            for (String e: expects) {
+                if (!logs.get(l).contains(e))
+                    error("expected string not found: " + e);
+            }
+            return this;
+        }
+
+        TestResult checkIllegalArgumentException() {
+            return checkThrown(IllegalArgumentException.class);
+        }
+
+        TestResult checkIllegalStateException() {
+            return checkThrown(IllegalStateException.class);
+        }
+
+        TestResult checkThrown(Class<? extends Throwable> t) {
+            if (thrown == null)
+                error("expected exception not thrown: " + t);
+            else if (!t.isAssignableFrom(thrown.getClass()))
+                error("unexpected exception thrown: " + thrown + ";  expected: " + t);
+            return this;
+        }
+
+        TestResult checkClass(String name) {
+            Path p = getOutDir().resolve(name.replace(".", "/") + ".class");
+            if (!Files.exists(p))
+                error("expected class not found: " + name + " (" + p + ")");
+            return this;
+        }
+
+        Path getOutDir() {
+            Iterator<String> iter = args.iterator();
+            while (iter.hasNext()) {
+                if (iter.next().equals("-d")) {
+                    return Paths.get(iter.next());
+                }
+            }
+            return null;
+        }
+    }
+
+    /**
+     * Utility class to simplify the handling of temporarily setting a
+     * new stream for System.out or System.err.
+     */
+    private static class StreamOutput {
+        // functional interface to set a stream.
+        private interface Initializer {
+            void set(PrintStream s);
+        }
+
+        private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        private final PrintStream ps = new PrintStream(baos);
+        private final PrintStream prev;
+        private final Initializer init;
+
+        StreamOutput(PrintStream s, Initializer init) {
+            prev = s;
+            init.set(ps);
+            this.init = init;
+        }
+
+        String close() {
+            init.set(prev);
+            ps.close();
+            return baos.toString();
+        }
+    }
+
+    List<JavaFileObject> getFiles(String... paths) {
+        List<JavaFileObject> files = new ArrayList<>();
+        for (JavaFileObject f : fm.getJavaFileObjects(paths))
+            files.add(f);
+        return files;
+    }
+
+    String toString(List<JavaFileObject> files) {
+        return files.stream().map(f -> f.getName()).collect(Collectors.toList()).toString();
+    }
+
+    void mkdirs(String path) throws IOException {
+        Files.createDirectories(Paths.get(path));
+    }
+
+    void writeFile(String path, String body) throws IOException {
+        Path p = Paths.get(path);
+        if (p.getParent() != null)
+            Files.createDirectories(p.getParent());
+        try (FileWriter w = new FileWriter(path)) {
+            w.write(body);
+        }
+    }
+
+    String[] join(String[] a, String[] b) {
+        String[] result = new String[a.length + b.length];
+        System.arraycopy(a, 0, result, 0, a.length);
+        System.arraycopy(b, 0, result, a.length, b.length);
+        return result;
+    }
+
+    void error(String message) {
+        out.print(">>>>> ");
+        out.println(message);
+        errors++;
+    }
+
+    StandardJavaFileManager fm =
+            ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
+    PrintStream out = System.err;
+    int errors;
+
+}
--- a/langtools/test/tools/javac/options/modes/OutputDirTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/OutputDirTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,14 +29,14 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main OutputDirTest
  */
 
 import com.sun.tools.javac.main.Main;
 import java.io.IOException;
 
-public class OutputDirTest extends Tester {
+public class OutputDirTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         OutputDirTest t = new OutputDirTest();
         t.writeFile("src/C.java", "class C { }");
--- a/langtools/test/tools/javac/options/modes/ProfileBootClassPathTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/ProfileBootClassPathTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,7 +29,7 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main ProfileBootClassPathTest
  */
 
@@ -37,13 +37,13 @@
 import java.io.File;
 import java.io.IOException;
 
-public class ProfileBootClassPathTest extends Tester {
+public class ProfileBootClassPathTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         ProfileBootClassPathTest t = new ProfileBootClassPathTest();
         t.runTests();
     }
 
-    @Tester.Test
+    @OptionModesTester.Test
     void testProfileBootClassPath() throws IOException {
         writeFile("C.java", "class C { }");
 
--- a/langtools/test/tools/javac/options/modes/ProfileTargetTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/ProfileTargetTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,14 +29,14 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main ProfileTargetTest
  */
 
 import com.sun.tools.javac.main.Main;
 import java.io.IOException;
 
-public class ProfileTargetTest extends Tester {
+public class ProfileTargetTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         ProfileTargetTest t = new ProfileTargetTest();
         t.runTests();
--- a/langtools/test/tools/javac/options/modes/SourceTargetTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/SourceTargetTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,14 +29,14 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main SourceTargetTest
  */
 
 import com.sun.tools.javac.main.Main;
 import java.io.IOException;
 
-public class SourceTargetTest extends Tester {
+public class SourceTargetTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         SourceTargetTest t = new SourceTargetTest();
         t.runTests();
--- a/langtools/test/tools/javac/options/modes/StdOutTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/options/modes/StdOutTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -29,7 +29,7 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.javac.util
- * @build Tester
+ * @build OptionModesTester
  * @run main StdOutTest
  */
 
@@ -38,7 +38,7 @@
 import java.nio.file.Files;
 import java.nio.file.Paths;
 
-public class StdOutTest extends Tester {
+public class StdOutTest extends OptionModesTester {
     public static void main(String... args) throws Exception {
         StdOutTest t = new StdOutTest();
         t.writeFile("src/Bad.java", "class Bad");
--- a/langtools/test/tools/javac/options/modes/Tester.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,376 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.
- */
-
-import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.util.Context;
-import java.io.ByteArrayOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.UncheckedIOException;
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.EnumMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-public class Tester {
-
-    /** Marker annotation for test methods to be invoked by runTests. */
-    @Retention(RetentionPolicy.RUNTIME)
-    @interface Test { }
-
-    /**
-     * Run all methods annotated with @Test, and throw an exception if any
-     * errors are reported..
-     * Typically called on a tester object in main()
-     * @throws Exception if any errors occurred
-     */
-    void runTests() throws Exception {
-        for (Method m: getClass().getDeclaredMethods()) {
-            Annotation a = m.getAnnotation(Test.class);
-            if (a != null) {
-                try {
-                    out.println("Running test " + m.getName());
-                    m.invoke(this);
-                } catch (InvocationTargetException e) {
-                    Throwable cause = e.getCause();
-                    throw (cause instanceof Exception) ? ((Exception) cause) : e;
-                }
-                out.println();
-            }
-        }
-        if (errors > 0)
-            throw new Exception(errors + " errors occurred");
-    }
-
-    TestResult runMain(String[] opts, String[] files) {
-        out.println("Main " + Arrays.toString(opts) + " " + Arrays.toString(files));
-        return run(new TestResult(opts), (tr, c, pw) -> {
-            com.sun.tools.javac.main.Main compiler =
-                new com.sun.tools.javac.main.Main("javac", pw);
-            int rc = compiler.compile(join(opts, files), c).exitCode;
-            tr.setResult(rc);
-        });
-    }
-
-    TestResult runCall(String[] opts, String[] files) {
-        out.println("Call " + Arrays.toString(opts) + " " + Arrays.toString(files));
-        return run(new TestResult(opts), (tr, c, pw) -> {
-            boolean ok = JavacTool.create()
-                    .getTask(pw, null, null, Arrays.asList(opts), null, getFiles(files), c)
-                    .call();
-            tr.setResult(ok);
-        });
-    }
-
-    TestResult runParse(String[] opts, String[] files) {
-        out.println("Parse " + Arrays.toString(opts) + " " + Arrays.toString(files));
-        return run(new TestResult(opts), (tr, c, pw) -> {
-            JavacTool.create()
-                    .getTask(pw, null, null, Arrays.asList(opts), null, getFiles(files), c)
-                    .parse();
-            tr.setResult(true);
-        });
-    }
-
-    TestResult runAnalyze(String[] opts, String[] files) {
-        out.println("Analyze " + Arrays.toString(opts) + " " + Arrays.toString(files));
-        return run(new TestResult(opts), (tr, c, pw) -> {
-            JavacTool.create()
-                    .getTask(pw, null, null, Arrays.asList(opts), null, getFiles(files), c)
-                    .analyze();
-            tr.setResult(true);
-        });
-    }
-
-    interface Runnable {
-        void run(TestResult tr, Context c, PrintWriter pw) throws IOException;
-    }
-
-    TestResult run(TestResult tr, Runnable r) {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        StreamOutput sysOut = new StreamOutput(System.out, System::setOut);
-        StreamOutput sysErr = new StreamOutput(System.err, System::setErr);
-        Context context = new Context();
-        JavacFileManager.preRegister(context);
-        try {
-            r.run(tr, context, pw);
-        } catch (IllegalArgumentException | IllegalStateException | IOException e) {
-            tr.setThrown(e);
-        } finally {
-            try {
-                ((JavacFileManager) context.get(JavaFileManager.class)).close();
-            } catch (IOException e) {
-                throw new UncheckedIOException(e);
-            }
-            tr.setLogs(sw.toString(), sysOut.close(), sysErr.close());
-        }
-        tr.setContext(context);
-        tr.show();
-        return tr;
-    }
-
-    enum Log { DIRECT, STDOUT, STDERR };
-
-    class TestResult {
-        final List<String> args;
-        Throwable thrown;
-        List<Throwable> suppressed = new ArrayList<>();
-        Object rc; // Number or Boolean
-        Map<Log, String> logs;
-        Context context;
-
-        TestResult(String... args) {
-            this.args = Arrays.asList(args);
-        }
-
-        TestResult(List<String> args, Iterable<? extends JavaFileObject> files) {
-            this.args = new ArrayList<>();
-            this.args.addAll(args);
-            for (JavaFileObject f: files)
-                this.args.add(f.getName());
-        }
-
-        void setResult(int rc) {
-            this.rc = rc;
-        }
-
-        void setResult(boolean ok) {
-            this.rc = ok ? 0 : 1;
-        }
-
-        void setSuppressed(Throwable thrown) {
-            this.suppressed.add(thrown);
-        }
-
-        void setThrown(Throwable thrown) {
-            this.thrown = thrown;
-        }
-
-        void setLogs(String direct, String stdOut, String stdErr) {
-            logs = new EnumMap<>(Log.class);
-            logs.put(Log.DIRECT, direct);
-            logs.put(Log.STDOUT, stdOut);
-            logs.put(Log.STDERR, stdErr);
-        }
-
-        void setContext(Context context) {
-            this.context = context;
-        }
-
-        final void show() {
-            String NL = System.getProperty("line.separator");
-            boolean needSep = false;
-            if (rc != null) {
-                out.print("rc:" + rc);
-                needSep = true;
-            }
-            if (thrown != null) {
-                if (needSep) out.print("; ");
-                out.print("thrown:" + thrown);
-                needSep = true;
-            }
-            if (!suppressed.isEmpty()) {
-                if (needSep) out.print("; ");
-                out.print("suppressed:" + suppressed);
-                needSep = true;
-            }
-            if (needSep)
-                out.println();
-            logs.forEach((k, v) -> {
-                if (!v.isEmpty()) {
-                    out.println("javac/" + k + ":");
-                    if (v.endsWith(NL))
-                        out.print(v);
-                    else
-                        out.println(v);
-                }
-
-            });
-        }
-
-        TestResult checkOK() {
-            if (thrown != null) {
-                error("unexpected exception thrown: " + thrown);
-            } else if (rc == null) {
-                error("no result set");
-            } else if (rc != (Integer) 0 && rc != (Boolean) true) {
-                error("compilation failed unexpectedly; rc=" + rc);
-            }
-            return this;
-        }
-
-        TestResult checkResult(int expect) {
-            if (thrown != null) {
-                error("unexpected exception thrown: " + thrown);
-            } else if (rc != (Integer) expect) {
-                error("unexpected result: " + rc +", expected:" + expect);
-            }
-            return this;
-        }
-
-        TestResult checkResult(boolean expect) {
-            if (thrown != null) {
-                error("unexpected exception thrown: " + thrown);
-            } else if (rc != (Integer) (expect ? 0 : 1)) {
-                error("unexpected result: " + rc +", expected:" + expect);
-            }
-            return this;
-        }
-
-        TestResult checkLog(String... expects) {
-            return checkLog(Log.DIRECT, expects);
-        }
-
-        TestResult checkLog(Log l, String... expects) {
-            for (String e: expects) {
-                if (!logs.get(l).contains(e))
-                    error("expected string not found: " + e);
-            }
-            return this;
-        }
-
-        TestResult checkIllegalArgumentException() {
-            return checkThrown(IllegalArgumentException.class);
-        }
-
-        TestResult checkIllegalStateException() {
-            return checkThrown(IllegalStateException.class);
-        }
-
-        TestResult checkThrown(Class<? extends Throwable> t) {
-            if (thrown == null)
-                error("expected exception not thrown: " + t);
-            else if (!t.isAssignableFrom(thrown.getClass()))
-                error("unexpected exception thrown: " + thrown + ";  expected: " + t);
-            return this;
-        }
-
-        TestResult checkClass(String name) {
-            Path p = getOutDir().resolve(name.replace(".", "/") + ".class");
-            if (!Files.exists(p))
-                error("expected class not found: " + name + " (" + p + ")");
-            return this;
-        }
-
-        Path getOutDir() {
-            Iterator<String> iter = args.iterator();
-            while (iter.hasNext()) {
-                if (iter.next().equals("-d")) {
-                    return Paths.get(iter.next());
-                }
-            }
-            return null;
-        }
-    }
-
-    /**
-     * Utility class to simplify the handling of temporarily setting a
-     * new stream for System.out or System.err.
-     */
-    private static class StreamOutput {
-        // functional interface to set a stream.
-        private interface Initializer {
-            void set(PrintStream s);
-        }
-
-        private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        private final PrintStream ps = new PrintStream(baos);
-        private final PrintStream prev;
-        private final Initializer init;
-
-        StreamOutput(PrintStream s, Initializer init) {
-            prev = s;
-            init.set(ps);
-            this.init = init;
-        }
-
-        String close() {
-            init.set(prev);
-            ps.close();
-            return baos.toString();
-        }
-    }
-
-    List<JavaFileObject> getFiles(String... paths) {
-        List<JavaFileObject> files = new ArrayList<>();
-        for (JavaFileObject f : fm.getJavaFileObjects(paths))
-            files.add(f);
-        return files;
-    }
-
-    String toString(List<JavaFileObject> files) {
-        return files.stream().map(f -> f.getName()).collect(Collectors.toList()).toString();
-    }
-
-    void mkdirs(String path) throws IOException {
-        Files.createDirectories(Paths.get(path));
-    }
-
-    void writeFile(String path, String body) throws IOException {
-        Path p = Paths.get(path);
-        if (p.getParent() != null)
-            Files.createDirectories(p.getParent());
-        try (FileWriter w = new FileWriter(path)) {
-            w.write(body);
-        }
-    }
-
-    String[] join(String[] a, String[] b) {
-        String[] result = new String[a.length + b.length];
-        System.arraycopy(a, 0, result, 0, a.length);
-        System.arraycopy(b, 0, result, a.length, b.length);
-        return result;
-    }
-
-    void error(String message) {
-        out.print(">>>>> ");
-        out.println(message);
-        errors++;
-    }
-
-    StandardJavaFileManager fm =
-            ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null);
-    PrintStream out = System.err;
-    int errors;
-
-}
--- a/langtools/test/tools/javac/platform/PlatformProviderTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/platform/PlatformProviderTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -97,10 +97,9 @@
         Task.Result result =
                 new JavacTask(tb, Task.Mode.EXEC)
                   .outdir(".")
-                  .options("-J-classpath",
-                           "-J" + System.getProperty("test.classes"),
-                           "-J-XaddExports:jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED",
-                           "-J-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                  .options("-J--class-path=" + System.getProperty("test.classes"),
+                           "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED",
+                           "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                            "-XDrawDiagnostics",
                            "-release",
                            platformSpec,
@@ -133,10 +132,9 @@
         Task.Result result =
                 new JavacTask(tb, Task.Mode.EXEC)
                   .outdir(".")
-                  .options("-J-classpath",
-                           "-J" + System.getProperty("test.classes"),
-                           "-J-XaddExports:jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED",
-                           "-J-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                  .options("-J--class-path=" + System.getProperty("test.classes"),
+                           "-J--add-exports=jdk.compiler/com.sun.tools.javac.platform=ALL-UNNAMED",
+                           "-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                            "-release",
                            "fail",
                            System.getProperty("test.src") + "/PlatformProviderTestSource.java")
--- a/langtools/test/tools/javac/processing/T8142931.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/processing/T8142931.java	Fri Aug 19 12:17:32 2016 -0700
@@ -54,12 +54,12 @@
         try (StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null)) {
             Iterable<? extends JavaFileObject> files =
                 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T8142931.class.getName()+".java")));
-            Iterable<String> opts = Arrays.asList("-XaddExports:" +
-                                                  "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                                                  "-XDaccessInternalAPI",
-                                                  "-proc:only",
-                                                  "-processor", "T8142931",
-                                                  "-processorpath", testClasses);
+            Iterable<String> opts = Arrays.asList(
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "-XDaccessInternalAPI",
+                "-proc:only",
+                "-processor", "T8142931",
+                "-processorpath", testClasses);
             StringWriter out = new StringWriter();
             JavacTask task = (JavacTask)tool.getTask(out, fm, dl, opts, null, files);
             task.call();
--- a/langtools/test/tools/javac/processing/loader/testClose/TestClose.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose.java	Fri Aug 19 12:17:32 2016 -0700
@@ -132,8 +132,8 @@
                         new MemFile("AnnoProc.java", annoProc),
                         new MemFile("Callback.java", callback));
                 List<String> options = Arrays.asList(
-                        "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
-                        "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                        "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+                        "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                         "-XDaccessInternalAPI");
                 JavacTask task = tool.getTask(null, fm, null, options, null, files);
                 check(task.call());
--- a/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java	Fri Aug 19 12:17:32 2016 -0700
@@ -92,9 +92,9 @@
         Iterable<? extends JavaFileObject> files =
                 fm.getJavaFileObjects(new File(testSrc, TestClose2.class.getName() + ".java"));
         List<String> options = Arrays.asList(
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
-                "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
+                "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                 "-processor", TestClose2.class.getName());
 
         JavacTask task = tool.getTask(null, fm, null, options, null, files);
--- a/langtools/test/tools/javac/processing/messager/MessagerDiags.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/processing/messager/MessagerDiags.java	Fri Aug 19 12:17:32 2016 -0700
@@ -80,7 +80,6 @@
     }
 
     public static void main(String... args) throws IOException {
-        final String bootPath = System.getProperty("sun.boot.class.path");
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         assert tool != null;
 
--- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -64,7 +64,7 @@
     static JavacTask javac;
     static Elements elements;
 
-    static List<String> addmods_ALL_SYSTEM = Arrays.asList("-addmods", "ALL-SYSTEM");
+    static List<String> addmods_ALL_SYSTEM = Arrays.asList("--add-modules", "ALL-SYSTEM");
 
     public static void main(String[] args) throws Exception {
         JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
--- a/langtools/test/tools/javac/util/T6597678.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/util/T6597678.java	Fri Aug 19 12:17:32 2016 -0700
@@ -59,8 +59,8 @@
         PrintWriter pw = new PrintWriter(sw);
 
         compile(sw, pw,
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
-            "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+            "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
             "-XDaccessInternalAPI",
             "-proc:only",
             "-processor", myName,
--- a/langtools/test/tools/javac/warnings/suppress/T6480588.out	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javac/warnings/suppress/T6480588.out	Fri Aug 19 12:17:32 2016 -0700
@@ -8,6 +8,7 @@
 T6480588.java:19:9: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
 T6480588.java:19:34: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
 T6480588.java:21:9: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
+T6480588.java:21:25: compiler.warn.deprecated.annotation.has.no.effect: kindname.variable
 T6480588.java:21:35: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
 T6480588.java:30:5: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
 T6480588.java:29:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
@@ -15,4 +16,4 @@
 T6480588.java:33:25: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
 T6480588.java:33:52: compiler.warn.has.been.deprecated: DeprecatedInterface, compiler.misc.unnamed.package
 T6480588.java:32:6: compiler.warn.has.been.deprecated: DeprecatedAnnotation, compiler.misc.unnamed.package
-17 warnings
+18 warnings
--- a/langtools/test/tools/javadoc/6964914/TestStdDoclet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/6964914/TestStdDoclet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -47,8 +47,6 @@
      */
     void run() throws Exception {
         File javaHome = new File(System.getProperty("java.home"));
-        if (javaHome.getName().equals("jre"))
-            javaHome = javaHome.getParentFile();
         File javadoc = new File(new File(javaHome, "bin"), "javadoc");
         File testSrc = new File(System.getProperty("test.src"));
 
@@ -57,11 +55,6 @@
         String thisClassName = TestStdDoclet.class.getName();
         List<String> cmdArgs = new ArrayList<>();
         cmdArgs.add(javadoc.getPath());
-        int i = 0;
-        String prop;
-        while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) {
-            cmdArgs.add("-J-Xpatch:" + prop);
-        }
         cmdArgs.addAll(Arrays.asList(
                 "-classpath", ".", // insulates us from ambient classpath
                 "-Xdoclint:none",
--- a/langtools/test/tools/javadoc/6964914/TestUserDoclet.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/6964914/TestUserDoclet.java	Fri Aug 19 12:17:32 2016 -0700
@@ -59,11 +59,6 @@
         String thisClassName = TestUserDoclet.class.getName();
         List<String> cmdArgs = new ArrayList<>();
         cmdArgs.add(javadoc.getPath());
-        int i = 0;
-        String prop;
-        while ((prop = System.getProperty("jdk.launcher.patch." + (i++))) != null) {
-            cmdArgs.add("-J-Xpatch:" + prop);
-        }
         cmdArgs.addAll(Arrays.asList(
                 "-doclet", thisClassName,
                 "-docletpath", testClasses.getPath(),
--- a/langtools/test/tools/javadoc/CheckResourceKeys.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/CheckResourceKeys.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -121,7 +121,7 @@
             if (codeKeys.contains(rk))
                 continue;
 
-            error("Resource key not found in code: " + rk);
+            error("Resource key not found in code: '" + rk + "'");
         }
     }
 
--- a/langtools/test/tools/javadoc/ReleaseOption.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/ReleaseOption.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, 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
@@ -21,7 +21,7 @@
  * questions.
  */
 
-import com.sun.tools.javadoc.Main;
+import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.ArrayList;
@@ -29,6 +29,8 @@
 import java.util.List;
 import java.util.function.Predicate;
 
+import com.sun.tools.javadoc.Main;
+
 /**
  * @test
  * @bug 8086737
@@ -52,16 +54,16 @@
         List<String> options = new ArrayList<>();
         options.addAll(Arrays.asList(args));
         options.add("-XDrawDiagnostics");
-        options.add(System.getProperty("test.src", ".") + java.io.File.separatorChar + "ReleaseOptionSource.java");
+        options.add(new File(System.getProperty("test.src", "."), "ReleaseOptionSource.java").getPath());
         StringWriter out = new StringWriter();
         PrintWriter pw = new PrintWriter(out);
         int actualResult = Main.execute("javadoc", pw, pw, pw, "com.sun.tools.doclets.formats.html.HtmlDoclet", options.toArray(new String[0]));
         System.err.println("actual result=" + actualResult);
         System.err.println("actual output=" + out.toString());
         if (actualResult != expectedResult)
-            throw new Error();
+            throw new Error("Exit code not as expected");
         if (!validate.test(out.toString())) {
-            throw new Error("Not an expected error output: " + out.toString());
+            throw new Error("Output not as expected");
         }
     }
 }
--- a/langtools/test/tools/javadoc/annotations/annotateMethodsFields/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/annotateMethodsFields/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -29,16 +29,16 @@
  *          Test an annotation type with a type nested within.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/annotations/annotatePackage/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/annotatePackage/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Test package annotations and package-info.java package comments.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.*;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1", "pkg2");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1", "pkg2");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/annotations/annotateParams/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/annotateParams/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Test parameter annotations.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/annotations/badVals/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/badVals/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2016, 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
@@ -32,9 +32,9 @@
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/annotations/defaults/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/defaults/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -28,7 +28,7 @@
  *          annotations that use them.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
@@ -36,9 +36,9 @@
 import com.sun.javadoc.*;
 import com.sun.javadoc.AnnotationDesc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/annotations/elementTypes/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/elementTypes/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -28,7 +28,7 @@
  *          types.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
@@ -37,9 +37,9 @@
 import com.sun.javadoc.*;
 import com.sun.javadoc.AnnotationDesc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/annotations/missing/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/missing/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -34,9 +34,9 @@
 import com.sun.javadoc.ClassDoc;
 import com.sun.javadoc.AnnotationDesc;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "somepackage");
+    private static final OldToolTester tester = new OldToolTester("Main", "somepackage");
 
     public static void main(String... args) throws Exception {
         tester.run();
--- a/langtools/test/tools/javadoc/annotations/shortcuts/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/annotations/shortcuts/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify that "shortcuts" are used when printing annotations.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/enum/docComments/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/enum/docComments/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,17 +27,17 @@
  * @summary Verify the comments in an enum type.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester =
-            new Tester("Main", "-package", "pkg1");
+    private static final OldToolTester tester =
+            new OldToolTester("Main", "-package", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/enum/enumType/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/enum/enumType/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the contents of an enum type.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/genericClass/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/genericClass/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the contents of the ClassDoc of a generic class.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/genericInnerAndOuter/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/genericInnerAndOuter/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -28,7 +28,7 @@
  *          a generic class with a generic inner class.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
@@ -36,9 +36,9 @@
 import java.util.Arrays;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/genericInterface/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/genericInterface/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the contents of the ClassDoc of a generic interface.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/genericMethod/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/genericMethod/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the reading of generic methods and constructors.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/genericSuper/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/genericSuper/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,7 +27,7 @@
  * @summary Verify the contents of the ClassDoc of a generic class.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
@@ -35,10 +35,10 @@
 import java.util.Arrays;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester =
-            new Tester("Main", "pkg1", "-package");
+    private static final OldToolTester tester =
+            new OldToolTester("Main", "pkg1", "-package");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/supertypes/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/supertypes/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,7 +27,7 @@
  * @summary Check supertypes and superinterfaces of parameterized types.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
@@ -36,9 +36,9 @@
 import java.util.Arrays;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/throwsGeneric/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/throwsGeneric/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the reading of generic methods and constructors.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/tparamCycle/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/tparamCycle/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Check a type parameter whose bound cycles back on itself.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/tparamTagOnMethod/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/tparamTagOnMethod/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the reading of type parameter tags on methods.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/tparamTagOnType/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/tparamTagOnType/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the reading of a type parameter tag on an interface.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javadoc/generics/wildcards/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/generics/wildcards/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -27,16 +27,16 @@
  * @summary Verify the contents of the ClassDoc of a generic class.
  * @library ../../lib
  * @modules jdk.javadoc
- * @compile  ../../lib/Tester.java Main.java
+ * @compile  ../../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester = new Tester("Main", "pkg1");
+    private static final OldToolTester tester = new OldToolTester("Main", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/lib/OldToolTester.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 2003, 2016, 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.
+ */
+
+/*
+ * A utility used to invoke and test the javadoc tool.
+ *
+ * @author Scott Seligman
+ */
+
+
+import java.io.*;
+import java.util.*;
+import com.sun.javadoc.*;
+
+
+public class OldToolTester {
+
+    protected final String TEST_SRC = System.getProperty("test.src", ".");
+    protected final String TEST_CLASSES = System.getProperty("test.classes",
+                                                             ".");
+    private final String DEFAULT_ARGS[] = {
+        "-sourcepath", TEST_SRC,
+    };
+
+    private final File outputFile = new File(TEST_CLASSES, "testrun.out");
+    private final File expectedOutputFile = new File(TEST_SRC, "expected.out");
+//  private final File bootstrapMarkerFile = new File("bootstrap");
+
+    // True if we should "set expectations" by writing the expected output file
+    // rather than reading it and comparing.
+//  private final boolean bootstrap = bootstrapMarkerFile.isFile();
+
+    private String docletName;
+    private String[] args;
+    private Writer out = null;
+
+
+    /*
+     * Individual tests can extend this to create generics-aware doclets.
+     */
+    public static abstract class Doclet extends com.sun.javadoc.Doclet {
+        public static LanguageVersion languageVersion() {
+            return LanguageVersion.JAVA_1_5;
+        }
+    }
+
+
+    public OldToolTester(String docletName) {
+        this(docletName, new String[0]);
+    }
+
+    public OldToolTester(String docletName, String... additionalArgs) {
+        this.docletName = docletName;
+
+        int len = DEFAULT_ARGS.length + additionalArgs.length;
+        args = new String[len];
+        System.arraycopy(DEFAULT_ARGS, 0, args, 0, DEFAULT_ARGS.length);
+        System.arraycopy(additionalArgs, 0, args, DEFAULT_ARGS.length,
+                         additionalArgs.length);
+
+        try {
+            out = new BufferedWriter(new FileWriter(outputFile));
+        } catch (IOException e) {
+            throw new Error("Could not open output file " + outputFile);
+        }
+    }
+
+    public void run() throws IOException {
+        try {
+            if (com.sun.tools.javadoc.Main.execute("javadoc",
+                                                   docletName,
+                                                   getClass().getClassLoader(),
+                                                   args) != 0) {
+                throw new Error("Javadoc errors encountered.");
+            }
+            System.out.println("--> Output written to " + outputFile);
+        } finally {
+            out.close();
+        }
+    }
+
+    /*
+     * Compare output of test run to expected output.
+     * Throw an Error if they don't match.
+     */
+    public void verify() throws IOException {
+        BufferedReader thisRun =
+            new BufferedReader(new FileReader(outputFile));
+        BufferedReader expected =
+            new BufferedReader(new FileReader(expectedOutputFile));
+
+        for (int lineNum = 1; true; lineNum++) {
+            String line1 = thisRun.readLine();
+            String line2 = expected.readLine();
+            if (line1 == null && line2 == null) {
+                return;         // EOF with all lines matching
+            }
+            if (line1 == null || !line1.equals(line2)) {
+                throw new Error(outputFile + ":" + lineNum +
+                                ": output doesn't match");
+            }
+        }
+    }
+
+
+    public void println(Object o) throws IOException {
+        prln(0, o);
+    }
+
+    public void println() throws IOException {
+        prln();
+    }
+
+    public void printPackage(PackageDoc p) throws IOException {
+        prPackage(0, p);
+    }
+
+    public void printClass(ClassDoc cd) throws IOException {
+        if (cd.isAnnotationType())
+            printAnnotationType((AnnotationTypeDoc)cd);
+        else
+            prClass(0, cd);
+    }
+
+    public void printAnnotationType(AnnotationTypeDoc at) throws IOException {
+        prAnnotationType(0, at);
+    }
+
+    public void printField(FieldDoc f) throws IOException {
+        prField(0, f);
+    }
+
+    public void printParameter(Parameter p) throws IOException {
+        prParameter(0, p);
+    }
+
+    public void printMethod(MethodDoc m) throws IOException {
+        prln(0, "method " + m);
+        prMethod(0, m);
+    }
+
+    public void printAnnotationTypeElement(AnnotationTypeElementDoc e)
+                                                        throws IOException {
+        prln(0, "element " + e);
+        prMethod(0, e);
+    }
+
+    public void printConstructor(ConstructorDoc c) throws IOException {
+        prln(0, "constructor " + c);
+        prExecutable(0, c);
+    }
+
+
+    private void prPackage(int off, PackageDoc p) throws IOException {
+        prln(off, "package " + p);
+        prAnnotations(off + 2, p.annotations());
+    }
+
+    private void prClass(int off, ClassDoc cd) throws IOException {
+        prln(off,
+             (cd.isInterface() ? "interface" : cd.isEnum() ? "enum" : "class")
+             + " " + cd);
+        prln(off + 2, "name: " + cd.simpleTypeName() + " / " +
+             cd.typeName() + " / " + cd.qualifiedTypeName());
+        prAnnotations(off + 2, cd.annotations());
+        prLabel(off + 2, "type parameters");
+        for (Type t : cd.typeParameters())
+            prln(off + 4, t);
+        prParamTags(off + 2, cd.typeParamTags());
+        prLabel(off + 2, "nested in");
+        prln(off + 4, cd.containingClass());
+        prLabel(off + 2, "superclass");
+        prln(off + 4, cd.superclassType());
+        prLabel(off + 2, "interfaces");
+        Type[] ts = cd.interfaceTypes();
+        Arrays.sort(ts);
+        for (Type t : ts)
+            prln(off + 4, t);
+        prLabel(off + 2, "enum constants");
+        for (FieldDoc f : cd.enumConstants())
+            prln(off + 4, f.name());
+        prLabel(off + 2, "fields");
+        for (FieldDoc f : cd.fields())
+            prln(off + 4, f.type() + " " + f.name());
+        prLabel(off + 2, "constructors");
+        for (ConstructorDoc c : cd.constructors())
+            prln(off + 4, c.name() + c.flatSignature());
+        prLabel(off + 2, "methods");
+        for (MethodDoc m : cd.methods())
+            prln(off + 4, typeUseString(m.returnType()) + " " +
+                          m.name() + m.flatSignature());
+    }
+
+    private void prAnnotationType(int off, AnnotationTypeDoc at)
+                                                        throws IOException {
+        prln(off, "@interface " + at);
+        prAnnotations(off + 2, at.annotations());
+        prLabel(off + 2, "elements");
+        for (AnnotationTypeElementDoc e : at.elements()) {
+            String def = (e.defaultValue() == null)
+                                ? ""
+                                : " default " + e.defaultValue();
+            prln(off + 4, typeUseString(e.returnType()) + " " + e.name() +
+                          e.flatSignature() + def);
+        }
+    }
+
+    private void prField(int off, FieldDoc f) throws IOException {
+        prln(off, "field " + typeUseString(f.type()) + " " + f.name());
+        prAnnotations(off + 2, f.annotations());
+    }
+
+    private void prParameter(int off, Parameter p) throws IOException {
+        prln(off, "parameter " + p);
+        prAnnotations(off + 2, p.annotations());
+    }
+
+    private void prMethod(int off, MethodDoc m) throws IOException {
+        prExecutable(off, m);
+        prLabel(off + 2, "returns");
+        prln(off + 4, typeUseString(m.returnType()));
+        prLabel(off + 2, "overridden type");
+        prln(off + 4, m.overriddenType());
+    }
+
+    private void prExecutable(int off, ExecutableMemberDoc m)
+                                                        throws IOException {
+        if (!m.isAnnotationTypeElement()) {
+            prln(off + 2, "signature: " + m.flatSignature());
+            prln(off + 2, "           " + m.signature());
+        }
+        prAnnotations(off + 2, m.annotations());
+        prParamTags(off + 2, m.typeParamTags());
+        prParamTags(off + 2, m.paramTags());
+        prLabel(off + 2, "type parameters");
+        for (Type t : m.typeParameters())
+            prln(off + 4, t);
+        prLabel(off + 2, "throws");
+        Type[] ts = m.thrownExceptionTypes();
+        Arrays.sort(ts);
+        for (Type t : ts)
+            prln(off + 4, t);
+    }
+
+    private void prAnnotations(int off, AnnotationDesc[] as)
+                                                        throws IOException {
+        prLabel(off, "annotations");
+        for (AnnotationDesc a : as)
+            prln(off + 2, a.toString());
+    }
+
+    private void prParamTags(int off, ParamTag tags[]) throws IOException {
+        for (ParamTag tag : tags)
+            prParamTag(off, tag);
+    }
+
+    private void prParamTag(int off, ParamTag tag) throws IOException {
+        String name = tag.parameterName();
+        if (tag.isTypeParameter()) name = "<" + name + ">";
+        prln(off, "@param " + name + " " + tag.parameterComment());
+    }
+
+
+    private String typeUseString(Type t) {
+        return (t instanceof ClassDoc || t instanceof TypeVariable)
+                ? t.typeName()
+                : t.toString();
+    }
+
+
+    // Labels queued for possible printing.  Innermost is first in list.
+    List<Line> labels = new ArrayList<Line>();
+
+    // Print label if its section is nonempty.
+    void prLabel(int off, String s) {
+        while (!labels.isEmpty() && labels.get(0).off >= off)
+            labels.remove(0);
+        labels.add(0, new Line(off, s));
+    }
+
+    // Print queued labels with offsets less than "off".
+    void popLabels(int off) throws IOException {
+        while (!labels.isEmpty()) {
+            Line label = labels.remove(0);
+            if (label.off < off)
+                prln(label.off, label.o + ":");
+        }
+    }
+
+    // Print "o" at given offset.
+    void pr(int off, Object o) throws IOException {
+        popLabels(off);
+        for (int i = 0; i < off; i++)
+            out.write(' ');
+        if (o != null)
+            out.write(o.toString());
+    }
+
+    // Print "o" (if non-null) at given offset, then newline.
+    void prln(int off, Object o) throws IOException {
+        if (o != null) {
+            pr(off, o);
+            prln();
+        }
+    }
+
+    // Print newline.
+    void prln() throws IOException {
+        out.write('\n');        // don't want platform-dependent separator
+    }
+
+
+    static class Line {
+        int off;
+        Object o;
+        Line(int off, Object o) { this.off = off; this.o = o; }
+    }
+}
--- a/langtools/test/tools/javadoc/lib/Tester.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2003, 2008, 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.
- */
-
-/*
- * A utility used to invoke and test the javadoc tool.
- *
- * @author Scott Seligman
- */
-
-
-import java.io.*;
-import java.util.*;
-import com.sun.javadoc.*;
-
-
-public class Tester {
-
-    protected final String TEST_SRC = System.getProperty("test.src", ".");
-    protected final String TEST_CLASSES = System.getProperty("test.classes",
-                                                             ".");
-    private final String DEFAULT_ARGS[] = {
-        "-sourcepath", TEST_SRC,
-    };
-
-    private final File outputFile = new File(TEST_CLASSES, "testrun.out");
-    private final File expectedOutputFile = new File(TEST_SRC, "expected.out");
-//  private final File bootstrapMarkerFile = new File("bootstrap");
-
-    // True if we should "set expectations" by writing the expected output file
-    // rather than reading it and comparing.
-//  private final boolean bootstrap = bootstrapMarkerFile.isFile();
-
-    private String docletName;
-    private String[] args;
-    private Writer out = null;
-
-
-    /*
-     * Individual tests can extend this to create generics-aware doclets.
-     */
-    public static abstract class Doclet extends com.sun.javadoc.Doclet {
-        public static LanguageVersion languageVersion() {
-            return LanguageVersion.JAVA_1_5;
-        }
-    }
-
-
-    public Tester(String docletName) {
-        this(docletName, new String[0]);
-    }
-
-    public Tester(String docletName, String... additionalArgs) {
-        this.docletName = docletName;
-
-        int len = DEFAULT_ARGS.length + additionalArgs.length;
-        args = new String[len];
-        System.arraycopy(DEFAULT_ARGS, 0, args, 0, DEFAULT_ARGS.length);
-        System.arraycopy(additionalArgs, 0, args, DEFAULT_ARGS.length,
-                         additionalArgs.length);
-
-        try {
-            out = new BufferedWriter(new FileWriter(outputFile));
-        } catch (IOException e) {
-            throw new Error("Could not open output file " + outputFile);
-        }
-    }
-
-    public void run() throws IOException {
-        try {
-            if (com.sun.tools.javadoc.Main.execute("javadoc",
-                                                   docletName,
-                                                   getClass().getClassLoader(),
-                                                   args) != 0) {
-                throw new Error("Javadoc errors encountered.");
-            }
-            System.out.println("--> Output written to " + outputFile);
-        } finally {
-            out.close();
-        }
-    }
-
-    /*
-     * Compare output of test run to expected output.
-     * Throw an Error if they don't match.
-     */
-    public void verify() throws IOException {
-        BufferedReader thisRun =
-            new BufferedReader(new FileReader(outputFile));
-        BufferedReader expected =
-            new BufferedReader(new FileReader(expectedOutputFile));
-
-        for (int lineNum = 1; true; lineNum++) {
-            String line1 = thisRun.readLine();
-            String line2 = expected.readLine();
-            if (line1 == null && line2 == null) {
-                return;         // EOF with all lines matching
-            }
-            if (line1 == null || !line1.equals(line2)) {
-                throw new Error(outputFile + ":" + lineNum +
-                                ": output doesn't match");
-            }
-        }
-    }
-
-
-    public void println(Object o) throws IOException {
-        prln(0, o);
-    }
-
-    public void println() throws IOException {
-        prln();
-    }
-
-    public void printPackage(PackageDoc p) throws IOException {
-        prPackage(0, p);
-    }
-
-    public void printClass(ClassDoc cd) throws IOException {
-        if (cd.isAnnotationType())
-            printAnnotationType((AnnotationTypeDoc)cd);
-        else
-            prClass(0, cd);
-    }
-
-    public void printAnnotationType(AnnotationTypeDoc at) throws IOException {
-        prAnnotationType(0, at);
-    }
-
-    public void printField(FieldDoc f) throws IOException {
-        prField(0, f);
-    }
-
-    public void printParameter(Parameter p) throws IOException {
-        prParameter(0, p);
-    }
-
-    public void printMethod(MethodDoc m) throws IOException {
-        prln(0, "method " + m);
-        prMethod(0, m);
-    }
-
-    public void printAnnotationTypeElement(AnnotationTypeElementDoc e)
-                                                        throws IOException {
-        prln(0, "element " + e);
-        prMethod(0, e);
-    }
-
-    public void printConstructor(ConstructorDoc c) throws IOException {
-        prln(0, "constructor " + c);
-        prExecutable(0, c);
-    }
-
-
-    private void prPackage(int off, PackageDoc p) throws IOException {
-        prln(off, "package " + p);
-        prAnnotations(off + 2, p.annotations());
-    }
-
-    private void prClass(int off, ClassDoc cd) throws IOException {
-        prln(off,
-             (cd.isInterface() ? "interface" : cd.isEnum() ? "enum" : "class")
-             + " " + cd);
-        prln(off + 2, "name: " + cd.simpleTypeName() + " / " +
-             cd.typeName() + " / " + cd.qualifiedTypeName());
-        prAnnotations(off + 2, cd.annotations());
-        prLabel(off + 2, "type parameters");
-        for (Type t : cd.typeParameters())
-            prln(off + 4, t);
-        prParamTags(off + 2, cd.typeParamTags());
-        prLabel(off + 2, "nested in");
-        prln(off + 4, cd.containingClass());
-        prLabel(off + 2, "superclass");
-        prln(off + 4, cd.superclassType());
-        prLabel(off + 2, "interfaces");
-        Type[] ts = cd.interfaceTypes();
-        Arrays.sort(ts);
-        for (Type t : ts)
-            prln(off + 4, t);
-        prLabel(off + 2, "enum constants");
-        for (FieldDoc f : cd.enumConstants())
-            prln(off + 4, f.name());
-        prLabel(off + 2, "fields");
-        for (FieldDoc f : cd.fields())
-            prln(off + 4, f.type() + " " + f.name());
-        prLabel(off + 2, "constructors");
-        for (ConstructorDoc c : cd.constructors())
-            prln(off + 4, c.name() + c.flatSignature());
-        prLabel(off + 2, "methods");
-        for (MethodDoc m : cd.methods())
-            prln(off + 4, typeUseString(m.returnType()) + " " +
-                          m.name() + m.flatSignature());
-    }
-
-    private void prAnnotationType(int off, AnnotationTypeDoc at)
-                                                        throws IOException {
-        prln(off, "@interface " + at);
-        prAnnotations(off + 2, at.annotations());
-        prLabel(off + 2, "elements");
-        for (AnnotationTypeElementDoc e : at.elements()) {
-            String def = (e.defaultValue() == null)
-                                ? ""
-                                : " default " + e.defaultValue();
-            prln(off + 4, typeUseString(e.returnType()) + " " + e.name() +
-                          e.flatSignature() + def);
-        }
-    }
-
-    private void prField(int off, FieldDoc f) throws IOException {
-        prln(off, "field " + typeUseString(f.type()) + " " + f.name());
-        prAnnotations(off + 2, f.annotations());
-    }
-
-    private void prParameter(int off, Parameter p) throws IOException {
-        prln(off, "parameter " + p);
-        prAnnotations(off + 2, p.annotations());
-    }
-
-    private void prMethod(int off, MethodDoc m) throws IOException {
-        prExecutable(off, m);
-        prLabel(off + 2, "returns");
-        prln(off + 4, typeUseString(m.returnType()));
-        prLabel(off + 2, "overridden type");
-        prln(off + 4, m.overriddenType());
-    }
-
-    private void prExecutable(int off, ExecutableMemberDoc m)
-                                                        throws IOException {
-        if (!m.isAnnotationTypeElement()) {
-            prln(off + 2, "signature: " + m.flatSignature());
-            prln(off + 2, "           " + m.signature());
-        }
-        prAnnotations(off + 2, m.annotations());
-        prParamTags(off + 2, m.typeParamTags());
-        prParamTags(off + 2, m.paramTags());
-        prLabel(off + 2, "type parameters");
-        for (Type t : m.typeParameters())
-            prln(off + 4, t);
-        prLabel(off + 2, "throws");
-        Type[] ts = m.thrownExceptionTypes();
-        Arrays.sort(ts);
-        for (Type t : ts)
-            prln(off + 4, t);
-    }
-
-    private void prAnnotations(int off, AnnotationDesc[] as)
-                                                        throws IOException {
-        prLabel(off, "annotations");
-        for (AnnotationDesc a : as)
-            prln(off + 2, a.toString());
-    }
-
-    private void prParamTags(int off, ParamTag tags[]) throws IOException {
-        for (ParamTag tag : tags)
-            prParamTag(off, tag);
-    }
-
-    private void prParamTag(int off, ParamTag tag) throws IOException {
-        String name = tag.parameterName();
-        if (tag.isTypeParameter()) name = "<" + name + ">";
-        prln(off, "@param " + name + " " + tag.parameterComment());
-    }
-
-
-    private String typeUseString(Type t) {
-        return (t instanceof ClassDoc || t instanceof TypeVariable)
-                ? t.typeName()
-                : t.toString();
-    }
-
-
-    // Labels queued for possible printing.  Innermost is first in list.
-    List<Line> labels = new ArrayList<Line>();
-
-    // Print label if its section is nonempty.
-    void prLabel(int off, String s) {
-        while (!labels.isEmpty() && labels.get(0).off >= off)
-            labels.remove(0);
-        labels.add(0, new Line(off, s));
-    }
-
-    // Print queued labels with offsets less than "off".
-    void popLabels(int off) throws IOException {
-        while (!labels.isEmpty()) {
-            Line label = labels.remove(0);
-            if (label.off < off)
-                prln(label.off, label.o + ":");
-        }
-    }
-
-    // Print "o" at given offset.
-    void pr(int off, Object o) throws IOException {
-        popLabels(off);
-        for (int i = 0; i < off; i++)
-            out.write(' ');
-        if (o != null)
-            out.write(o.toString());
-    }
-
-    // Print "o" (if non-null) at given offset, then newline.
-    void prln(int off, Object o) throws IOException {
-        if (o != null) {
-            pr(off, o);
-            prln();
-        }
-    }
-
-    // Print newline.
-    void prln() throws IOException {
-        out.write('\n');        // don't want platform-dependent separator
-    }
-
-
-    static class Line {
-        int off;
-        Object o;
-        Line(int off, Object o) { this.off = off; this.o = o; }
-    }
-}
--- a/langtools/test/tools/javadoc/varArgs/Main.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javadoc/varArgs/Main.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, 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
@@ -28,17 +28,17 @@
  *          Verify that see/link tags can use "..." notation.
  * @library ../lib
  * @modules jdk.javadoc
- * @compile  ../lib/Tester.java Main.java
+ * @compile  ../lib/OldToolTester.java Main.java
  * @run main Main
  */
 
 import java.io.IOException;
 import com.sun.javadoc.*;
 
-public class Main extends Tester.Doclet {
+public class Main extends OldToolTester.Doclet {
 
-    private static final Tester tester =
-            new Tester("Main", "-Xwerror", "pkg1");
+    private static final OldToolTester tester =
+            new OldToolTester("Main", "-Xwerror", "pkg1");
 
     public static void main(String[] args) throws IOException {
         tester.run();
--- a/langtools/test/tools/javap/T7004698.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javap/T7004698.java	Fri Aug 19 12:17:32 2016 -0700
@@ -42,7 +42,7 @@
         File srcFile = new File(srcDir, T7004698.class.getSimpleName() + ".java");
         File classesDir = new File(".");
         compile("-Xjcov",
-                "-XaddExports:jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED",
+                "--add-exports", "jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED",
                 "-d", classesDir.getPath(),
                 srcFile.getPath());
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/output/JavapTester.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,389 @@
+/*
+ * Copyright (c) 2013, 2016, 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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.lang.annotation.*;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * {@code JavapTester} is an abstract test-driver that provides the logic
+ * to execute test-cases, grouped by test classes.
+ * A test class is a main class extending this class, that instantiate
+ * itself, and calls the {@link run} method, passing any command line
+ * arguments.
+ * <p>
+ * The {@code run} method, expects arguments to identify test-case classes.
+ * A test-case class is a class extending the test class, and annotated
+ * with {@code TestCase}.
+ * <p>
+ * If no test-cases are specified, the test class directory is searched for
+ * co-located test-case classes (i.e. any class extending the test class,
+ * annotated with  {@code TestCase}).
+ * <p>
+ * Besides serving to group test-cases, extending the driver allow
+ * setting up a test-case template, and possibly overwrite default
+ * test-driver behaviour.
+ */
+public abstract class JavapTester {
+
+    private static boolean debug = false;
+    private static final PrintStream out = System.err;
+    private static final PrintStream err = System.err;
+
+
+    protected void run(String... args) throws Exception {
+
+        final File classesdir = new File(System.getProperty("test.classes", "."));
+
+        String[] classNames = args;
+
+        // If no test-cases are specified, we regard all co-located classes
+        // as potential test-cases.
+        if (args.length == 0) {
+            final String pattern =  ".*\\.class";
+            final File classFiles[] = classesdir.listFiles(new FileFilter() {
+                    public boolean accept(File f) {
+                        return f.getName().matches(pattern);
+                    }
+                });
+            ArrayList<String> names = new ArrayList<String>(classFiles.length);
+            for (File f : classFiles) {
+                String fname = f.getName();
+                names.add(fname.substring(0, fname.length() -6));
+            }
+            classNames = names.toArray(new String[names.size()]);
+        } else {
+            debug = true;
+        }
+        // Test-cases must extend the driver type, and be marked
+        // @TestCase. Other arguments (classes) are ignored.
+        // Test-cases are instantiated, and thereby executed.
+        for (String clname : classNames) {
+            try {
+                final Class tclass = Class.forName(clname);
+                if  (!getClass().isAssignableFrom(tclass)) continue;
+                TestCase anno = (TestCase) tclass.getAnnotation(TestCase.class);
+                if (anno == null) continue;
+                if (!debug) {
+                    ignore i = (ignore) tclass.getAnnotation(ignore.class);
+                    if (i != null) {
+                        out.println("Ignore: " + clname);
+                        ignored++;
+                        continue;
+                    }
+                }
+                out.println("TestCase: " + clname);
+                cases++;
+                JavapTester tc = (JavapTester) tclass.getConstructor().newInstance();
+                if (tc.errors > 0) {
+                    error("" + tc.errors + " test points failed in " + clname);
+                    errors += tc.errors - 1;
+                    fcases++;
+                }
+            } catch(ReflectiveOperationException roe) {
+                error("Warning: " + clname + " - ReflectiveOperationException");
+                roe.printStackTrace(err);
+            } catch(Exception unknown) {
+                error("Warning: " + clname + " - uncaught exception");
+                unknown.printStackTrace(err);
+            }
+        }
+
+        String imsg = ignored > 0 ? " (" +  ignored + " ignored)" : "";
+        if (errors > 0)
+            throw new Error(errors + " error, in " + fcases + " of " + cases + " test-cases" + imsg);
+        else
+            err.println("" + cases + " test-cases executed" + imsg + ", no errors");
+    }
+
+
+    /**
+     * Test-cases must be marked with the {@code TestCase} annotation,
+     * as well as extend {@code JavapTester} (or an driver extension
+     * specified as the first argument to the {@code main()} method.
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface TestCase { }
+
+    /**
+     * Individual test-cases failing due to product bugs, may temporarily
+     * be excluded by marking them like this, (where "at-" is replaced by "@")
+     * at-ignore // 1234567: bug synopsis
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @interface ignore { }
+
+    /**
+     * Test-cases are classes extending {@code JavapTester}, and
+     * calling {@link setSrc}, followed by one or more invocations
+     * of {@link verify} in the body of the constructor.
+     * <p>
+     * Sets a default test-case template, which is empty except
+     * for a key of {@code "TESTCASE"}.
+     * Subclasses will typically call {@code setSrc(TestSource)}
+     * to setup a useful test-case template.
+     */
+    public JavapTester() {
+        this.testCase = this.getClass().getName();
+        src = new TestSource("TESTCASE");
+    }
+
+    /**
+     * Set the top-level source template.
+     */
+    protected JavapTester setSrc(TestSource src) {
+        this.src = src;
+        return this;
+    }
+
+    /**
+     * Convenience method for calling {@code innerSrc("TESTCASE", ...)}.
+     */
+    protected JavapTester setSrc(String... lines) {
+        return innerSrc("TESTCASE", lines);
+    }
+
+    /**
+     * Convenience method for calling {@code innerSrc(key, new TestSource(...))}.
+     */
+    protected JavapTester innerSrc(String key, String... lines) {
+        return innerSrc(key, new TestSource(lines));
+    }
+
+    /**
+     * Specialize the testcase template, setting replacement content
+     * for the specified key.
+     */
+    protected JavapTester innerSrc(String key, TestSource content) {
+        if (src == null) {
+            src = new TestSource(key);
+        }
+        src.setInner(key, content);
+        return this;
+    }
+
+    /**
+     * On the first invocation, call {@code execute()} to compile
+     * the test-case source and process the resulting class(se)
+     * into verifiable output.
+     * <p>
+     * Verify that the output matches each of the regular expressions
+     * given as argument.
+     * <p>
+     * Any failure to match constitutes a test failure, but doesn't
+     * abort the test-case.
+     * <p>
+     * Any exception (e.g. bad regular expression syntax) results in
+     * a test failure, and aborts the test-case.
+     */
+    protected void verify(String... expect) {
+        if (!didExecute) {
+            try {
+                execute();
+            } catch(Exception ue) {
+                throw new Error(ue);
+            } finally {
+                didExecute = true;
+            }
+        }
+        if (output == null) {
+            error("output is null");
+            return;
+        }
+        for (String e: expect) {
+            // Escape regular expressions (to allow input to be literals).
+            // Notice, characters to be escaped are themselves identified
+            // using regular expressions
+            String rc[] = { "(", ")", "[", "]", "{", "}", "$" };
+            for (String c : rc) {
+                e = e.replace(c, "\\" + c);
+            }
+            // DEBUG: Uncomment this to test modulo constant pool index.
+            // e = e.replaceAll("#[0-9]{2}", "#[0-9]{2}");
+            if (!output.matches("(?s).*" + e + ".*")) {
+                if (!didPrint) {
+                    out.println(output);
+                    didPrint = true;
+                }
+                error("not matched: '" + e + "'");
+            } else if(debug) {
+                out.println("matched: '" + e + "'");
+            }
+        }
+    }
+
+    /**
+     * Calls {@code writeTestFile()} to write out the test-case source
+     * content to a file, then call {@code compileTestFile()} to
+     * compile it, and finally run the {@link process} method to produce
+     * verifiable output. The default {@code process} method runs javap.
+     * <p>
+     * If an exception occurs, it results in a test failure, and
+     * aborts the test-case.
+     */
+    protected void execute() throws IOException {
+        err.println("TestCase: " + testCase);
+        writeTestFile();
+        compileTestFile();
+        process();
+    }
+
+    /**
+     * Generate java source from test-case.
+     * TBD: change to use javaFileObject, possibly make
+     * this class extend JavaFileObject.
+     */
+    protected void writeTestFile() throws IOException {
+        javaFile = new File("Test.java");
+        FileWriter fw = new FileWriter(javaFile);
+        BufferedWriter bw = new BufferedWriter(fw);
+        PrintWriter pw = new PrintWriter(bw);
+        for (String line : src) {
+            pw.println(line);
+            if (debug) out.println(line);
+        }
+        pw.close();
+    }
+
+    /**
+     * Compile the Java source code.
+     */
+    protected void compileTestFile() {
+        String path = javaFile.getPath();
+        String params[] =  {"-g", path };
+        int rc = com.sun.tools.javac.Main.compile(params);
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        classFile = new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+
+    /**
+     * Process class file to generate output for verification.
+     * The default implementation simply runs javap. This might be
+     * overwritten to generate output in a different manner.
+     */
+    protected void process() {
+        String testClasses = "."; //System.getProperty("test.classes", ".");
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String[] args = { "-v", "-classpath", testClasses, "Test" };
+        int rc = com.sun.tools.javap.Main.run(args, pw);
+        if (rc != 0)
+            throw new Error("javap failed. rc=" + rc);
+        pw.close();
+        output = sw.toString();
+        if (debug) {
+            out.println(output);
+            didPrint = true;
+        }
+
+    }
+
+
+    private String testCase;
+    private TestSource src;
+    private File javaFile = null;
+    private File classFile = null;
+    private String output = null;
+    private boolean didExecute = false;
+    private boolean didPrint = false;
+
+
+    protected void error(String msg) {
+        err.println("Error: " + msg);
+        errors++;
+    }
+
+    private int cases;
+    private int fcases;
+    private int errors;
+    private int ignored;
+
+    /**
+     * The TestSource class provides a simple container for
+     * test cases. It contains an array of source code lines,
+     * where zero or more lines may be markers for nested lines.
+     * This allows representing templates, with specialization.
+     * <P>
+     * This may be generalized to support more advance combo
+     * tests, but presently it's only used with a static template,
+     * and one level of specialization.
+     */
+    public class TestSource implements Iterable<String> {
+
+        private String[] lines;
+        private Hashtable<String, TestSource> innerSrc;
+
+        public TestSource(String... lines) {
+            this.lines = lines;
+            innerSrc = new Hashtable<String, TestSource>();
+        }
+
+        public void setInner(String key, TestSource inner) {
+            innerSrc.put(key, inner);
+        }
+
+        public void setInner(String key, String... lines) {
+            innerSrc.put(key, new TestSource(lines));
+        }
+
+        public Iterator<String> iterator() {
+            return new LineIterator();
+        }
+
+        private class LineIterator implements Iterator<String> {
+
+            int nextLine = 0;
+            Iterator<String> innerIt = null;
+
+            public  boolean hasNext() {
+                return nextLine < lines.length;
+            }
+
+            public String next() {
+                if (!hasNext()) throw new NoSuchElementException();
+                String str = lines[nextLine];
+                TestSource inner = innerSrc.get(str);
+                if (inner == null) {
+                    nextLine++;
+                    return str;
+                }
+                if (innerIt == null) {
+                    innerIt = inner.iterator();
+                }
+                if (innerIt.hasNext()) {
+                    return innerIt.next();
+                }
+                innerIt = null;
+                nextLine++;
+                return next();
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        }
+    }
+}
--- a/langtools/test/tools/javap/output/RepeatingTypeAnnotations.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/javap/output/RepeatingTypeAnnotations.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -46,13 +46,13 @@
  * produced to help debugging. Test annotated with {@code ignore}
  * can be executed explicitly.
  */
-public class RepeatingTypeAnnotations extends Tester {
+public class RepeatingTypeAnnotations extends JavapTester {
 
     /**
      * Main method instantiates test and run test-cases.
      */
     public static void main(String... args) throws Exception {
-        Tester tester = new RepeatingTypeAnnotations();
+        JavapTester tester = new RepeatingTypeAnnotations();
         tester.run(args);
     }
 
--- a/langtools/test/tools/javap/output/Tester.java	Fri Aug 19 10:09:53 2016 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,389 +0,0 @@
-/*
- * Copyright (c) 2013, 2014, 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.
- */
-
-import java.io.*;
-import java.util.*;
-import java.lang.annotation.*;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * {@code Tester} is an abstract test-driver that provides the logic
- * to execute test-cases, grouped by test classes.
- * A test class is a main class extending this class, that instantiate
- * itself, and calls the {@link run} method, passing any command line
- * arguments.
- * <p>
- * The {@code run} method, expects arguments to identify test-case classes.
- * A test-case class is a class extending the test class, and annotated
- * with {@code TestCase}.
- * <p>
- * If no test-cases are specified, the test class directory is searched for
- * co-located test-case classes (i.e. any class extending the test class,
- * annotated with  {@code TestCase}).
- * <p>
- * Besides serving to group test-cases, extending the driver allow
- * setting up a test-case template, and possibly overwrite default
- * test-driver behaviour.
- */
-public abstract class Tester {
-
-    private static boolean debug = false;
-    private static final PrintStream out = System.err;
-    private static final PrintStream err = System.err;
-
-
-    protected void run(String... args) throws Exception {
-
-        final File classesdir = new File(System.getProperty("test.classes", "."));
-
-        String[] classNames = args;
-
-        // If no test-cases are specified, we regard all co-located classes
-        // as potential test-cases.
-        if (args.length == 0) {
-            final String pattern =  ".*\\.class";
-            final File classFiles[] = classesdir.listFiles(new FileFilter() {
-                    public boolean accept(File f) {
-                        return f.getName().matches(pattern);
-                    }
-                });
-            ArrayList<String> names = new ArrayList<String>(classFiles.length);
-            for (File f : classFiles) {
-                String fname = f.getName();
-                names.add(fname.substring(0, fname.length() -6));
-            }
-            classNames = names.toArray(new String[names.size()]);
-        } else {
-            debug = true;
-        }
-        // Test-cases must extend the driver type, and be marked
-        // @TestCase. Other arguments (classes) are ignored.
-        // Test-cases are instantiated, and thereby executed.
-        for (String clname : classNames) {
-            try {
-                final Class tclass = Class.forName(clname);
-                if  (!getClass().isAssignableFrom(tclass)) continue;
-                TestCase anno = (TestCase) tclass.getAnnotation(TestCase.class);
-                if (anno == null) continue;
-                if (!debug) {
-                    ignore i = (ignore) tclass.getAnnotation(ignore.class);
-                    if (i != null) {
-                        out.println("Ignore: " + clname);
-                        ignored++;
-                        continue;
-                    }
-                }
-                out.println("TestCase: " + clname);
-                cases++;
-                Tester tc = (Tester) tclass.getConstructor().newInstance();
-                if (tc.errors > 0) {
-                    error("" + tc.errors + " test points failed in " + clname);
-                    errors += tc.errors - 1;
-                    fcases++;
-                }
-            } catch(ReflectiveOperationException roe) {
-                error("Warning: " + clname + " - ReflectiveOperationException");
-                roe.printStackTrace(err);
-            } catch(Exception unknown) {
-                error("Warning: " + clname + " - uncaught exception");
-                unknown.printStackTrace(err);
-            }
-        }
-
-        String imsg = ignored > 0 ? " (" +  ignored + " ignored)" : "";
-        if (errors > 0)
-            throw new Error(errors + " error, in " + fcases + " of " + cases + " test-cases" + imsg);
-        else
-            err.println("" + cases + " test-cases executed" + imsg + ", no errors");
-    }
-
-
-    /**
-     * Test-cases must be marked with the {@code TestCase} annotation,
-     * as well as extend {@code Tester} (or an driver extension
-     * specified as the first argument to the {@code main()} method.
-     */
-    @Retention(RetentionPolicy.RUNTIME)
-    @interface TestCase { }
-
-    /**
-     * Individual test-cases failing due to product bugs, may temporarily
-     * be excluded by marking them like this, (where "at-" is replaced by "@")
-     * at-ignore // 1234567: bug synopsis
-     */
-    @Retention(RetentionPolicy.RUNTIME)
-    @interface ignore { }
-
-    /**
-     * Test-cases are classes extending {@code Tester}, and
-     * calling {@link setSrc}, followed by one or more invocations
-     * of {@link verify} in the body of the constructor.
-     * <p>
-     * Sets a default test-case template, which is empty except
-     * for a key of {@code "TESTCASE"}.
-     * Subclasses will typically call {@code setSrc(TestSource)}
-     * to setup a useful test-case template.
-     */
-    public Tester() {
-        this.testCase = this.getClass().getName();
-        src = new TestSource("TESTCASE");
-    }
-
-    /**
-     * Set the top-level source template.
-     */
-    protected Tester setSrc(TestSource src) {
-        this.src = src;
-        return this;
-    }
-
-    /**
-     * Convenience method for calling {@code innerSrc("TESTCASE", ...)}.
-     */
-    protected Tester setSrc(String... lines) {
-        return innerSrc("TESTCASE", lines);
-    }
-
-    /**
-     * Convenience method for calling {@code innerSrc(key, new TestSource(...))}.
-     */
-    protected Tester innerSrc(String key, String... lines) {
-        return innerSrc(key, new TestSource(lines));
-    }
-
-    /**
-     * Specialize the testcase template, setting replacement content
-     * for the specified key.
-     */
-    protected Tester innerSrc(String key, TestSource content) {
-        if (src == null) {
-            src = new TestSource(key);
-        }
-        src.setInner(key, content);
-        return this;
-    }
-
-    /**
-     * On the first invocation, call {@code execute()} to compile
-     * the test-case source and process the resulting class(se)
-     * into verifiable output.
-     * <p>
-     * Verify that the output matches each of the regular expressions
-     * given as argument.
-     * <p>
-     * Any failure to match constitutes a test failure, but doesn't
-     * abort the test-case.
-     * <p>
-     * Any exception (e.g. bad regular expression syntax) results in
-     * a test failure, and aborts the test-case.
-     */
-    protected void verify(String... expect) {
-        if (!didExecute) {
-            try {
-                execute();
-            } catch(Exception ue) {
-                throw new Error(ue);
-            } finally {
-                didExecute = true;
-            }
-        }
-        if (output == null) {
-            error("output is null");
-            return;
-        }
-        for (String e: expect) {
-            // Escape regular expressions (to allow input to be literals).
-            // Notice, characters to be escaped are themselves identified
-            // using regular expressions
-            String rc[] = { "(", ")", "[", "]", "{", "}", "$" };
-            for (String c : rc) {
-                e = e.replace(c, "\\" + c);
-            }
-            // DEBUG: Uncomment this to test modulo constant pool index.
-            // e = e.replaceAll("#[0-9]{2}", "#[0-9]{2}");
-            if (!output.matches("(?s).*" + e + ".*")) {
-                if (!didPrint) {
-                    out.println(output);
-                    didPrint = true;
-                }
-                error("not matched: '" + e + "'");
-            } else if(debug) {
-                out.println("matched: '" + e + "'");
-            }
-        }
-    }
-
-    /**
-     * Calls {@code writeTestFile()} to write out the test-case source
-     * content to a file, then call {@code compileTestFile()} to
-     * compile it, and finally run the {@link process} method to produce
-     * verifiable output. The default {@code process} method runs javap.
-     * <p>
-     * If an exception occurs, it results in a test failure, and
-     * aborts the test-case.
-     */
-    protected void execute() throws IOException {
-        err.println("TestCase: " + testCase);
-        writeTestFile();
-        compileTestFile();
-        process();
-    }
-
-    /**
-     * Generate java source from test-case.
-     * TBD: change to use javaFileObject, possibly make
-     * this class extend JavaFileObject.
-     */
-    protected void writeTestFile() throws IOException {
-        javaFile = new File("Test.java");
-        FileWriter fw = new FileWriter(javaFile);
-        BufferedWriter bw = new BufferedWriter(fw);
-        PrintWriter pw = new PrintWriter(bw);
-        for (String line : src) {
-            pw.println(line);
-            if (debug) out.println(line);
-        }
-        pw.close();
-    }
-
-    /**
-     * Compile the Java source code.
-     */
-    protected void compileTestFile() {
-        String path = javaFile.getPath();
-        String params[] =  {"-g", path };
-        int rc = com.sun.tools.javac.Main.compile(params);
-        if (rc != 0)
-            throw new Error("compilation failed. rc=" + rc);
-        classFile = new File(path.substring(0, path.length() - 5) + ".class");
-    }
-
-
-    /**
-     * Process class file to generate output for verification.
-     * The default implementation simply runs javap. This might be
-     * overwritten to generate output in a different manner.
-     */
-    protected void process() {
-        String testClasses = "."; //System.getProperty("test.classes", ".");
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        String[] args = { "-v", "-classpath", testClasses, "Test" };
-        int rc = com.sun.tools.javap.Main.run(args, pw);
-        if (rc != 0)
-            throw new Error("javap failed. rc=" + rc);
-        pw.close();
-        output = sw.toString();
-        if (debug) {
-            out.println(output);
-            didPrint = true;
-        }
-
-    }
-
-
-    private String testCase;
-    private TestSource src;
-    private File javaFile = null;
-    private File classFile = null;
-    private String output = null;
-    private boolean didExecute = false;
-    private boolean didPrint = false;
-
-
-    protected void error(String msg) {
-        err.println("Error: " + msg);
-        errors++;
-    }
-
-    private int cases;
-    private int fcases;
-    private int errors;
-    private int ignored;
-
-    /**
-     * The TestSource class provides a simple container for
-     * test cases. It contains an array of source code lines,
-     * where zero or more lines may be markers for nested lines.
-     * This allows representing templates, with specialization.
-     * <P>
-     * This may be generalized to support more advance combo
-     * tests, but presently it's only used with a static template,
-     * and one level of specialization.
-     */
-    public class TestSource implements Iterable<String> {
-
-        private String[] lines;
-        private Hashtable<String, TestSource> innerSrc;
-
-        public TestSource(String... lines) {
-            this.lines = lines;
-            innerSrc = new Hashtable<String, TestSource>();
-        }
-
-        public void setInner(String key, TestSource inner) {
-            innerSrc.put(key, inner);
-        }
-
-        public void setInner(String key, String... lines) {
-            innerSrc.put(key, new TestSource(lines));
-        }
-
-        public Iterator<String> iterator() {
-            return new LineIterator();
-        }
-
-        private class LineIterator implements Iterator<String> {
-
-            int nextLine = 0;
-            Iterator<String> innerIt = null;
-
-            public  boolean hasNext() {
-                return nextLine < lines.length;
-            }
-
-            public String next() {
-                if (!hasNext()) throw new NoSuchElementException();
-                String str = lines[nextLine];
-                TestSource inner = innerSrc.get(str);
-                if (inner == null) {
-                    nextLine++;
-                    return str;
-                }
-                if (innerIt == null) {
-                    innerIt = inner.iterator();
-                }
-                if (innerIt.hasNext()) {
-                    return innerIt.next();
-                }
-                innerIt = null;
-                nextLine++;
-                return next();
-            }
-
-            public void remove() {
-                throw new UnsupportedOperationException();
-            }
-        }
-    }
-}
--- a/langtools/test/tools/jdeps/APIDeps.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/APIDeps.java	Fri Aug 19 12:17:32 2016 -0700
@@ -60,13 +60,13 @@
         Path testsrc = Paths.get(System.getProperty("test.src"));
         List<String> options = new ArrayList<>();
 
-        // add -XaddExports
+        // add --add-exports
         String testModules = System.getProperty("test.modules", "");
         List<String> addExports = new ArrayList<>();
         for (String s : testModules.split("\\s+")) {
             if (s.isEmpty()) continue;
             if (s.indexOf('/') != -1)
-                addExports.add("-XaddExports:" + s.trim() + "=ALL-UNNAMED");
+                addExports.add("--add-exports=" + s.trim() + "=ALL-UNNAMED");
         }
         options.addAll(addExports);
 
--- a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java	Fri Aug 19 12:17:32 2016 -0700
@@ -64,7 +64,7 @@
         assertTrue(CompilerUtils.compile(Paths.get(TEST_SRC, "src", "q"),
                                          CLASSES_DIR,
                                          "-cp", tmp.toString(),
-                                         "-XaddExports:java.base/sun.security.util=ALL-UNNAMED"));
+                                         "--add-exports=java.base/sun.security.util=ALL-UNNAMED"));
     }
 
     @Test
--- a/langtools/test/tools/jdeps/lib/JdepsUtil.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/lib/JdepsUtil.java	Fri Aug 19 12:17:32 2016 -0700
@@ -198,7 +198,7 @@
         }
 
         public ModuleAnalyzer getModuleAnalyzer(Set<String> mods) throws IOException {
-            // if -check is set, add to the root set and all modules are observable
+            // if --check is set, add to the root set and all modules are observable
             addmods(mods);
             builder.allModules();
             return new ModuleAnalyzer(configuration(), pw, mods);
--- a/langtools/test/tools/jdeps/modules/CheckModuleTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/CheckModuleTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -78,7 +78,7 @@
 
     @Test(dataProvider = "javaBase")
     public void testJavaBase(String name, ModuleMetaData data) throws Exception {
-        String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR);
+        String cmd = String.format("jdeps --check %s --module-path %s%n", name, MODS_DIR);
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
             jdeps.appModulePath(MODS_DIR.toString());
 
@@ -137,7 +137,7 @@
 
     @Test(dataProvider = "modules")
     public void modularTest(String name, ModuleMetaData[] data) throws Exception {
-        String cmd = String.format("jdeps -check %s -mp %s%n", name, MODS_DIR);
+        String cmd = String.format("jdeps --check %s --module-path %s%n", name, MODS_DIR);
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
             jdeps.appModulePath(MODS_DIR.toString());
--- a/langtools/test/tools/jdeps/modules/GenModuleInfo.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/GenModuleInfo.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary Tests jdeps -genmoduleinfo option
+ * @summary Tests jdeps --gen-module-info option
  * @library ../lib
  * @build CompilerUtils JdepsUtil
  * @modules jdk.jdeps/com.sun.tools.jdeps
@@ -73,7 +73,7 @@
         CompilerUtils.cleanDir(NEW_MODS_DIR);
 
         assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED,
-                                               "-XaddExports:java.base/jdk.internal.perf=" + UNSUPPORTED));
+                                               "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED));
         Arrays.asList("m1", "m2", "m3")
               .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn)));
 
@@ -106,7 +106,7 @@
                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                 .map(Path::toString);
 
-        JdepsUtil.jdeps(Stream.concat(Stream.of("-genmoduleinfo", DEST_DIR.toString()),
+        JdepsUtil.jdeps(Stream.concat(Stream.of("--gen-module-info", DEST_DIR.toString()),
                                       files).toArray(String[]::new));
 
         // check file exists
@@ -132,11 +132,11 @@
 
         // compile new module-info.java
         assertTrue(CompilerUtils.compileModule(DEST_DIR, NEW_MODS_DIR, UNSUPPORTED,
-                        "-mp", NEW_MODS_DIR.toString(), "-verbose",
-                        "-XaddExports:java.base/jdk.internal.perf=" + UNSUPPORTED));
+                        "-p", NEW_MODS_DIR.toString(), "-verbose",
+                        "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED));
         Arrays.asList("m1", "m2", "m3")
               .forEach(mn -> assertTrue(CompilerUtils.compileModule(DEST_DIR, NEW_MODS_DIR,
-                                        mn, "-mp", NEW_MODS_DIR.toString())));
+                                        mn, "-p", NEW_MODS_DIR.toString())));
 
         for (String mn : modules) {
             Path p1 = NEW_MODS_DIR.resolve(mn).resolve(MODULE_INFO);
--- a/langtools/test/tools/jdeps/modules/InverseDeps.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/InverseDeps.java	Fri Aug 19 12:17:32 2016 -0700
@@ -117,7 +117,7 @@
 
     @Test(dataProvider = "testrequires")
     public void testrequires(String name, String[][] expected) throws Exception {
-        String cmd1 = String.format("jdeps -inverse -modulepath %s -requires %s -addmods %s%n",
+        String cmd1 = String.format("jdeps -inverse --module-path %s -requires %s --add-modules %s%n",
                 MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
@@ -128,8 +128,8 @@
             runJdeps(jdeps, expected);
         }
 
-        String cmd2 = String.format("jdeps -inverse -modulepath %s -requires %s" +
-            " -addmods ALL-MODULE-PATH%n", LIBS_DIR, name);
+        String cmd2 = String.format("jdeps -inverse --module-path %s -requires %s" +
+            " --add-modules ALL-MODULE-PATH%n", LIBS_DIR, name);
 
             // automatic module
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
@@ -164,7 +164,7 @@
 
     @Test(dataProvider = "testpackage")
     public void testpackage(String name, String[][] expected) throws Exception {
-        String cmd = String.format("jdeps -inverse -modulepath %s -package %s -addmods %s%n",
+        String cmd = String.format("jdeps -inverse --module-path %s -package %s --add-modules %s%n",
             MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
             jdeps.appModulePath(MODS_DIR.toString())
@@ -195,7 +195,7 @@
 
     @Test(dataProvider = "testregex")
     public void testregex(String name, String[][] expected) throws Exception {
-        String cmd = String.format("jdeps -inverse -modulepath %s -regex %s -addmods %s%n",
+        String cmd = String.format("jdeps -inverse --module-path %s -regex %s --add-modules %s%n",
                 MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
--- a/langtools/test/tools/jdeps/modules/ModuleTest.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/ModuleTest.java	Fri Aug 19 12:17:32 2016 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary Tests jdeps -m and -mp options on named modules and unnamed modules
+ * @summary Tests jdeps -m and --module-path options on named modules and unnamed modules
  * @library ../lib
  * @build CompilerUtils JdepsUtil
  * @modules jdk.jdeps/com.sun.tools.jdeps
@@ -68,12 +68,12 @@
         CompilerUtils.cleanDir(UNNAMED_DIR);
 
         assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, UNSUPPORTED,
-                                               "-XaddExports:java.base/jdk.internal.perf=" + UNSUPPORTED));
+                                               "--add-exports", "java.base/jdk.internal.perf=" + UNSUPPORTED));
         // m4 is not referenced
         Arrays.asList("m1", "m2", "m3", "m4")
               .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, MODS_DIR, mn)));
 
-        assertTrue(CompilerUtils.compile(SRC_DIR.resolve("m3"), UNNAMED_DIR, "-mp", MODS_DIR.toString()));
+        assertTrue(CompilerUtils.compile(SRC_DIR.resolve("m3"), UNNAMED_DIR, "-p", MODS_DIR.toString()));
         Files.delete(UNNAMED_DIR.resolve("module-info.class"));
     }
 
@@ -112,10 +112,10 @@
 
     @Test(dataProvider = "modules")
     public void modularTest(String name, ModuleMetaData data) throws IOException {
-        // jdeps -modulepath mods -m <name>
+        // jdeps --module-path mods -m <name>
         runTest(data, MODS_DIR.toString(), Set.of(name));
 
-        // jdeps -modulepath libs/m1.jar:.... -m <name>
+        // jdeps --module-path libs/m1.jar:.... -m <name>
         String mp = Arrays.stream(modules)
                 .filter(mn -> !mn.equals(name))
                 .map(mn -> MODS_DIR.resolve(mn).toString())
@@ -150,8 +150,8 @@
                          Set<String> roots, Path... paths)
         throws IOException
     {
-        // jdeps -modulepath <modulepath> -m root paths
-        String cmd = String.format("jdeps -modulepath %s -addmods %s %s%n",
+        // jdeps --module-path <modulepath> -m root paths
+        String cmd = String.format("jdeps --module-path %s --add-modules %s %s%n",
             MODS_DIR, roots.stream().collect(Collectors.joining(",")), paths);
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
--- a/langtools/test/tools/jdeps/modules/SplitPackage.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/SplitPackage.java	Fri Aug 19 12:17:32 2016 -0700
@@ -65,12 +65,12 @@
     public void runTest() throws Exception {
         // Test jdeps classes
         runTest(null);
-        // Test jdeps -addmods
+        // Test jdeps --add-modules
         runTest(JAVA_ANNOTATIONS_COMMON, SPLIT_PKG_NAME);
     }
 
     private void runTest(String root, String... splitPackages) throws Exception {
-        String cmd = String.format("jdeps -verbose:class -addmods %s %s%n",
+        String cmd = String.format("jdeps -verbose:class --add-modules %s %s%n",
             root, CLASSES_DIR);
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
--- a/langtools/test/tools/jdeps/modules/TransitiveDeps.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/TransitiveDeps.java	Fri Aug 19 12:17:32 2016 -0700
@@ -123,7 +123,7 @@
     public void testModulePath(String name, List<ModuleMetaData> data) throws IOException {
         Set<String> roots = Set.of("m6", "unsafe");
 
-        String cmd1 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", MODS_DIR,
+        String cmd1 = String.format("jdeps --module-path %s --add-modules %s -m %s%n", MODS_DIR,
             roots.stream().collect(Collectors.joining(",")), name);
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
             jdeps.verbose("-verbose:class")
@@ -136,7 +136,7 @@
         // run automatic modules
         roots = Set.of("ALL-MODULE-PATH", "jdk.unsupported");
 
-        String cmd2 = String.format("jdeps -modulepath %s -addmods %s -m %s%n", LIBS_DIR,
+        String cmd2 = String.format("jdeps --module-path %s --add-modules %s -m %s%n", LIBS_DIR,
             roots.stream().collect(Collectors.joining(",")), name);
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
--- a/langtools/test/tools/jdeps/modules/src/m3/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/src/m3/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -24,7 +24,7 @@
 module m3 {
     requires public java.sql;
     requires public m2;
-    requires java.logging;   // TODO: genmoduleinfo to do transitive reduction
+    requires java.logging;   // TODO: --gen-module-info to do transitive reduction
     requires public m1;
     exports p3;
 }
--- a/langtools/test/tools/jdeps/modules/src/m5/module-info.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/jdeps/modules/src/m5/module-info.java	Fri Aug 19 12:17:32 2016 -0700
@@ -22,7 +22,7 @@
  */
 
 module m5 {
-    // m4 requires public java.compilerr
+    // m4 requires public java.compiler
     requires public m4;
     requires public java.compiler;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/lib/toolbox/Assert.java	Fri Aug 19 12:17:32 2016 -0700
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2011, 2016, 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 toolbox;
+
+import java.util.function.Supplier;
+
+/**
+ * Simple facility for unconditional assertions.
+ * The methods in this class are described in terms of equivalent assert
+ * statements, assuming that assertions have been enabled.
+ */
+public class Assert {
+    /** Equivalent to
+     *   assert cond;
+     */
+    public static void check(boolean cond) {
+        if (!cond)
+            error();
+    }
+
+    /** Equivalent to
+     *   assert (o == null);
+     */
+    public static void checkNull(Object o) {
+        if (o != null)
+            error();
+    }
+
+    /** Equivalent to
+     *   assert (t != null); return t;
+     */
+    public static <T> T checkNonNull(T t) {
+        if (t == null)
+            error();
+        return t;
+    }
+
+    /** Equivalent to
+     *   assert cond : value;
+     */
+    public static void check(boolean cond, int value) {
+        if (!cond)
+            error(String.valueOf(value));
+    }
+
+    /** Equivalent to
+     *   assert cond : value;
+     */
+    public static void check(boolean cond, long value) {
+        if (!cond)
+            error(String.valueOf(value));
+    }
+
+    /** Equivalent to
+     *   assert cond : value;
+     */
+    public static void check(boolean cond, Object value) {
+        if (!cond)
+            error(String.valueOf(value));
+    }
+
+    /** Equivalent to
+     *   assert cond : msg;
+     */
+    public static void check(boolean cond, String msg) {
+        if (!cond)
+            error(msg);
+    }
+
+    /** Equivalent to
+     *   assert cond : msg.get();
+     *  Note: message string is computed lazily.
+     */
+    public static void check(boolean cond, Supplier<String> msg) {
+        if (!cond)
+            error(msg.get());
+    }
+
+    /** Equivalent to
+     *   assert (o == null) : value;
+     */
+    public static void checkNull(Object o, Object value) {
+        if (o != null)
+            error(String.valueOf(value));
+    }
+
+    /** Equivalent to
+     *   assert (o == null) : msg;
+     */
+    public static void checkNull(Object o, String msg) {
+        if (o != null)
+            error(msg);
+    }
+
+    /** Equivalent to
+     *   assert (o == null) : msg.get();
+     *  Note: message string is computed lazily.
+     */
+    public static void checkNull(Object o, Supplier<String> msg) {
+        if (o != null)
+            error(msg.get());
+    }
+
+    /** Equivalent to
+     *   assert (o != null) : msg;
+     */
+    public static <T> T checkNonNull(T t, String msg) {
+        if (t == null)
+            error(msg);
+        return t;
+    }
+
+    /** Equivalent to
+     *   assert (o != null) : msg.get();
+     *  Note: message string is computed lazily.
+     */
+    public static <T> T checkNonNull(T t, Supplier<String> msg) {
+        if (t == null)
+            error(msg.get());
+        return t;
+    }
+
+    /** Equivalent to
+     *   assert false;
+     */
+    public static void error() {
+        throw new AssertionError();
+    }
+
+    /** Equivalent to
+     *   assert false : msg;
+     */
+    public static void error(String msg) {
+        throw new AssertionError(msg);
+    }
+
+    /** Prevent instantiation. */
+    private Assert() { }
+}
--- a/langtools/test/tools/lib/toolbox/JavaTask.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/lib/toolbox/JavaTask.java	Fri Aug 19 12:17:32 2016 -0700
@@ -67,6 +67,16 @@
     }
 
     /**
+     * Sets the VM options.
+     * @param vmOptions the options
+     * @return this task object
+     */
+    public JavaTask vmOptions(List<String> vmOptions) {
+        this.vmOptions = vmOptions;
+        return this;
+    }
+
+    /**
      * Sets the name of the class to be executed.
      * @param className the name of the class
      * @return this task object
@@ -87,6 +97,16 @@
     }
 
     /**
+     * Sets the arguments for the class to be executed.
+     * @param classArgs the arguments
+     * @return this task object
+     */
+    public JavaTask classArgs(List<String> classArgs) {
+        this.classArgs = classArgs;
+        return this;
+    }
+
+    /**
      * Sets whether or not the standard VM and java options for the test should be passed
      * to the new VM instance. If this method is not called, the default behavior is that
      * the options will be passed to the new VM instance.
--- a/langtools/test/tools/lib/toolbox/JavacTask.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/lib/toolbox/JavacTask.java	Fri Aug 19 12:17:32 2016 -0700
@@ -176,6 +176,16 @@
     }
 
     /**
+     * Sets the options.
+     * @param options the options
+     * @return this task object
+     */
+    public JavacTask options(List<String> options) {
+        this.options = options;
+        return this;
+    }
+
+    /**
      * Sets the classes to be analyzed.
      * @param classes the classes
      * @return this task object
--- a/langtools/test/tools/lib/toolbox/TestRunner.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/lib/toolbox/TestRunner.java	Fri Aug 19 12:17:32 2016 -0700
@@ -117,7 +117,7 @@
         }
     }
 
-    public void error(String message) {
+    protected void error(String message) {
         out.println("Error: " + message);
         errorCount++;
     }
--- a/langtools/test/tools/sjavac/ApiExtraction.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/ApiExtraction.java	Fri Aug 19 12:17:32 2016 -0700
@@ -29,10 +29,12 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
- * @build Wrapper toolbox.ToolBox
+ *          jdk.compiler/com.sun.tools.sjavac.options
+ *          jdk.compiler/com.sun.tools.sjavac.pubapi
+ * @build Wrapper toolbox.ToolBox toolbox.JavacTask
  * @run main Wrapper ApiExtraction
  */
+
 import static java.util.Arrays.asList;
 import static java.util.Collections.emptyList;
 import static javax.lang.model.element.Modifier.FINAL;
@@ -56,6 +58,8 @@
 import com.sun.tools.sjavac.pubapi.PubVar;
 import com.sun.tools.sjavac.pubapi.ReferenceTypeDesc;
 
+import toolbox.JavacTask;
+import toolbox.ToolBox;
 
 public class ApiExtraction {
     public static void main(String[] args) throws IOException {
@@ -86,7 +90,7 @@
                 "}");
 
         // Create class file to extract API from
-        new ToolBox().new JavacTask().sources(testSrc).run();
+        new JavacTask(new ToolBox()).sources(testSrc).run();
 
         // Extract PubApi
         Options options = Options.parseArgs("-d", "bin", "--state-dir=bin", "-cp", ".");
--- a/langtools/test/tools/sjavac/ClasspathDependencies.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/ClasspathDependencies.java	Fri Aug 19 12:17:32 2016 -0700
@@ -29,12 +29,10 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
- * @build Wrapper toolbox.ToolBox
+ * @build Wrapper toolbox.ToolBox toolbox.Assert
  * @run main Wrapper ClasspathDependencies
  */
 
-import static com.sun.tools.javac.util.Assert.check;
 
 import java.io.IOException;
 import java.nio.file.FileVisitResult;
@@ -45,6 +43,8 @@
 import java.nio.file.attribute.BasicFileAttributes;
 import java.nio.file.attribute.FileTime;
 
+import static toolbox.Assert.check;
+
 public class ClasspathDependencies extends SjavacBase {
 
     public static void main(String... args) throws Exception {
@@ -134,5 +134,4 @@
                  }
             });
     }
-
 }
--- a/langtools/test/tools/sjavac/CompileCircularSources.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/CompileCircularSources.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper CompileCircularSources
  */
--- a/langtools/test/tools/sjavac/CompileExcludingDependency.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/CompileExcludingDependency.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper CompileExcludingDependency
  */
@@ -49,7 +48,6 @@
     void test() throws Exception {
         Files.createDirectories(BIN);
         Map<String,Long> previous_bin_state = collectState(BIN);
-        ToolBox tb = new ToolBox();
         tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
                      "package alfa.omega; public class A { beta.B b; }");
         tb.writeFile(GENSRC.resolve("beta/B.java"),
--- a/langtools/test/tools/sjavac/CompileWithAtFile.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/CompileWithAtFile.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper CompileWithAtFile
  */
--- a/langtools/test/tools/sjavac/CompileWithInvisibleSources.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/CompileWithInvisibleSources.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper CompileWithInvisibleSources
  */
@@ -53,7 +52,6 @@
 
         Map<String,Long> previous_bin_state = collectState(BIN);
 
-        ToolBox tb = new ToolBox();
         tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
                      "package alfa.omega; import beta.B; import gamma.C; public class A { B b; C c; }");
         tb.writeFile(GENSRC2.resolve("beta/B.java"),
--- a/langtools/test/tools/sjavac/CompileWithOverrideSources.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/CompileWithOverrideSources.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper CompileWithOverrideSources
  */
@@ -51,7 +50,6 @@
         Files.createDirectories(BIN);
 
         Map<String,Long> previous_bin_state = collectState(BIN);
-        ToolBox tb = new ToolBox();
         tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
                      "package alfa.omega; import beta.B; import gamma.C; public class A { B b; C c; }");
         tb.writeFile(GENSRC.resolve("beta/B.java"),
--- a/langtools/test/tools/sjavac/HiddenFiles.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/HiddenFiles.java	Fri Aug 19 12:17:32 2016 -0700
@@ -28,22 +28,23 @@
  * @bug 8144226
  * @summary Ensures that excluded files are inaccessible (even for implicit
  *          compilation)
- *
- * @modules jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.sjavac
+ *          jdk.compiler/com.sun.tools.sjavac.server
  * @library /tools/lib
- * @build Wrapper toolbox.ToolBox
+ * @build Wrapper toolbox.ToolBox toolbox.Assert
  * @run main Wrapper HiddenFiles
  */
 
-import com.sun.tools.javac.main.Main.Result;
-import com.sun.tools.javac.util.Assert;
-import com.sun.tools.sjavac.server.Sjavac;
 
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import com.sun.tools.javac.main.Main.Result;
+
+import toolbox.Assert;
+
 public class HiddenFiles extends SjavacBase {
 
     public static void main(String[] ignore) throws Exception {
--- a/langtools/test/tools/sjavac/IdleShutdown.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IdleShutdown.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,10 +25,12 @@
  * @test
  * @bug 8044131
  * @summary Tests the hooks used for detecting idleness of the sjavac server.
- * @modules jdk.compiler/com.sun.tools.sjavac.server
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.sjavac.server
  * @build Wrapper
  * @run main Wrapper IdleShutdown
  */
+
 import java.util.concurrent.atomic.AtomicLong;
 
 import com.sun.tools.javac.main.Main.Result;
--- a/langtools/test/tools/sjavac/IgnoreSymbolFile.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IgnoreSymbolFile.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,8 +25,7 @@
  * @test
  * @bug 8047183
  * @summary JDK build fails with sjavac enabled
- *
- * @modules jdk.compiler
+ * @modules jdk.compiler/com.sun.tools.sjavac
  * @build Wrapper
  * @run main Wrapper IgnoreSymbolFile
  */
--- a/langtools/test/tools/sjavac/IncCompInheritance.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncCompInheritance.java	Fri Aug 19 12:17:32 2016 -0700
@@ -28,7 +28,7 @@
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
- *          jdk.jdeps/com.sun.tools.javap
+ *          jdk.compiler/com.sun.tools.sjavac
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper IncCompInheritance
  */
--- a/langtools/test/tools/sjavac/IncCompileChangeNative.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncCompileChangeNative.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper IncCompileChangeNative
  */
@@ -48,7 +47,6 @@
     // Remember the previous bin and headers state here.
     Map<String,Long> previous_bin_state;
     Map<String,Long> previous_headers_state;
-    ToolBox tb = new ToolBox();
 
     void test() throws Exception {
         Files.createDirectories(GENSRC);
--- a/langtools/test/tools/sjavac/IncCompileDropClasses.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncCompileDropClasses.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper IncCompileDropClasses
  */
@@ -48,7 +47,6 @@
     // Remember the previous bin and headers state here.
     Map<String,Long> previous_bin_state;
     Map<String,Long> previous_headers_state;
-    ToolBox tb = new ToolBox();
 
     void test() throws Exception {
         Files.createDirectories(GENSRC);
--- a/langtools/test/tools/sjavac/IncCompileFullyQualifiedRef.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncCompileFullyQualifiedRef.java	Fri Aug 19 12:17:32 2016 -0700
@@ -48,7 +48,6 @@
 
     void test() throws Exception {
         clean(TEST_ROOT);
-        ToolBox tb = new ToolBox();
         tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
                      "package alfa.omega; public class A { "+
                      "  public final static int DEFINITION = 18; "+
--- a/langtools/test/tools/sjavac/IncCompileNoChanges.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncCompileNoChanges.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper IncCompileNoChanges
  */
--- a/langtools/test/tools/sjavac/IncCompileUpdateNative.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncCompileUpdateNative.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper IncCompileUpdateNative
  */
@@ -48,7 +47,6 @@
     // Remember the previous bin and headers state here.
     Map<String,Long> previous_bin_state;
     Map<String,Long> previous_headers_state;
-    ToolBox tb = new ToolBox();
 
     void test() throws Exception {
         Files.createDirectories(GENSRC);
--- a/langtools/test/tools/sjavac/IncCompileWithChanges.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncCompileWithChanges.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @ignore Requires dependency code to deal with in-method dependencies.
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper IncCompileWithChanges
@@ -51,7 +50,6 @@
     // Remember the previous bin and headers state here.
     Map<String,Long> previous_bin_state;
     Map<String,Long> previous_headers_state;
-    ToolBox tb = new ToolBox();
 
     void test() throws Exception {
         clean(TEST_ROOT);
--- a/langtools/test/tools/sjavac/IncludeExcludePatterns.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/IncludeExcludePatterns.java	Fri Aug 19 12:17:32 2016 -0700
@@ -26,17 +26,14 @@
  * @bug 8037085
  * @summary Ensures that sjavac can handle various exclusion patterns.
  *
- * @modules jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.sjavac
+ *          jdk.compiler/com.sun.tools.sjavac.server
  * @library /tools/lib
- * @build Wrapper toolbox.ToolBox
+ * @build Wrapper toolbox.ToolBox toolbox.Assert
  * @run main Wrapper IncludeExcludePatterns
  */
 
-import com.sun.tools.javac.main.Main.Result;
-import com.sun.tools.javac.util.Assert;
-import com.sun.tools.sjavac.server.Sjavac;
-
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
@@ -49,6 +46,10 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import com.sun.tools.javac.main.Main.Result;
+
+import toolbox.Assert;
+
 public class IncludeExcludePatterns extends SjavacBase {
 
     final Path SRC = Paths.get("src");
--- a/langtools/test/tools/sjavac/NoState.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/NoState.java	Fri Aug 19 12:17:32 2016 -0700
@@ -29,17 +29,16 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
- * @build Wrapper toolbox.ToolBox
+ * @build Wrapper toolbox.ToolBox toolbox.Assert
  * @run main Wrapper NoState
  */
 
-import com.sun.tools.javac.util.Assert;
-
 import java.io.IOException;
 import java.nio.file.*;
 import java.util.stream.Stream;
 
+import toolbox.Assert;
+
 public class NoState extends SJavacTester {
     public static void main(String... args) throws Exception {
         new NoState().run();
--- a/langtools/test/tools/sjavac/OptionDecoding.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/OptionDecoding.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -28,6 +28,7 @@
  *
  * @modules jdk.compiler/com.sun.tools.sjavac
  *          jdk.compiler/com.sun.tools.sjavac.client
+ *          jdk.compiler/com.sun.tools.sjavac.comp
  *          jdk.compiler/com.sun.tools.sjavac.options
  * @build Wrapper
  * @run main Wrapper OptionDecoding
@@ -147,13 +148,13 @@
         SourceLocation dir2 = new SourceLocation(Paths.get("dir2"), i, x);
         String dir1_PS_dir2 = "dir1" + File.pathSeparator + "dir2";
 
-        Options options = Options.parseArgs("-sourcepath", dir1_PS_dir2);
+        Options options = Options.parseArgs("--source-path", dir1_PS_dir2);
         assertEquals(options.getSourceSearchPaths(), Arrays.asList(dir1, dir2));
 
-        options = Options.parseArgs("-modulepath", dir1_PS_dir2);
+        options = Options.parseArgs("--module-path", dir1_PS_dir2);
         assertEquals(options.getModuleSearchPaths(), Arrays.asList(dir1, dir2));
 
-        options = Options.parseArgs("-classpath", dir1_PS_dir2);
+        options = Options.parseArgs("--class-path", dir1_PS_dir2);
         assertEquals(options.getClassSearchPath(), Arrays.asList(dir1, dir2));
     }
 
--- a/langtools/test/tools/sjavac/OverlappingSrcDst.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/OverlappingSrcDst.java	Fri Aug 19 12:17:32 2016 -0700
@@ -32,7 +32,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper OverlappingSrcDst
  */
@@ -40,6 +39,8 @@
 import java.io.File;
 import java.nio.file.Paths;
 
+import toolbox.ToolBox;
+
 public class OverlappingSrcDst extends SJavacTester {
     public static void main(String... args) {
         new OverlappingSrcDst().run();
--- a/langtools/test/tools/sjavac/PackagePathMismatch.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/PackagePathMismatch.java	Fri Aug 19 12:17:32 2016 -0700
@@ -28,7 +28,7 @@
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
- *          jdk.jdeps/com.sun.tools.javap
+ *          jdk.compiler/com.sun.tools.sjavac
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper PackagePathMismatch
  */
--- a/langtools/test/tools/sjavac/ParallelCompilations.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/ParallelCompilations.java	Fri Aug 19 12:17:32 2016 -0700
@@ -30,7 +30,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper ParallelCompilations
  */
@@ -45,8 +44,6 @@
   }
 
   public void run() throws Exception {
-    ToolBox tb = new ToolBox();
-
     // Generate 10 files
     for (int i = 0; i < 10; i++) {
       String content = "package foo"+ i + ";\n" +
--- a/langtools/test/tools/sjavac/PermittedArtifact.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/PermittedArtifact.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper PermittedArtifact
  */
@@ -51,7 +50,6 @@
 
         Map<String,Long> previous_bin_state = collectState(BIN);
 
-        ToolBox tb = new ToolBox();
         tb.writeFile(GENSRC + "/alfa/omega/A.java",
                      "package alfa.omega; public class A { }");
 
--- a/langtools/test/tools/sjavac/PooledExecution.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/PooledExecution.java	Fri Aug 19 12:17:32 2016 -0700
@@ -25,11 +25,13 @@
  * @test
  * @bug 8044131
  * @summary Makes sure sjavac poolsize option is honored.
- * @modules jdk.compiler/com.sun.tools.sjavac.comp
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.sjavac.comp
  *          jdk.compiler/com.sun.tools.sjavac.server
  * @build Wrapper
  * @run main Wrapper PooledExecution
  */
+
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 
--- a/langtools/test/tools/sjavac/SjavacBase.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/SjavacBase.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -24,6 +24,8 @@
 import java.lang.reflect.Method;
 import java.util.Arrays;
 
+import toolbox.ToolBox;
+
 public class SjavacBase {
 
     protected final static ToolBox toolbox = new ToolBox();
@@ -44,5 +46,4 @@
         int rc = (Integer) m.invoke(null, (Object) strArgs);
         return rc;
     }
-
 }
--- a/langtools/test/tools/sjavac/StateDir.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/StateDir.java	Fri Aug 19 12:17:32 2016 -0700
@@ -31,7 +31,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
  *          jdk.compiler/com.sun.tools.sjavac
- *          jdk.jdeps/com.sun.tools.javap
  * @build Wrapper toolbox.ToolBox
  * @run main Wrapper StateDir
  */
@@ -53,7 +52,6 @@
         Map<String,Long> previous_bin_state = collectState(BIN);
         Map<String,Long> previous_bar_state = collectState(BAR);
 
-        ToolBox tb = new ToolBox();
         tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
                      "package alfa.omega; public class A { }");
 
--- a/langtools/test/tools/sjavac/Wrapper.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/langtools/test/tools/sjavac/Wrapper.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, 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
@@ -21,10 +21,15 @@
  * questions.
  */
 
-import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
 import java.util.Arrays;
-
+import java.util.List;
+import java.util.stream.Collectors;
 
 public class Wrapper {
     public static void main(String... args) throws Exception {
@@ -36,16 +41,28 @@
         String testClassName = args[0];
         String[] testArgs = Arrays.copyOfRange(args, 1, args.length);
 
-        File srcDir = new File(System.getProperty("test.src"));
-        File clsDir = new File(System.getProperty("test.classes"));
+        Path srcDir = Paths.get(System.getProperty("test.src"));
+        Path clsDir = Paths.get(System.getProperty("test.classes"));
+        String clsPath = System.getProperty("test.class.path");
+        String tstMdls = System.getProperty("test.modules");
+
+        Path src = srcDir.resolve(testClassName + ".java");
+        Path cls = clsDir.resolve(testClassName + ".class");
 
-        File src = new File(srcDir, testClassName + ".java");
-        File cls = new File(clsDir, testClassName + ".class");
-
-        if (cls.lastModified() < src.lastModified()) {
+        if (isNewer(src, cls)) {
             System.err.println("Recompiling test class...");
-            String[] javacArgs = { "-d", clsDir.getPath(), src.getPath() };
-            int rc = com.sun.tools.javac.Main.compile(javacArgs);
+            List<String> javacArgs = new ArrayList<>();
+            javacArgs.addAll(Arrays.asList("-d", clsDir.toString()));
+            javacArgs.addAll(Arrays.asList("-sourcepath", srcDir.toString()));
+            javacArgs.addAll(Arrays.asList("-classpath", clsPath));
+            Arrays.stream(tstMdls.split("\\s+"))
+                .filter(s -> s.contains("/"))
+                .map(s -> "--add-exports=" + s + "=ALL-UNNAMED")
+                .collect(Collectors.toCollection(() -> javacArgs));
+            javacArgs.add(src.toString());
+            System.out.println("javac: " + javacArgs);
+            int rc = com.sun.tools.javac.Main.compile(
+                javacArgs.toArray(new String[javacArgs.size()]));
             if (rc != 0)
                 throw new Exception("compilation failed");
         }
@@ -55,6 +72,12 @@
         main.invoke(null, new Object[] { testArgs });
     }
 
+    private static boolean isNewer(Path a, Path b) throws IOException {
+        if (Files.notExists(b))
+            return true;
+        return Files.getLastModifiedTime(a).compareTo(Files.getLastModifiedTime(b)) > 0;
+    }
+
     private static boolean isSJavacOnClassPath() {
         String cls = "com/sun/tools/sjavac/Main.class";
         return Wrapper.class.getClassLoader().getResource(cls) != null;
--- a/make/CompileJavaModules.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/make/CompileJavaModules.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -502,8 +502,8 @@
     HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \
     ADD_JAVAC_FLAGS := \
         $($(MODULE)_ADD_JAVAC_FLAGS) \
-        -modulesourcepath $(MODULESOURCEPATH) \
-        -modulepath $(MODULEPATH) \
+        --module-source-path $(MODULESOURCEPATH) \
+        --module-path $(MODULEPATH) \
         -system none, \
 ))
 
--- a/make/CreateJmods.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/make/CreateJmods.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -77,7 +77,7 @@
 
     EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES))))
 
-    JMOD_FLAGS += --modulepath $(JMODS_DIR) \
+    JMOD_FLAGS += --module-path $(JMODS_DIR) \
         --hash-modules '^(?!$(EXCLUDE_PATTERN))'
   endif
 endif
@@ -102,7 +102,7 @@
             --os-name $(REQUIRED_OS_NAME) \
             --os-arch $(OPENJDK_TARGET_CPU_LEGACY) \
             --os-version $(REQUIRED_OS_VERSION) \
-            --modulepath $(JMODS_DIR) \
+            --module-path $(JMODS_DIR) \
             --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.pdb,*.map}' \
 	    $(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@)
 	$(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@
--- a/make/Images.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/make/Images.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -127,7 +127,7 @@
     /jdk.localedata/** \
     #
 
-JLINK_TOOL := $(JLINK) --modulepath $(IMAGES_OUTPUTDIR)/jmods \
+JLINK_TOOL := $(JLINK) --module-path $(IMAGES_OUTPUTDIR)/jmods \
     --endian $(OPENJDK_BUILD_CPU_ENDIAN) \
     --release-info $(BASE_RELEASE_FILE) \
     --order-resources=$(call CommaList, $(JLINK_ORDER_RESOURCES)) \
@@ -142,7 +142,7 @@
 	$(ECHO) Creating jdk jimage
 	$(RM) -r $(JDK_IMAGE_DIR)
 	$(JLINK_TOOL) --output $(JDK_IMAGE_DIR) \
-	    --addmods $(JDK_MODULES_LIST) $(JLINK_EXTRA_OPTS)
+	    --add-modules $(JDK_MODULES_LIST) $(JLINK_EXTRA_OPTS)
 	$(TOUCH) $@
 
 $(JRE_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
@@ -150,7 +150,7 @@
 	$(ECHO) Creating jre jimage
 	$(RM) -r $(JRE_IMAGE_DIR)
 	$(JLINK_TOOL) --output $(JRE_IMAGE_DIR) \
-	    --addmods $(JRE_MODULES_LIST)
+	    --add-modules $(JRE_MODULES_LIST)
 	$(TOUCH) $@
 
 JRE_COMPACT1_IMAGE_DIR := $(JRE_IMAGE_DIR)-compact1
@@ -161,7 +161,7 @@
     $(call DependOnVariable, JRE_COMPACT1_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jre compact1 jimage
 	$(RM) -r $(JRE_COMPACT1_IMAGE_DIR)
-	$(JLINK_TOOL) --addmods $(JRE_COMPACT1_MODULES_LIST) \
+	$(JLINK_TOOL) --add-modules $(JRE_COMPACT1_MODULES_LIST) \
 	    --output $(JRE_COMPACT1_IMAGE_DIR)
 	$(TOUCH) $@
 
@@ -169,7 +169,7 @@
     $(call DependOnVariable, JRE_COMPACT2_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jre compact2 jimage
 	$(RM) -r $(JRE_COMPACT2_IMAGE_DIR)
-	$(JLINK_TOOL) --addmods $(JRE_COMPACT2_MODULES_LIST) \
+	$(JLINK_TOOL) --add-modules $(JRE_COMPACT2_MODULES_LIST) \
 	    --output $(JRE_COMPACT2_IMAGE_DIR)
 	$(TOUCH) $@
 
@@ -177,7 +177,7 @@
     $(call DependOnVariable, JRE_COMPACT3_MODULES_LIST) $(BASE_RELEASE_FILE)
 	$(ECHO) Creating jre compact3 jimage
 	$(RM) -r $(JRE_COMPACT3_IMAGE_DIR)
-	$(JLINK_TOOL) --addmods $(JRE_COMPACT3_MODULES_LIST) \
+	$(JLINK_TOOL) --add-modules $(JRE_COMPACT3_MODULES_LIST) \
 	    --output $(JRE_COMPACT3_IMAGE_DIR)
 	$(TOUCH) $@
 
--- a/make/InterimImage.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/make/InterimImage.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -39,7 +39,7 @@
 JMODS := $(patsubst %, $(IMAGES_OUTPUTDIR)/jmods/%.jmod, $(INTERIM_IMAGE_MODULES))
 
 JLINK_TOOL := $(JLINK) \
-    --modulepath $(IMAGES_OUTPUTDIR)/jmods \
+    --module-path $(IMAGES_OUTPUTDIR)/jmods \
     --endian $(OPENJDK_BUILD_CPU_ENDIAN)
 
 $(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE): $(JMODS) \
@@ -48,7 +48,7 @@
 	$(RM) -r $(INTERIM_IMAGE_DIR)
 	$(JLINK_TOOL) \
 	    --output $(INTERIM_IMAGE_DIR) \
-	    --addmods $(INTERIM_MODULES_LIST)
+	    --add-modules $(INTERIM_MODULES_LIST)
 	$(TOUCH) $@
 
 TARGETS += $(INTERIM_IMAGE_DIR)/$(JIMAGE_TARGET_FILE)
--- a/make/Javadoc.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/make/Javadoc.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -425,9 +425,9 @@
           $(call COMMON_JAVADOCTAGS) ; \
           $(call OptionOnly,-Xdoclint:reference) ; \
           $(call OptionOnly,-Xdoclint/package:-org.omg.*$(COMMA)jdk.internal.logging.*) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(COREAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(COREAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ISO-8859-1) ; \
 	  $(call OptionOnly,-splitIndex) ; \
 	  $(call OptionPair,-overview,$(COREAPI_OVERVIEW)) ; \
@@ -488,9 +488,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(DOCLETAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(DOCLETAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-breakiterator) ; \
 	  $(call OptionPair,-doctitle,$(DOCLETAPI_DOCTITLE)) ; \
@@ -550,9 +550,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(OLD_DOCLETAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(OLD_DOCLETAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-breakiterator) ; \
 	  $(call OptionPair,-doctitle,$(OLD_DOCLETAPI_DOCTITLE)) ; \
@@ -605,9 +605,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(TAGLETAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(TAGLETAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-breakiterator) ; \
 	  $(call OptionPair,-doctitle,$(TAGLETAPI_DOCTITLE)) ; \
@@ -667,9 +667,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(DOMAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(DOMAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-splitIndex) ; \
 	  $(call OptionPair,-doctitle,$(DOMAPI_DOCTITLE)) ; \
@@ -736,9 +736,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JDI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JDI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionPair,-overview,$(JDI_OVERVIEW)) ; \
 	  $(call OptionPair,-doctitle,$(JDI_DOCTITLE)) ; \
@@ -829,9 +829,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JAAS_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JAAS_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionPair,-overview,$(JAAS_OVERVIEW)) ; \
 	  $(call OptionPair,-doctitle,$(JAAS_DOCTITLE)) ; \
@@ -888,9 +888,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JGSS_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JGSS_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-overview,$(JGSS_OVERVIEW)) ; \
@@ -947,9 +947,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(SMARTCARDIO_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(SMARTCARDIO_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(SMARTCARDIO_DOCTITLE)) ; \
@@ -1004,9 +1004,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(HTTPSERVER_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(HTTPSERVER_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(HTTPSERVER_DOCTITLE)) ; \
@@ -1061,9 +1061,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JSOBJECT_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JSOBJECT_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(JSOBJECT_DOCTITLE)) ; \
@@ -1121,9 +1121,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(MGMT_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(MGMT_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-overview,$(MGMT_OVERVIEW)) ; \
@@ -1179,9 +1179,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(ATTACH_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(ATTACH_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(ATTACH_DOCTITLE)) ; \
@@ -1236,9 +1236,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JCONSOLE_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JCONSOLE_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(JCONSOLE_DOCTITLE)) ; \
@@ -1294,9 +1294,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JSHELLAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JSHELLAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionPair,-overview,$(JSHELLAPI_OVERVIEW)) ; \
 	  $(call OptionPair,-doctitle,$(JSHELLAPI_DOCTITLE)) ; \
@@ -1353,9 +1353,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(TREEAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(TREEAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionPair,-doctitle,$(TREEAPI_DOCTITLE)) ; \
 	  $(call OptionPair,-windowtitle,$(TREEAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
@@ -1412,9 +1412,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(NASHORNAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(NASHORNAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionPair,-doctitle,$(NASHORNAPI_DOCTITLE)) ; \
 	  $(call OptionPair,-windowtitle,$(NASHORNAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
@@ -1471,9 +1471,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(DYNALINKAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(DYNALINKAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionPair,-doctitle,$(DYNALINKAPI_DOCTITLE)) ; \
 	  $(call OptionPair,-windowtitle,$(DYNALINKAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \
@@ -1527,9 +1527,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(SCTPAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(SCTPAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(SCTPAPI_DOCTITLE)) ; \
@@ -1584,9 +1584,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
 	  $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:all) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JACCESSAPI_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JACCESSAPI_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(JACCESSAPI_DOCTITLE)) ; \
@@ -1641,9 +1641,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JDKNET_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JDKNET_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(JDKNET_DOCTITLE)) ; \
@@ -1702,9 +1702,9 @@
 	@($(call COMMON_JAVADOCFLAGS) ; \
           $(call COMMON_JAVADOCTAGS) ; \
 	  $(call OptionOnly,-Xdoclint:none) ; \
-          $(call OptionPair,-system,none) ; \
-	  $(call OptionPair,-modulesourcepath,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
-	  $(call OptionPair,-addmods,$(JLINK_PLUGIN_MODULES)) ; \
+          $(call OptionPair,--system,none) ; \
+	  $(call OptionPair,--module-source-path,$(RELEASEDOCS_MODULESOURCEPATH)) ; \
+	  $(call OptionPair,--add-modules,$(JLINK_PLUGIN_MODULES)) ; \
 	  $(call OptionPair,-encoding,ascii) ; \
 	  $(call OptionOnly,-nodeprecatedlist) ; \
 	  $(call OptionPair,-doctitle,$(JLINK_PLUGIN_DOCTITLE)) ; \
--- a/make/common/MakeBase.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/make/common/MakeBase.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -828,7 +828,7 @@
 endif
 
 ################################################################################
-# Return a string suitable for use after a -classpath or -modulepath option. It
+# Return a string suitable for use after a -classpath or --module-path option. It
 # will be correct and safe to use on all platforms. Arguments are given as space
 # separate classpath entries. Safe for multiple nested calls.
 # param 1 : A space separated list of classpath entries
--- a/make/common/SetupJavaCompilers.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/make/common/SetupJavaCompilers.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -88,7 +88,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_USINGJDKBYTECODE, \
     JVM := $(JAVA_SMALL), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -upgrademodulepath $(JDK_OUTPUTDIR)/modules -system none $(DISABLE_WARNINGS), \
+    FLAGS := --upgrade-module-path $(JDK_OUTPUTDIR)/modules -system none $(DISABLE_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
 
--- a/nashorn/.hgtags	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/.hgtags	Fri Aug 19 12:17:32 2016 -0700
@@ -364,3 +364,4 @@
 5a189c5b396c353786343b590f6c19a5d929f01d jdk-9+128
 68020a486500422e2c8b94b0f35cafe54c9e219a jdk-9+129
 0de67a63e2c73781ecf5979a2f3aa9619a445c37 jdk-9+130
+ee77c6b3713ab293e027ac3ea1cc16f86dac535f jdk-9+131
--- a/nashorn/buildtools/nasgen/project.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/buildtools/nasgen/project.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -40,8 +40,8 @@
 javac.debug=true
 
 nasgen.module.imports=\
-    -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
-    -XaddExports:java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED
+    --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
+    --add-exports java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED
 
 meta.inf.dir=${src.dir}/META-INF
 run.classpath=\
--- a/nashorn/make/BuildNashorn.gmk	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/make/BuildNashorn.gmk	Fri Aug 19 12:17:32 2016 -0700
@@ -44,8 +44,8 @@
 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \
     JVM := $(JAVA), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -g -source 9 -target 9 -upgrademodulepath "$(JDK_OUTPUTDIR)/modules/" \
-         -system none -modulesourcepath "$(MODULESOURCEPATH)", \
+    FLAGS := -g -source 9 -target 9 --upgrade-module-path "$(JDK_OUTPUTDIR)/modules/" \
+         --system none --module-source-path "$(MODULESOURCEPATH)", \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
 
@@ -76,9 +76,9 @@
 ifeq ($(BOOT_JDK_MODULAR), true)
   NASGEN_OPTIONS := \
       -cp $(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \
-      -Xpatch:java.base=$(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \
-      -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
-      -XaddExports:java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED \
+      --patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \
+      --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
+      --add-exports java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED \
       #
 else
   NASGEN_OPTIONS := \
--- a/nashorn/make/build.xml	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/make/build.xml	Fri Aug 19 12:17:32 2016 -0700
@@ -178,7 +178,7 @@
       <compilerarg value="-Xdiags:verbose"/>
       <compilerarg value="-parameters"/>
     </javac>
-    <!-- -Xpatch does not like module-info.class files! -->
+    <!-- patch-module does not like module-info.class files! -->
     <delete>
       <fileset dir="${build.classes.dir}" includes="**/module-info.class"/>
     </delete>
@@ -195,7 +195,7 @@
       <compilerarg value="-parameters"/>
       <compilerarg line="${nashorn.override.option}"/>
     </javac>
-    <!-- -Xpatch does not like module-info.class files! -->
+    <!-- patch-module does not like module-info.class files! -->
     <delete>
       <fileset dir="${build.classes.dir}" includes="**/module-info.class"/>
     </delete>
@@ -212,7 +212,7 @@
       <compilerarg value="-parameters"/>
       <compilerarg line="${nashorn.override.option}"/>
     </javac>
-    <!-- -Xpatch does not like module-info.class files! -->
+    <!-- patch-module does not like module-info.class files! -->
     <delete>
       <fileset dir="${build.classes.dir}" includes="**/module-info.class"/>
     </delete>
@@ -266,7 +266,7 @@
     <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${nashorn.module.src.dir}/overview.html"
         windowtitle="${nashorn.product.name} ${nashorn.version}"
         additionalparam="-quiet" failonerror="true" useexternalfile="true">
-      <arg value="-modulesourcepath"/>
+      <arg value="--module-source-path"/>
       <arg value="${basedir}/src/*/share/classes"/>
       <arg value="${javadoc.option}"/>
       <classpath>
@@ -285,7 +285,7 @@
     <javadoc destdir="${dist.nashornapi.javadoc.dir}" use="yes" overview="${nashorn.module.src.dir}/overview.html"
         extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
         additionalparam="-quiet" failonerror="true" useexternalfile="true">
-      <arg value="-modulesourcepath"/>
+      <arg value="--module-source-path"/>
       <arg value="${basedir}/src/*/share/classes"/>
       <arg value="${javadoc.option}"/>
       <classpath>
@@ -302,7 +302,7 @@
     <javadoc destdir="${dist.dynalinkapi.javadoc.dir}" use="yes"
         windowtitle="Dynalink"
         additionalparam="-quiet" failonerror="true" useexternalfile="true">
-      <arg value="-modulesourcepath"/>
+      <arg value="--module-source-path"/>
       <arg value="${basedir}/src/*/share/classes"/>
       <arg value="${javadoc.option}"/>
       <classpath>
--- a/nashorn/make/project.properties	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/make/project.properties	Fri Aug 19 12:17:32 2016 -0700
@@ -51,9 +51,9 @@
 build.gzip=${build.dir}/nashorn.tar.gz
 
 nashorn.override.option=\
- -Xpatch:jdk.scripting.nashorn=${build.classes.dir}/jdk.scripting.nashorn \
- -Xpatch:jdk.scripting.nashorn.shell=${build.classes.dir}/jdk.scripting.nashorn.shell \
- -Xpatch:jdk.dynalink=${build.classes.dir}/jdk.dynalink
+ --patch-module jdk.scripting.nashorn=${build.classes.dir}/jdk.scripting.nashorn \
+ --patch-module jdk.scripting.nashorn.shell=${build.classes.dir}/jdk.scripting.nashorn.shell \
+ --patch-module jdk.dynalink=${build.classes.dir}/jdk.dynalink
 
 # project directory of <nashorn> ant task
 nashorntask.dir=buildtools/nashorntask
@@ -65,8 +65,8 @@
 nasgen.tool=jdk.nashorn.internal.tools.nasgen.Main
 
 nasgen.module.imports=\
-    -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
-    -XaddExports:java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED
+    --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
+    --add-exports java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED
 
 # parallel test runner tool
 parallel.test.runner=jdk.nashorn.internal.test.framework.ParallelTestRunner
@@ -142,19 +142,19 @@
     ${file.reference.snakeyaml.jar}
 
 test.module.imports=\
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.ir=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.codegen=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.parser=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.objects=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.doubleconv=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.events=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.options=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp.joni=ALL-UNNAMED \
-    -XaddExports:jdk.scripting.nashorn/jdk.nashorn.tools=ALL-UNNAMED \
-    -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.ir=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.codegen=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.parser=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.objects=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.doubleconv=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.events=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.options=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.internal.runtime.regexp.joni=ALL-UNNAMED \
+    --add-exports jdk.scripting.nashorn/jdk.nashorn.tools=ALL-UNNAMED \
+    --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED
 
 meta.inf.dir=${nashorn.module.src.dir}/META-INF
 
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java	Fri Aug 19 12:17:32 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, 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
@@ -324,6 +324,8 @@
                 }
                 versionDir.mkdirs();
                 if (versionDir.isDirectory()) {
+                    //FIXME:Logger is disabled as Context.getContext() always returns null here because global scope object will not be created
+                    //by the time this method gets invoked
                     getLogger().info("Optimistic type persistence directory is " + versionDir);
                     return versionDir;
                 }
@@ -450,10 +452,12 @@
     private static DebugLogger getLogger() {
         try {
             return Context.getContext().getLogger(RecompilableScriptFunctionData.class);
+        } catch (final NullPointerException e) {
+            //Don't print stacktrace until we revisit this, NPE is a known issue here
         } catch (final Exception e) {
             e.printStackTrace();
-            return DebugLogger.DISABLED_LOGGER;
         }
+        return DebugLogger.DISABLED_LOGGER;
     }
 
     private static void scheduleCleanup() {
--- a/nashorn/test/TEST.ROOT	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/test/TEST.ROOT	Fri Aug 19 12:17:32 2016 -0700
@@ -8,7 +8,7 @@
 groups=TEST.groups
 
 # Minimum jtreg version
-requiredVersion=4.2 b02
+requiredVersion=4.2 b03
 
-# Use new form of -Xpatch
-useNewXpatch=true
+# Use new module options
+useNewOptions=true
--- a/nashorn/test/script/currently-failing/JDK-8055034.js	Fri Aug 19 10:09:53 2016 -0400
+++ b/nashorn/test/script/currently-failing/JDK-8055034.js	Fri Aug 19 12:17:32 2016 -0700
@@ -51,7 +51,7 @@
     jjsCmd = javahome + "/bin/jjs";
     jjsCmd = jjsCmd.toString().replace(/\//g, File.separator);
 }
-jjsCmd += " -J-Xpatch:" + nashornJar;
+jjsCmd += " -J--patch-module=jdk.scripting.nashorn=" + nashornJar;
 
 $ENV.PWD=System.getProperty("user.dir") // to avoid RE on Cygwin
 $EXEC(jjsCmd, "var x = Object.create(null);\nx;\nprint('PASSED');\nexit(0)");