Merge
authoralanb
Tue, 03 May 2016 11:38:13 +0100
changeset 37849 3c7998b21c27
parent 37761 82b8d12a553f (current diff)
parent 37848 3c8ff4204d2d (diff)
child 37850 24e70308f4ea
Merge
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties
langtools/test/tools/javac/modules/AddLimitMods.java
--- a/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -48,6 +48,13 @@
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.Log;
 
+/*
+ * This code must be run in a context that provides
+ * access to the following javac internal packages:
+ *      com.sun.tools.javac.api
+ *      com.sun.tools.javac.tree
+ *      com.sun.tools.javac.util
+ */
 public class CodingRulesAnalyzerPlugin implements Plugin {
 
     protected Log log;
@@ -55,11 +62,6 @@
 
     @DefinedBy(Api.COMPILER_TREE)
     public void init(JavacTask task, String... args) {
-        addExports("jdk.compiler",
-                "com.sun.tools.javac.api",
-                "com.sun.tools.javac.code",
-                "com.sun.tools.javac.tree",
-                "com.sun.tools.javac.util");
         BasicJavacTask impl = (BasicJavacTask)task;
         Context context = impl.getContext();
         log = Log.instance(context);
--- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java	Tue May 03 11:38:13 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, 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,8 +25,10 @@
 
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import com.sun.source.util.JavacTask;
 import com.sun.source.util.TaskEvent.Kind;
@@ -48,16 +50,8 @@
     }
 
     private boolean ignoreField(String className, String field) {
-        List<String> currentFieldsToIgnore =
-                classFieldsToIgnoreMap.get(className);
-        if (currentFieldsToIgnore != null) {
-            for (String fieldToIgnore : currentFieldsToIgnore) {
-                if (field.equals(fieldToIgnore)) {
-                    return true;
-                }
-            }
-        }
-        return false;
+        Set<String> fieldsToIgnore = classFieldsToIgnoreMap.get(className);
+        return (fieldsToIgnore) != null && fieldsToIgnore.contains(field);
     }
 
     class MutableFieldsVisitor extends TreeScanner {
@@ -89,34 +83,29 @@
 
     private static final String packageToCheck = "com.sun.tools.javac";
 
-    private static final Map<String, List<String>> classFieldsToIgnoreMap =
+    private static final Map<String, Set<String>> classFieldsToIgnoreMap =
                 new HashMap<>();
 
+    private static void ignoreFields(String className, String... fieldNames) {
+        classFieldsToIgnoreMap.put(className, new HashSet<>(Arrays.asList(fieldNames)));
+    };
+
     static {
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.util.JCDiagnostic",
-                    Arrays.asList("fragmentFormatter"));
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.util.JavacMessages",
-                    Arrays.asList("defaultBundle", "defaultMessages"));
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.file.ZipFileIndexCache",
-                    Arrays.asList("sharedInstance"));
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.file.JRTIndex",
-                    Arrays.asList("sharedInstance"));
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.main.JavaCompiler",
-                    Arrays.asList("versionRB"));
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.code.Type",
-                    Arrays.asList("moreInfo"));
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.util.SharedNameTable",
-                    Arrays.asList("freelist"));
-        classFieldsToIgnoreMap.
-                put("com.sun.tools.javac.util.Log",
-                    Arrays.asList("useRawMessages"));
+        ignoreFields("com.sun.tools.javac.util.JCDiagnostic", "fragmentFormatter");
+        ignoreFields("com.sun.tools.javac.util.JavacMessages", "defaultBundle", "defaultMessages");
+        ignoreFields("com.sun.tools.javac.file.JRTIndex", "sharedInstance");
+        ignoreFields("com.sun.tools.javac.main.JavaCompiler", "versionRB");
+        ignoreFields("com.sun.tools.javac.code.Type", "moreInfo");
+        ignoreFields("com.sun.tools.javac.util.SharedNameTable", "freelist");
+        ignoreFields("com.sun.tools.javac.util.Log", "useRawMessages");
+        ignoreFields("com.sun.tools.javac.util.ModuleWrappers$ModuleFinderHelper",
+                "moduleFinderInterface", "ofMethod", "emptyMethod");
+        ignoreFields("com.sun.tools.javac.util.ModuleWrappers$ConfigurationHelper",
+                "configurationClass", "resolveRequiresAndUsesMethod");
+        ignoreFields("com.sun.tools.javac.util.ModuleWrappers$LayerHelper",
+                "layerClass", "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod");
+        ignoreFields("com.sun.tools.javac.util.ModuleHelper",
+                "addExportsMethod", "getUnnamedModuleMethod", "getModuleMethod");
     }
 
 }
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java	Tue May 03 11:38:13 2016 +0100
@@ -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,12 +49,22 @@
     /**
      * Returns a package given its fully qualified name.
      *
-     * @param name  fully qualified package name, or "" for an unnamed package
+     * @param name  fully qualified package name, or an empty string for an unnamed package
      * @return the named package, or {@code null} if it cannot be found
      */
     PackageElement getPackageElement(CharSequence name);
 
     /**
+     * Returns a package given its fully qualified name, as seen from the given module.
+     *
+     * @param name  fully qualified package name, or an empty string for an unnamed package
+     * @param module module relative to which the lookup should happen
+     * @return the named package, or {@code null} if it cannot be found
+     * @since 9
+     */
+    PackageElement getPackageElement(ModuleElement module, CharSequence name);
+
+    /**
      * Returns a type element given its canonical name.
      *
      * @param name  the canonical name
@@ -63,6 +73,16 @@
     TypeElement getTypeElement(CharSequence name);
 
     /**
+     * Returns a type element given its canonical name, as seen from the given module.
+     *
+     * @param name  the canonical name
+     * @param module module relative to which the lookup should happen
+     * @return the named type element, or {@code null} if it cannot be found
+     * @since 9
+     */
+    TypeElement getTypeElement(ModuleElement module, CharSequence name);
+
+    /**
      * Returns a module element given its fully qualified name.
      *
      * @param name  the name
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Tue May 03 11:38:13 2016 +0100
@@ -960,12 +960,12 @@
             return n;
         }
 
-        @Override
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public <R, P> R accept(ElementVisitor<R, P> v, P p) {
             return v.visitModule(this, p);
         }
 
-        @Override
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public List<Symbol> getEnclosedElements() {
             List<Symbol> list = List.nil();
             for (Symbol sym : enclosedPackages) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Tue May 03 11:38:13 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -1588,17 +1588,17 @@
             return v.visitModuleType(this, s);
         }
 
-        @Override
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public String toString() {
             return tsym.getQualifiedName().toString();
         }
 
-        @Override
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public TypeKind getKind() {
             return TypeKind.MODULE;
         }
 
-        @Override
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public <R, P> R accept(TypeVisitor<R, P> v, P p) {
             return v.visitNoType(this, p);
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Tue May 03 11:38:13 2016 +0100
@@ -131,6 +131,9 @@
 
     private final String moduleOverride;
 
+    private final Name java_se;
+    private final Name java_;
+
     ModuleSymbol defaultModule;
 
     private final String addExportsOpt;
@@ -173,6 +176,9 @@
         JNIWriter jniWriter = JNIWriter.instance(context);
         jniWriter.multiModuleMode = multiModuleMode;
 
+        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);
@@ -761,17 +767,17 @@
         private void checkForCorrectness() {
             for (Directive.ProvidesDirective provides : allProvides) {
                 JCProvides tree = directiveToTreeMap.get(provides);
-                /** The implementation must be defined in the same module as the provides directive
-                 *  (else, error)
+                /* The implementation must be defined in the same module as the provides directive
+                 * (else, error)
                  */
                 PackageSymbol implementationDefiningPackage = provides.impl.packge();
                 if (implementationDefiningPackage.modle != msym) {
                     log.error(tree.pos(), Errors.ServiceImplementationNotInRightModule(implementationDefiningPackage.modle));
                 }
 
