Merge
authorlana
Thu, 05 May 2016 19:10:30 +0000
changeset 37852 4dd95b3cb2e8
parent 37847 ae390587c2e9 (current diff)
parent 37851 f2820cadfa38 (diff)
child 37853 b4ea8806ad1a
Merge
--- a/langtools/make/build.xml	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/make/build.xml	Thu May 05 19:10:30 2016 +0000
@@ -83,6 +83,17 @@
     <property name="build.jtreg" location="${build.dir}/jtreg"/>
     <property name="build.prevsrc" location="${build.dir}/prevsrc"/>
 
+    <pathconvert property="modules.names" pathsep=",">
+        <globmapper from="${src.dir}/*" to="*" />
+        <dirset dir="${src.dir}" includes="*.*"/>
+    </pathconvert>
+
+    <pathconvert property="xpatch.rest" pathsep=" -Xpatch:">
+        <regexpmapper from="${file.separator}([^${file.separator}]+)$" to="\1=${build.modules}${file.separator}\1" />
+        <dirset dir="${src.dir}" includes="*.*"/>
+    </pathconvert>
+
+    <property name="xpatch.cmd" value="-Xpatch:${xpatch.rest}"/>
 
     <!-- java.marker is set to a marker file to check for within a Java install dir.
          The best file to check for across Solaris/Linux/Windows/MacOS is one of the
@@ -190,7 +201,7 @@
             <arg line="-source ${javac.source} -target ${javac.target}" />
             <arg value="-d" />
             <arg value="${build.modules}" />
-            <arg line="${javac.opts} -modulesourcepath ${src.dir}${file.separator}*${file.separator}share${file.separator}classes:${build.gensrc} -m java.compiler,jdk.compiler,jdk.javadoc,jdk.jdeps,jdk.jshell" />
+            <arg line="${javac.opts} -modulesourcepath ${src.dir}${file.separator}*${file.separator}share${file.separator}classes:${build.gensrc} -m ${modules.names}" />
         </exec>
         <delete>
             <fileset dir="${build.modules}" includes="**/module-info.class"/>
@@ -229,7 +240,7 @@
         <replace file=".idea/ant.xml" token="@IDEA_JTREG_HOME@" value="${idea.jtreg.home}"/>
         <replace file=".idea/ant.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
         <replace file=".idea/workspace.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
-        <replace file=".idea/workspace.xml" token="@FILE_SEP@" value="${file.separator}"/>
+        <replace file=".idea/workspace.xml" token="@XPATCH@" value="${xpatch.cmd}"/>
         <replace file=".idea/workspace.xml" token="@PATH_SEP@" value="${path.separator}"/>
         <mkdir dir=".idea/classes"/>
         <javac srcdir="make/intellij/src"
@@ -285,6 +296,7 @@
             <attribute name="bin.dir" default="${build.bin}"/>
             <attribute name="java" default="${launcher.java}"/>
             <attribute name="main.class" default="${tool.@{name}.main.class}"/>
+            <attribute name="xpatch" default="${xpatch.cmd}"/>
             <sequential>
                 <mkdir dir="@{bin.dir}"/>
                 <copy file="${make.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
@@ -292,6 +304,7 @@
                         <filter token="PROGRAM" value="@{main.class}"/>
                         <filter token="TARGET_JAVA" value="@{java}"/>
                         <filter token="PS" value="${path.separator}"/>
+                        <filter token="XPATCH" value="${xpatch.cmd}"/>
                     </filterset>
                 </copy>
                 <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
@@ -330,7 +343,7 @@
                     jdk="@{jdk}"
                     agentvm="@{agentvm}" verbose="@{verbose}"
                     failonerror="false" resultproperty="jtreg.@{name}.result"
-                    vmoptions="${coverage.options} @{extra.jvmargs} -Xpatch:@{build.modules}">
+                    vmoptions="${coverage.options} @{extra.jvmargs} ${xpatch.cmd}">
                     <arg value="-debug:@{jpda.jvmargs}"/>
                     <arg line="@{keywords}"/>
                     <arg line="@{options}"/>
--- a/langtools/make/intellij/workspace.xml	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/make/intellij/workspace.xml	Thu May 05 19:10:30 2016 +0000
@@ -10,7 +10,7 @@
     <!-- javac -->
     <configuration default="false" name="javac" type="Application" factoryName="Application">
       <option name="MAIN_CLASS_NAME" value="com.sun.tools.javac.Main" />
-      <option name="VM_PARAMETERS" value="-Xpatch:build@FILE_SEP@modules" />
+      <option name="VM_PARAMETERS" value="@XPATCH@" />
       <option name="PROGRAM_PARAMETERS" value="" />
       <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
@@ -30,7 +30,7 @@
     <!-- javadoc -->
     <configuration default="false" name="javadoc" type="Application" factoryName="Application">
       <option name="MAIN_CLASS_NAME" value="com.sun.tools.javadoc.Main" />
-      <option name="VM_PARAMETERS" value="-Xpatch:build@FILE_SEP@modules" />
+      <option name="VM_PARAMETERS" value="@XPATCH@" />
       <option name="PROGRAM_PARAMETERS" value="" />
       <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
@@ -50,7 +50,7 @@
     <!-- javap -->
     <configuration default="false" name="javap" type="Application" factoryName="Application">
       <option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" />
-      <option name="VM_PARAMETERS" value="-Xpatch:build@FILE_SEP@modules" />
+      <option name="VM_PARAMETERS" value="@XPATCH@" />
       <option name="PROGRAM_PARAMETERS" value="" />
       <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
@@ -70,7 +70,7 @@
     <!-- javah -->
     <configuration default="false" name="javah" type="Application" factoryName="Application">
       <option name="MAIN_CLASS_NAME" value="com.sun.tools.javah.Main" />
-      <option name="VM_PARAMETERS" value="-Xpatch:build@FILE_SEP@modules" />
+      <option name="VM_PARAMETERS" value="@XPATCH@" />
       <option name="PROGRAM_PARAMETERS" value="" />
       <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
@@ -90,7 +90,7 @@
     <!-- sjavac -->
     <configuration default="false" name="sjavac" type="Application" factoryName="Application">
       <option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" />
-      <option name="VM_PARAMETERS" value="-Xpatch:build@FILE_SEP@modules" />
+      <option name="VM_PARAMETERS" value="@XPATCH@" />
       <option name="PROGRAM_PARAMETERS" value="" />
       <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
@@ -111,7 +111,7 @@
     <configuration default="false" name="jshell" type="Application" factoryName="Application">
       <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
       <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellTool" />
-      <option name="VM_PARAMETERS" value="-Xpatch:build@FILE_SEP@modules -XaddExports:jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED" />
+      <option name="VM_PARAMETERS" value="@XPATCH@ -XaddExports:jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED" />
       <option name="PROGRAM_PARAMETERS" value="" />
       <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
       <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
--- a/langtools/make/launcher.sh-template	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/make/launcher.sh-template	Thu May 05 19:10:30 2016 +0000
@@ -25,17 +25,6 @@
 # questions.
 #
 
-mydir="`dirname $0`"
-case `uname -s` in
-    CYGWIN*)
-      mydir=`cygpath -m $mydir`
-      ;;
-esac
-mylib="$mydir/../modules"
-
-# patch langtools modules
-bcp=-Xpatch:"$mylib"
-
 # tools currently assumes that assertions are enabled in the launcher
 ea=-ea:com.sun.tools...
 
@@ -59,4 +48,4 @@
 unset DUALCASE
 
 IFS=$nl
-"#TARGET_JAVA#" $bcp ${ea} ${javaOpts} #PROGRAM# ${toolOpts}
+"#TARGET_JAVA#" "#XPATCH#" ${ea} ${javaOpts} #PROGRAM# ${toolOpts}
--- a/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/make/tools/crules/CodingRulesAnalyzerPlugin.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java	Thu May 05 19:10:30 2016 +0000
@@ -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/make/tools/propertiesparser/PropertiesParser.java	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/make/tools/propertiesparser/PropertiesParser.java	Thu May 05 19:10:30 2016 +0000
@@ -28,24 +28,10 @@
 import propertiesparser.parser.MessageFile;
 import propertiesparser.gen.ClassGenerator;
 
-import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.lang.RuntimeException;
-import java.lang.Throwable;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collections;
+import java.io.PrintStream;
 import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
 /** Translates a .properties file into a .java file containing an enum-like Java class
  *  which defines static factory methods for all resource keys in a given resource file. <P>
@@ -64,13 +50,17 @@
     }
 
     public static void main(String[] args) {
-        PropertiesParser pp = new PropertiesParser(msg -> System.out.println(msg));
-        boolean ok = pp.run(args);
+        boolean ok = run(args, System.out);
         if ( !ok ) {
             System.exit(1);
         }
     }
 
+    public static boolean run(String[] args, PrintStream out) {
+        PropertiesParser pp = new PropertiesParser(msg -> out.println(msg));
+        return pp.run(args);
+    }
+
     public static interface Logger {
         void info(String msg);
     }
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleWrappers.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/TEST.ROOT	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/all/RunCodingRules.java	Thu May 05 19:10:30 2016 +0000
@@ -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,15 +25,14 @@
  * @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
  */
 
 
 import java.io.*;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -58,16 +57,18 @@
 
     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;
         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)) {
+                    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());
@@ -86,7 +87,10 @@
             DiagnosticListener<JavaFileObject> noErrors = diagnostic -> {
                 Assert.check(diagnostic.getKind() != Diagnostic.Kind.ERROR, diagnostic.toString());
             };