-                /** There is no inherent requirement that module that provides a service should actually
-                 *  use it itself. However, it is a pointless declaration if the service package is not
-                 *  exported and there is no uses for the service.
+                /* There is no inherent requirement that module that provides a service should actually
+                 * use it itself. However, it is a pointless declaration if the service package is not
+                 * exported and there is no uses for the service.
                  */
                 PackageSymbol interfaceDeclaringPackage = provides.service.packge();
                 boolean isInterfaceDeclaredInCurrentModule = interfaceDeclaringPackage.modle == msym;
@@ -826,8 +832,22 @@
         Set<ModuleSymbol> enabledRoot = new LinkedHashSet<>();
 
         if (rootModules.contains(syms.unnamedModule)) {
-            for (ModuleSymbol sym : syms.getAllModules()) {
-                if (systemModulePred.test(sym) && observablePred.test(sym)) {
+            ModuleSymbol javaSE = syms.getModule(java_se);
+            Predicate<ModuleSymbol> jdkModulePred;
+
+            if (javaSE != null && (observable == null || observable.contains(javaSE))) {
+                jdkModulePred = sym -> {
+                    sym.complete();
+                    return   !sym.name.startsWith(java_)
+                           && sym.exports.stream().anyMatch(e -> e.modules == null);
+                };
+                enabledRoot.add(javaSE);
+            } else {
+                jdkModulePred = sym -> true;
+            }
+
+            for (ModuleSymbol sym : new HashSet<>(syms.getAllModules())) {
+                if (systemModulePred.test(sym) && observablePred.test(sym) && jdkModulePred.test(sym)) {
                     enabledRoot.add(sym);
                 }
             }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Tue May 03 11:38:13 2016 +0100
@@ -74,6 +74,8 @@
 import com.sun.tools.javac.main.Option;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.resources.CompilerProperties.Warnings;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.ListBuffer;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Pair;
@@ -813,7 +815,7 @@
      * SYSTEM_MODULES and MODULE_PATH.
      *
      * The Location can be specified to accept overriding classes from the
-     * -Xpatch:dir parameter.
+     * {@code -Xpatch:<module>=<path> } parameter.
      */
     private class ModuleLocationHandler extends LocationHandler implements Location {
         protected final String name;
@@ -829,47 +831,27 @@
             this.searchPath = searchPath;
             this.output = output;
 
-            if (allowOverrides) {
-                if (patchMap != null) {
-                    SearchPath mPatch = patchMap.get(moduleName);
-                    if (mPatch != null) {
-                        SearchPath sp = new SearchPath();
-                        sp.addAll(mPatch);
-                        sp.addAll(searchPath);
-                        searchPathWithOverrides = sp;
-                    } else {
-                        searchPathWithOverrides = searchPath;
-                    }
+            if (allowOverrides && patchMap != null) {
+                SearchPath mPatch = patchMap.get(moduleName);
+                if (mPatch != null) {
+                    SearchPath sp = new SearchPath();
+                    sp.addAll(mPatch);
+                    sp.addAll(searchPath);
+                    searchPathWithOverrides = sp;
                 } else {
-                     // for old style patch option; retained for transition
-                    Set<Path> overrides = new LinkedHashSet<>();
-                    if (moduleOverrideSearchPath != null) {
-                       for (Path p: moduleOverrideSearchPath) {
-                           Path o = p.resolve(moduleName);
-                           if (Files.isDirectory(o)) {
-                               overrides.add(o);
-                           }
-                       }
-                    }
-
-                    if (!overrides.isEmpty()) {
-                        overrides.addAll(searchPath);
-                        searchPathWithOverrides = overrides;
-                    } else {
-                        searchPathWithOverrides = searchPath;
-                    }
+                    searchPathWithOverrides = searchPath;
                 }
             } else {
                 searchPathWithOverrides = searchPath;
             }
         }
 
-        @Override // defined by Location
+        @Override @DefinedBy(Api.COMPILER)
         public String getName() {
             return name;
         }
 
-        @Override // defined by Location
+        @Override @DefinedBy(Api.COMPILER)
         public boolean isOutputLocation() {
             return output;
         }
@@ -1522,41 +1504,33 @@
         }
     }
 
-    private SearchPath moduleOverrideSearchPath; // for old style patch option; retained for transition
     private Map<String, SearchPath> patchMap;
 
     boolean handleOption(Option option, String value) {
         switch (option) {
             case XPATCH:
-                if (value.contains("=")) {
-                    Map<String, SearchPath> map = new LinkedHashMap<>();
-                    for (String entry: value.split(",")) {
-                        int eq = entry.indexOf('=');
-                        if (eq > 0) {
-                            String mName = entry.substring(0, eq);
-                            SearchPath mPatchPath = new SearchPath()
-                                    .addFiles(entry.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 && !mPatchPath.isEmpty()) {
-                                map.computeIfAbsent(mName, (_x) -> new SearchPath())
-                                        .addAll(mPatchPath);
-                            }
-                        } else {
-                            log.error(Errors.LocnInvalidArgForXpatch(entry));
+                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;
                         }
                     }
-                    patchMap = map;
+                    if (ok && !mPatchPath.isEmpty()) {
+                        map.computeIfAbsent(mName, (_x) -> new SearchPath())
+                                .addAll(mPatchPath);
+                    }
                 } else {
-                     // for old style patch option; retained for transition
-                    moduleOverrideSearchPath = new SearchPath().addFiles(value);
+                    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/main/Option.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Tue May 03 11:38:13 2016 +0100
@@ -199,7 +199,7 @@
 
     SYSTEM("-system", "opt.arg.jdk", "opt.system", STANDARD, FILEMANAGER),
 
-    XPATCH("-Xpatch:", "opt.arg.path", "opt.Xpatch", EXTENDED, FILEMANAGER),
+    XPATCH("-Xpatch:", "opt.arg.patch", "opt.patch", EXTENDED, FILEMANAGER),
 
     BOOTCLASSPATH("-bootclasspath", "opt.arg.path", "opt.bootclasspath", STANDARD, FILEMANAGER) {
         @Override
@@ -529,83 +529,21 @@
     XADDEXPORTS("-XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) {
         @Override
         public boolean process(OptionHelper helper, String option) {
-            if (option.matches(".*,.*=.*")) { // temporary, for backwards compatibility
-                return processOldStyle(helper, option);
-            }
             String p = option.substring(option.indexOf(':') + 1).trim();
             String prev = helper.get(XADDEXPORTS);
             helper.put(XADDEXPORTS.text, (prev == null) ? p : prev + '\0' + p);
             return false;
         }
-
-        // convert old style option into a series of new-style options
-        private boolean processOldStyle(OptionHelper helper, String option) {
-            String p = option.substring(option.indexOf(':') + 1).trim();
-            String[] entries = p.split("[ ,]+");
-            Map<String, String> map = new LinkedHashMap<>();
-            for (String e: entries) {
-                // Each entry is of the form   module/package=target
-                // we must group values for the same module/package together
-                int eq = e.indexOf('=');
-                if (eq == -1) {
-                    // don't bother with error message for backwards compatible support
-                    continue;
-                }
-                String modPkg = e.substring(0, eq);
-                String target = e.substring(eq + 1);
-                String targets = map.get(modPkg);
-                map.put(modPkg, (targets == null) ? target : targets + "," + target);
-            }
-            boolean ok = true;
-            for (Map.Entry<String, String> e: map.entrySet()) {
-                // process as new-style options
-                String key = e.getKey();
-                String value = e.getValue();
-                ok = ok & process(helper, XADDEXPORTS.text + key + "=" + value);
-            };
-            return ok;
-        }
     },
 
     XADDREADS("-XaddReads:", "opt.arg.addReads", "opt.addReads", EXTENDED, BASIC) {
         @Override
         public boolean process(OptionHelper helper, String option) {
-            if (option.matches(".*,.*=.*")) { // temporary, for backwards compatibility
-                return processOldStyle(helper, option);
-            }
             String p = option.substring(option.indexOf(':') + 1).trim();
             String prev = helper.get(XADDREADS);
             helper.put(XADDREADS.text, (prev == null) ? p : prev + '\0' + p);
             return false;
         }
-
-        // convert old style option into a series of new-style options
-        private boolean processOldStyle(OptionHelper helper, String option) {
-            String p = option.substring(option.indexOf(':') + 1).trim();
-            String[] entries = p.split("[ ,]+");
-            Map<String, String> map = new LinkedHashMap<>();
-            for (String e: entries) {
-                // Each entry is of the form   module=target
-                // we must group values for the same module together
-                int eq = e.indexOf('=');
-                if (eq == -1) {
-                    // don't bother with error message for backwards compatible support
-                    continue;
-                }
-                String modPkg = e.substring(0, eq);
-                String target = e.substring(eq + 1);
-                String targets = map.get(modPkg);
-                map.put(modPkg, (targets == null) ? target : targets + "," + target);
-            }
-            boolean ok = true;
-            for (Map.Entry<String, String> e: map.entrySet()) {
-                // process as new-style options
-                String key = e.getKey();
-                String value = e.getValue();
-                ok = ok & process(helper, XADDEXPORTS.text + key + "=" + value);
-            };
-            return ok;
-        }
     },
 
     XMODULE("-Xmodule:", "opt.arg.module", "opt.module", EXTENDED, BASIC) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Tue May 03 11:38:13 2016 +0100
@@ -107,12 +107,13 @@
         return modules.getObservableModule(names.fromString(strName));
     }
 
-    @DefinedBy(Api.LANGUAGE_MODEL)
+    @Override @DefinedBy(Api.LANGUAGE_MODEL)
     public PackageSymbol getPackageElement(CharSequence name) {
         ensureEntered("getPackageElement");
         return getPackageElement(modules.getDefaultModule(), name);
     }
 
+    @Override @DefinedBy(Api.LANGUAGE_MODEL)
     public PackageSymbol getPackageElement(ModuleElement module, CharSequence name) {
         String strName = name.toString();
         if (strName.equals(""))
@@ -122,12 +123,13 @@
             : null;
     }
 
-    @DefinedBy(Api.LANGUAGE_MODEL)
+    @Override @DefinedBy(Api.LANGUAGE_MODEL)
     public ClassSymbol getTypeElement(CharSequence name) {
         ensureEntered("getTypeElement");
         return getTypeElement(modules.getDefaultModule(), name);
     }
 
+    @Override @DefinedBy(Api.LANGUAGE_MODEL)
     public ClassSymbol getTypeElement(ModuleElement module, CharSequence name) {
         String strName = name.toString();
         return SourceVersion.isName(strName)
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Tue May 03 11:38:13 2016 +0100
@@ -53,12 +53,6 @@
     Override location of system modules
 javac.opt.upgrademodulepath=\
     Override location of upgradeable modules
-javac.opt.Xbootclasspath.p=\
-    Prepend to the bootstrap class path
-javac.opt.Xbootclasspath.a=\
-    Append to the bootstrap class path
-javac.opt.Xpatch=\
-    Specify location of module class files to patch
 javac.opt.endorseddirs=\
     Override location of endorsed standards path
 javac.opt.extdirs=\
@@ -160,6 +154,10 @@
     <pathname>
 javac.opt.arg.file=\
     <filename>
+javac.opt.Xbootclasspath.p=\
+    Prepend to the bootstrap class path
+javac.opt.Xbootclasspath.a=\
+    Append to the bootstrap class path
 javac.opt.Xlint=\
     Enable recommended warnings
 javac.opt.Xlint.all=\
@@ -286,6 +284,11 @@
 \        <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.arg.patch=\
+    <module>=<file>(:<file>)*
 javac.opt.module=\
     Specify a module to which the classes being compiled belong.
 javac.opt.arg.module=\
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue May 03 11:38:13 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -2626,22 +2626,22 @@
         @Override
         public void accept(Visitor v) { v.visitModuleDef(this); }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() {
             return Kind.MODULE;
         }
 
-//        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getName() {
             return qualId;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public List<JCDirective> getDirectives() {
             return directives;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
             return v.visitModule(this, d);
         }
@@ -2666,22 +2666,22 @@
         @Override
         public void accept(Visitor v) { v.visitExports(this); }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() {
             return Kind.EXPORTS;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getExportName() {
             return qualid;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public List<JCExpression> getModuleNames() {
             return moduleNames;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
             return v.visitExports(this, d);
         }
@@ -2705,22 +2705,22 @@
         @Override
         public void accept(Visitor v) { v.visitProvides(this); }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() {
             return Kind.PROVIDES;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
             return v.visitProvides(this, d);
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getServiceName() {
             return serviceName;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getImplementationName() {
             return implName;
         }
@@ -2745,22 +2745,22 @@
         @Override
         public void accept(Visitor v) { v.visitRequires(this); }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() {
             return Kind.REQUIRES;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
             return v.visitRequires(this, d);
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public boolean isPublic() {
             return isPublic;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getModuleName() {
             return moduleName;
         }
@@ -2782,17 +2782,17 @@
         @Override
         public void accept(Visitor v) { v.visitUses(this); }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() {
             return Kind.USES;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public JCExpression getServiceName() {
             return qualid;
         }
 
-        @Override
+        @Override @DefinedBy(Api.COMPILER_TREE)
         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
             return v.visitUses(this, d);
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -505,7 +505,7 @@
         return M.at(t.pos).Wildcard(kind, inner);
     }
 
-    @Override
+    @Override @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitModule(ModuleTree node, P p) {
         JCModuleDecl t = (JCModuleDecl) node;
         JCExpression qualId = copy(t.qualId);
@@ -513,7 +513,7 @@
         return M.at(t.pos).ModuleDef(qualId, directives);
     }
 
-    @Override
+    @Override @DefinedBy(Api.COMPILER_TREE)
     public JCExports visitExports(ExportsTree node, P p) {
         JCExports t = (JCExports) node;
         JCExpression qualId = copy(t.qualid, p);
@@ -521,7 +521,7 @@
         return M.at(t.pos).Exports(qualId, moduleNames);
     }
 
-    @Override
+    @Override @DefinedBy(Api.COMPILER_TREE)
     public JCProvides visitProvides(ProvidesTree node, P p) {
         JCProvides t = (JCProvides) node;
         JCExpression serviceName = copy(t.serviceName, p);
@@ -529,14 +529,14 @@
         return M.at(t.pos).Provides(serviceName, implName);
     }
 
-    @Override
+    @Override @DefinedBy(Api.COMPILER_TREE)
     public JCRequires visitRequires(RequiresTree node, P p) {
         JCRequires t = (JCRequires) node;
         JCExpression moduleName = copy(t.moduleName, p);
         return M.at(t.pos).Requires(t.isPublic, moduleName);
     }
 
-    @Override
+    @Override @DefinedBy(Api.COMPILER_TREE)
     public JCUses visitUses(UsesTree node, P p) {
         JCUses t = (JCUses) node;
         JCExpression serviceName = copy(t.qualid, p);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleWrappers.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleWrappers.java	Tue May 03 11:38:13 2016 +0100
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javac.util;
 
-import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.nio.file.Path;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java	Tue May 03 11:38:13 2016 +0100
@@ -203,7 +203,7 @@
         return file;
     }
 
-    @Override
+    @Override @DefinedBy(Api.COMPILER)
     public Location getModuleLocation(Location location, JavaFileObject fo, String pkgName) throws IOException {
         return super.getModuleLocation(location, locUnwrap(fo), pkgName);
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Tue May 03 11:38:13 2016 +0100
@@ -339,7 +339,8 @@
 
 doclet.xusage.xdoclint-package.name=Xdoclint/package:
 doclet.xusage.xdoclint-package.parameters=([-]<packages>)
-doclet.xusage.xdoclint-package.description=Enable or disable checks in specific packages. <packages> is a comma separated\n\
+doclet.xusage.xdoclint-package.description=\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\
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Tue May 03 11:38:13 2016 +0100
@@ -1140,7 +1140,7 @@
          */
         @Override
         public String toString() {
-            String opt = name + " " + parameters;
+            String opt = name + (name.endsWith(":") ? "" : " ") + parameters;
             int optlen = opt.length();
             int spaces = 32 - optlen;
             StringBuffer sb = new StringBuffer("  -").append(opt);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -73,7 +73,9 @@
 \                                   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:<path>                   Specify location of module class files to patch\n\
+\  -Xpatch:<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
 
 main.Xusage.foot=\
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -231,6 +231,7 @@
     }
 
     // Make compatible with Jigsaw
+    @DefinedBy(Api.COMPILER)
     public String inferModuleName(Location location) {
         try {
             if (inferModuleNameMethod == null) {
@@ -249,6 +250,7 @@
     }
 
     // Make compatible with Jigsaw
+    @DefinedBy(Api.COMPILER)
     public Iterable<Set<Location>> listModuleLocations(Location location) throws IOException {
         try {
             if (listModuleLocationsMethod == null) {
--- a/langtools/test/TEST.ROOT	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/TEST.ROOT	Tue May 03 11:38:13 2016 +0100
@@ -14,5 +14,8 @@
 # Group definitions
 groups=TEST.groups
 
-# Tests using jtreg 4.2 b01 features
-requiredVersion=4.2 b01
+# Tests using jtreg 4.2 b02 features
+requiredVersion=4.2 b02
+
+# Use new form of -Xpatch
+useNewXpatch=true
--- a/langtools/test/tools/all/RunCodingRules.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/all/RunCodingRules.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -25,11 +25,7 @@
  * @test
  * @bug 8043643
  * @summary Run the langtools coding rules over the langtools source code.
- * @modules java.base/sun.reflect.annotation
- *          java.logging
- *          java.xml
- *          jdk.compiler/com.sun.tools.javac.resources
- *          jdk.compiler/com.sun.tools.javac.util
+ * @modules jdk.compiler/com.sun.tools.javac.util
  */
 
 
@@ -58,25 +54,33 @@
 
     public void run() throws Exception {
         Path testSrc = Paths.get(System.getProperty("test.src", "."));
-        Path targetDir = Paths.get(System.getProperty("test.classes", "."));
+        Path targetDir = Paths.get(".");
         List<Path> sourceDirs = null;
         Path crulesDir = null;
+        Path mainSrcDir = null;
+        List<Path> genSrcDirs = null;
         for (Path d = testSrc; d != null; d = d.getParent()) {
             if (Files.exists(d.resolve("TEST.ROOT"))) {
                 d = d.getParent();
                 Path toolsPath = d.resolve("make/tools");
-                if (Files.exists(toolsPath)) {
+                Path buildDir = d.getParent().resolve("build");
+                if (Files.exists(toolsPath) && Files.exists(buildDir)) {
+                    mainSrcDir = d.resolve("src");
                     crulesDir = toolsPath;
-                    sourceDirs = Files.walk(d.resolve("src"), 1)
+                    sourceDirs = Files.walk(mainSrcDir, 1)
                                       .map(p -> p.resolve("share/classes"))
                                       .filter(p -> Files.isDirectory(p))
                                       .collect(Collectors.toList());
+                    genSrcDirs = Files.walk(buildDir, 1)
+                                      .map(p -> p.resolve("support/gensrc"))
+                                      .filter(p -> Files.isDirectory(p.resolve("jdk.compiler")))
+                                      .collect(Collectors.toList());
                     break;
                 }
             }
         }
 
-        if (sourceDirs == null || crulesDir == null) {
+        if (sourceDirs == null || crulesDir == null || genSrcDirs == null) {
             System.err.println("Warning: sources not found, test skipped.");
             return ;
         }
@@ -96,12 +100,11 @@
             Path crulesTarget = targetDir.resolve("crules");
             Files.createDirectories(crulesTarget);
             List<String> crulesOptions = Arrays.asList(
-                    "-XaddExports:"
-                        + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
-                        + "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED,"
-                        + "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED,"
-                        + "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED,"
-                        + "jdk.compiler/com.sun.tools.javac.util=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.model=ALL-UNNAMED",
+                    "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+                    "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
                     "-d", crulesTarget.toString());
             javaCompiler.getTask(null, fm, noErrors, crulesOptions, null,
                     fm.getJavaFileObjectsFromFiles(crulesFiles)).call();
@@ -117,11 +120,36 @@
                                            .map(p -> p.toFile())
                                            .collect(Collectors.toList());
 
+            String FS = File.separator;
+            String PS = File.pathSeparator;
+
+            Path genSrcTarget = targetDir.resolve("gensrc");
+            List<String> genSrcFiles = Arrays.asList(
+                    "jdk.compiler/com/sun/tools/javac/resources/CompilerProperties.java"
+                );
+            for (String f : genSrcFiles) {
+                for (Path dir : genSrcDirs) {
+                    Path from = dir.resolve(f.replace("/", FS));
+                    if (Files.exists(from)) {
+                        try {
+                            Path to = genSrcTarget.resolve(f.replace("/", FS));
+                            Files.createDirectories(to.getParent());
+                            Files.copy(from, to);
+                        } catch (IOException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+
             Path sourceTarget = targetDir.resolve("classes");
             Files.createDirectories(sourceTarget);
-            String processorPath = crulesTarget.toString() + File.pathSeparator + crulesDir.toString();
+            String processorPath = crulesTarget + PS + crulesDir;
+
             List<String> options = Arrays.asList(
                     "-d", sourceTarget.toString(),
+                    "-modulesourcepath", mainSrcDir + FS + "*" + FS + "share" + FS + "classes" + PS + genSrcTarget,
+                    "-XDaccessInternalAPI",
                     "-processorpath", processorPath,
                     "-Xplugin:coding_rules");
             javaCompiler.getTask(null, fm, noErrors, options, null,
--- a/langtools/test/tools/javac/T6358024.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/T6358024.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -69,10 +69,10 @@
 
         JavacTool tool = JavacTool.create();
         List<String> flags = new ArrayList<String>();
-        flags.add("-XaddExports:"
-                + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
+        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"));
         for (Option opt: opts) {
             flags.add(opt.name);
             for (Object arg : opt.args)
--- a/langtools/test/tools/javac/T6358166.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/T6358166.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -42,8 +42,7 @@
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.main.JavaCompiler;
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List; // disambiguate
+import com.sun.tools.javac.util.Context;
 
 
 @SupportedAnnotationTypes("*")
@@ -56,22 +55,26 @@
         JavacFileManager fm = new JavacFileManager(new Context(), false, null);
         JavaFileObject f = fm.getJavaFileObject(testSrc + File.separatorChar + self + ".java");
 
-        String addExports = "-XaddExports:"
-                + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED";
+        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");
 
         test(fm, f, addExports, "-verbose", "-d", ".");
 
         test(fm, f, addExports, "-verbose", "-d", ".", "-XprintRounds", "-processorpath", ".", "-processor", self);
     }
 
-    static void test(JavacFileManager fm, JavaFileObject f, String... args) throws Throwable {
+    static void test(JavacFileManager fm, JavaFileObject f, List<String> addExports, String... args) throws Throwable {
+        List<String> allArgs = new ArrayList<>();
+        allArgs.addAll(addExports);
+        allArgs.addAll(Arrays.asList(args));
+
         Context context = new Context();
 
         JavacTool tool = JavacTool.create();
-        JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, fm, null, Arrays.asList(args), null, List.of(f), context);
+        JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, fm, null, allArgs, null, List.of(f), context);
         task.call();
 
         JavaCompiler c = JavaCompiler.instance(context);
--- a/langtools/test/tools/javac/T6406771.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/T6406771.java	Tue May 03 11:38:13 2016 +0100
@@ -50,9 +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,"
-                + "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
+                "-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
+                "-XaddExports:jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
                 "-XDaccessInternalAPI",
                 "-d", ".",
                 "-processorpath", testClasses,
--- a/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -143,12 +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,"
-                    + "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED,"
-                    + "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED,"
-                    + "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED,"
-                    + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                "-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",
                 "-d", System.getProperty("user.dir")
             );
             JavacTask task = (JavacTask) c.getTask(null, fm, null, options, null, fos);
--- a/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -73,11 +73,11 @@
         final Iterable<? extends JavaFileObject> compilationUnits =
             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,"
-                + "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED");
+        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");
         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/diags/CheckResourceKeys.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java	Tue May 03 11:38:13 2016 +0100
@@ -294,6 +294,7 @@
             "opt.Xlint.desc.",
             "count.",
             "illegal.",
+            "java.",
             "javac.",
             "verbose.",
             "locn."
--- a/langtools/test/tools/javac/file/T7018098.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/file/T7018098.java	Tue May 03 11:38:13 2016 +0100
@@ -60,10 +60,9 @@
         _assert(!testDir.exists());
 
         compile(
-            "-XaddExports:"
-                + "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+            "-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",
             "-XDaccessInternalAPI",
             "-proc:only",
             "-processor", myName,
@@ -74,10 +73,9 @@
         _assert(testDir.exists());
 
         compile(
-            "-XaddExports:"
-                + "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+            "-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",
             "-XDaccessInternalAPI",
             "-proc:only",
             "-processor", myName,
--- a/langtools/test/tools/javac/modules/AddLimitMods.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java	Tue May 03 11:38:13 2016 +0100
@@ -40,6 +40,7 @@
 import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -69,7 +70,6 @@
 import toolbox.JavacTask;
 import toolbox.JavaTask;
 import toolbox.Task;
-import toolbox.ToolBox;
 
 public class AddLimitMods extends ModuleTestBase {
 
@@ -176,6 +176,58 @@
     }
 
     @Test
+    public void testObservableForUnnamed(Path base) throws Exception {
+        Path src = base.resolve("src");
+
+        tb.writeJavaFiles(src,
+                          "package test;\n" +
+                          "@javax.annotation.Generated(\"test\")\n" +
+                          "public class Test {\n" +
+                          "    com.sun.tools.javac.Main m;\n" +
+                          "    javax.xml.bind.JAXBException e;\n" +
+                          "}\n");
+
+        Path out = base.resolve("out");
+
+        Files.createDirectories(out);
+
+        for (Entry<String[], String> variant : variants) {
+            System.err.println("running variant: options=" + Arrays.asList(variant.getKey()) + ", expected log: " + variant.getValue());
+
+            List<String> options = new ArrayList<>();
+            options.add("-XDrawDiagnostics");
+            options.addAll(Arrays.asList(variant.getKey()));
+
+            String log = new JavacTask(tb)
+                    .options(options.toArray(new String[0]))
+                    .outdir(out)
+                    .files(findJavaFiles(src))
+                    .run(variant.getValue() == null ? Task.Expect.SUCCESS : Task.Expect.FAIL)
+                    .writeAll()
+                    .getOutput(Task.OutputKind.DIRECT);
+
+            log = log.replace(System.getProperty("line.separator"), "\n");
+
+            if (variant.getValue() != null && !log.equals(variant.getValue())) {
+                throw new AssertionError();
+            }
+        }
+    }
+
+    private static final List<Entry<String[], String>> variants = Arrays.asList(
+            new SimpleEntry<String[], String>(new String[] {},
+                                              "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"},
+                                              null),
+            new SimpleEntry<String[], String>(new String[] {"-limitmods", "java.xml.ws,jdk.compiler"},
+                                              null),
+            new SimpleEntry<String[], String>(new String[] {"-addmods", "ALL-SYSTEM"},
+                                              null)
+    );
+
+    @Test
     public void testAllModulePath(Path base) throws Exception {
         if (Files.isDirectory(base))
             tb.cleanDirectory(base);
--- a/langtools/test/tools/javac/processing/loader/testClose/TestClose.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose.java	Tue May 03 11:38:13 2016 +0100
@@ -132,9 +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,"
-                        + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                        "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+                        "-XaddExports: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	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -92,10 +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,"
-                    + "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED,"
-                    + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+                "-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",
                 "-processor", TestClose2.class.getName());
 
         JavacTask task = tool.getTask(null, fm, null, options, null, files);
--- a/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Tue May 03 11:38:13 2016 +0100
@@ -33,7 +33,6 @@
 import java.io.File;
 import java.util.*;
 import java.util.Map.Entry;
-import java.util.stream.StreamSupport;
 
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -42,14 +41,12 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.util.Elements;
 import javax.tools.*;
-import javax.tools.JavaFileManager.Location;
 
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.model.JavacElements;
 
 import static javax.tools.StandardLocation.CLASS_PATH;
 import static javax.tools.StandardLocation.PLATFORM_CLASS_PATH;
-import static javax.tools.StandardLocation.SYSTEM_MODULES;
 import static javax.tools.JavaFileObject.Kind.CLASS;
 
 
@@ -67,11 +64,13 @@
     static JavacTask javac;
     static Elements elements;
 
+    static List<String> addmods_ALL_SYSTEM = Arrays.asList("-addmods", "ALL-SYSTEM");
+
     public static void main(String[] args) throws Exception {
         JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
             fm.setLocation(CLASS_PATH, Collections.<File>emptyList());
-            JavacTask javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
+            JavacTask javac = (JavacTask)tool.getTask(null, fm, null, addmods_ALL_SYSTEM, null, null);
             Elements elements = javac.getElements();
 
             final Map<String, Set<String>> packages = new LinkedHashMap<>();
@@ -109,11 +108,12 @@
             javac = null;
             elements = null;
 
-            javac = (JavacTask)tool.getTask(null, fm, null, null, null, null);
+            javac = (JavacTask)tool.getTask(null, fm, null, addmods_ALL_SYSTEM, null, null);
             elements = javac.getElements();
 
             for (Entry<String, Set<String>> module2Packages : packages.entrySet()) {
                 ModuleElement me = elements.getModuleElement(module2Packages.getKey());
+                me.getClass();
                 for (String name : module2Packages.getValue()) {
                     PackageElement pe = ((JavacElements) elements).getPackageElement(me, name);
                     for (Element e : pe.getEnclosedElements()) {
--- a/langtools/test/tools/javac/util/T6597678.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/javac/util/T6597678.java	Tue May 03 11:38:13 2016 +0100
@@ -59,9 +59,8 @@
         PrintWriter pw = new PrintWriter(sw);
 
         compile(sw, pw,
-            "-XaddExports:"
-                + "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED,"
-                + "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
+            "-XaddExports:jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
+            "-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
             "-XDaccessInternalAPI",
             "-proc:only",
             "-processor", myName,
--- a/langtools/test/tools/jdeps/APIDeps.java	Wed Jul 05 21:39:33 2017 +0200
+++ b/langtools/test/tools/jdeps/APIDeps.java	Tue May 03 11:38:13 2016 +0100
@@ -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
@@ -65,11 +65,9 @@
         for (String s : testModules.split("\\s+")) {
             if (s.isEmpty()) continue;
             if (s.indexOf('/') != -1)
-                addExports.add(s.trim() + "=ALL-UNNAMED");
+                addExports.add("-XaddExports:" + s.trim() + "=ALL-UNNAMED");
         }
-        if (addExports.size() > 0) {
-            options.add(addExports.stream().collect(Collectors.joining(",", "-XaddExports:", "")));
-        }
+        options.addAll(addExports);
 
         for (String dir : srcDirs) {
             Path source = testsrc.resolve(dir);