+            String FS = File.separator;
+            String PS = File.pathSeparator;
 
+            //compile crules:
             List<File> crulesFiles = Files.walk(crulesDir)
                                           .filter(entry -> entry.getFileName().toString().endsWith(".java"))
                                           .filter(entry -> entry.getParent().endsWith("crules"))
@@ -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();
@@ -111,6 +114,47 @@
                 metaInfServices.write("crules.CodingRulesAnalyzerPlugin\n");
             }
 
+            //generate CompilerProperties.java:
+            List<File> propertiesParserFiles =
+                    Files.walk(crulesDir.resolve("propertiesparser"))
+                         .filter(entry -> entry.getFileName().toString().endsWith(".java"))
+                         .map(entry -> entry.toFile())
+                         .collect(Collectors.toList());
+
+            Path propertiesParserTarget = targetDir.resolve("propertiesParser");
+            Files.createDirectories(propertiesParserTarget);
+            List<String> propertiesParserOptions = Arrays.asList(
+                    "-d", propertiesParserTarget.toString());
+            javaCompiler.getTask(null, fm, noErrors, propertiesParserOptions, null,
+                    fm.getJavaFileObjectsFromFiles(propertiesParserFiles)).call();
+
+            Path genSrcTarget = targetDir.resolve("gensrc");
+
+            ClassLoader propertiesParserLoader = new URLClassLoader(new URL[] {
+                propertiesParserTarget.toUri().toURL(),
+                crulesDir.toUri().toURL()
+            });
+            Class propertiesParserClass =
+                    Class.forName("propertiesparser.PropertiesParser", false, propertiesParserLoader);
+            Method propertiesParserRun =
+                    propertiesParserClass.getDeclaredMethod("run", String[].class, PrintStream.class);
+            String compilerProperties =
+                    "jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties";
+            Path propertiesPath = mainSrcDir.resolve(compilerProperties.replace("/", FS));
+            Path genSrcTargetDir = genSrcTarget.resolve(mainSrcDir.relativize(propertiesPath.getParent()));
+
+            Files.createDirectories(genSrcTargetDir);
+            String[] propertiesParserRunOptions = new String[] {
+                "-compile", propertiesPath.toString(), genSrcTargetDir.toString()
+            };
+
+            Object result = propertiesParserRun.invoke(null, propertiesParserRunOptions, System.err);
+
+            if (!(result instanceof Boolean) || !(Boolean) result) {
+                throw new AssertionError("Cannot parse properties: " + result);
+            }
+
+            //compile langtools sources with crules enabled:
             List<File> sources = sourceDirs.stream()
                                            .flatMap(dir -> silentFilesWalk(dir))
                                            .filter(entry -> entry.getFileName().toString().endsWith(".java"))
@@ -119,9 +163,13 @@
 
             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 + FS + "*" + FS + "share" + FS + "classes",
+                    "-XDaccessInternalAPI",
                     "-processorpath", processorPath,
                     "-Xplugin:coding_rules");
             javaCompiler.getTask(null, fm, noErrors, options, null,
--- a/langtools/test/tools/javac/T6358024.java	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/T6358024.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/T6358166.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/T6406771.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/T8010737/ParameterNamesAreNotCopiedToAnonymousInitTest.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/api/TestJavacTaskScanner.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java	Thu May 05 19:10:30 2016 +0000
@@ -294,6 +294,7 @@
             "opt.Xlint.desc.",
             "count.",
             "illegal.",
+            "java.",
             "javac.",
             "verbose.",
             "locn."
--- a/langtools/test/tools/javac/file/T7018098.java	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/file/T7018098.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/modules/AddLimitMods.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/processing/loader/testClose/TestClose2.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/processing/model/testgetallmembers/Main.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/javac/util/T6597678.java	Thu May 05 19:10:30 2016 +0000
@@ -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	Thu May 05 17:35:50 2016 +0000
+++ b/langtools/test/tools/jdeps/APIDeps.java	Thu May 05 19:10:30 2016 +0000
@@ -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);