Merge
authorduke
Wed, 05 Jul 2017 22:17:39 +0200
changeset 41256 d80ef55a59ea
parent 41255 72fcbd6294cb (diff)
parent 41245 71864d081689 (current diff)
child 41257 65477538bec3
Merge
jdk/src/java.base/aix/native/libnio/ch/AixNativeThread.c
jdk/test/java/beans/XMLEncoder/EnumPrivate.java
jdk/test/java/beans/XMLEncoder/EnumPublic.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedCollection.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedList.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedMap.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedRandomAccessList.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSet.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSortedMap.java
jdk/test/java/beans/XMLEncoder/java_util_Collections_CheckedSortedSet.java
jdk/test/java/beans/XMLEncoder/java_util_EnumMap.java
jdk/test/java/beans/XMLEncoder/java_util_JumboEnumSet.java
jdk/test/java/beans/XMLEncoder/java_util_RegularEnumSet.java
--- a/langtools/.hgtags	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/.hgtags	Wed Jul 05 22:17:39 2017 +0200
@@ -380,3 +380,4 @@
 af5eb8f3ffd21288305a54ea177ffad75021a741 jdk-9+135
 c8f02f0ecbd7cd6700f47416e4b7e9d5ec20ad77 jdk-9+136
 dd56c243c199a540c9f1fbff4855f0934b32a9d0 jdk-9+137
+90dd93e668a521642382561c47abe96ee2e065b7 jdk-9+138
--- a/langtools/make/gendata/Gendata-jdk.compiler.gmk	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/make/gendata/Gendata-jdk.compiler.gmk	Wed Jul 05 22:17:39 2017 +0200
@@ -52,7 +52,7 @@
 	$(RM) -r $(@D)
 	$(MKDIR) -p $(@D)
 	$(ECHO) Creating ct.sym classes
-	$(JAVA) $(INTERIM_LANGTOOLS_ARGS) \
+	$(JAVA_SMALL) $(INTERIM_LANGTOOLS_ARGS) \
 	    $(COMPILECREATESYMBOLS_ADD_EXPORTS) \
 	    -classpath $(BUILDTOOLS_OUTPUTDIR)/create_symbols \
 	    build.tools.symbolgenerator.CreateSymbols \
--- a/langtools/make/gensrc/GensrcCommon.gmk	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/make/gensrc/GensrcCommon.gmk	Wed Jul 05 22:17:39 2017 +0200
@@ -32,12 +32,12 @@
 
 ################################################################################
 # The compileprops tools compiles a properties file into a resource bundle.
-TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
+TOOL_COMPILEPROPS_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
     compileproperties.CompileProperties -quiet
 
 ################################################################################
 # The compileprops tools compiles a properties file into an enum-like class.
-TOOL_PARSEPROPS_CMD := $(JAVA) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
+TOOL_PARSEPROPS_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
     propertiesparser.PropertiesParser
 
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java	Wed Jul 05 22:17:39 2017 +0200
@@ -31,6 +31,7 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Set;
+import java.util.function.Function;
 
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileManager.Location;
@@ -38,10 +39,14 @@
 import javax.tools.JavaFileObject.Kind;
 import javax.tools.StandardLocation;
 
+import com.sun.tools.javac.code.Symbol.Completer;
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
+import com.sun.tools.javac.jvm.ModuleNameReader;
+import com.sun.tools.javac.jvm.ModuleNameReader.BadClassFile;
 import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.resources.CompilerProperties.Fragments;
+import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.JCDiagnostic.Fragment;
@@ -50,7 +55,6 @@
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
-import com.sun.tools.javac.util.StringUtils;
 
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 
@@ -84,6 +88,10 @@
 
     private final JCDiagnostic.Factory diags;
 
+    private ModuleNameReader moduleNameReader;
+
+    public ModuleInfoSourceFileCompleter sourceFileCompleter;
+
     /** Get the ModuleFinder instance for this invocation. */
     public static ModuleFinder instance(Context context) {
         ModuleFinder instance = context.get(moduleFinderKey);
@@ -182,6 +190,8 @@
         return list;
     }
 
+    private boolean inFindSingleModule;
+
     public ModuleSymbol findSingleModule() {
         try {
             JavaFileObject src_fo = getModuleInfoFromLocation(StandardLocation.SOURCE_PATH, Kind.SOURCE);
@@ -194,26 +204,41 @@
             if (fo == null) {
                 msym = syms.unnamedModule;
             } else {
-                // Note: the following may trigger a re-entrant call to Modules.enter
-//                msym = new ModuleSymbol();
-//                ClassSymbol info = new ClassSymbol(Flags.MODULE, names.module_info, msym);
-//                info.modle = msym;
-//                info.classfile = fo;
-//                info.members_field = WriteableScope.create(info);
-//                msym.module_info = info;
-                msym = ModuleSymbol.create(null, names.module_info);
-                msym.module_info.classfile = fo;
-                msym.completer = sym -> classFinder.fillIn(msym.module_info);
-//                // TODO: should we do the following here, or as soon as we find the name in
-//                // the source or class file?
-//                // Consider the case when the class/source path module shadows one on the
-//                // module source path
-//                if (syms.modules.get(msym.name) != null) {
-//                    // error: module already defined
-//                    System.err.println("ERROR: module already defined: " + msym);
-//                } else {
-//                    syms.modules.put(msym.name, msym);
-//                }
+                switch (fo.getKind()) {
+                    case SOURCE:
+                        if (!inFindSingleModule) {
+                            try {
+                                inFindSingleModule = true;
+                                // Note: the following will trigger a re-entrant call to Modules.enter
+                                msym = sourceFileCompleter.complete(fo);
+                                msym.module_info.classfile = fo;
+                            } finally {
+                                inFindSingleModule = false;
+                            }
+                        } else {
+                            //the module-info.java does not contain a module declaration,
+                            //avoid infinite recursion:
+                            msym = syms.unnamedModule;
+                        }
+                        break;
+                    case CLASS:
+                        Name name;
+                        try {
+                            name = names.fromString(readModuleName(fo));
+                        } catch (BadClassFile | IOException ex) {
+                            //fillIn will report proper errors:
+                            name = names.error;
+                        }
+                        msym = syms.enterModule(name);
+                        msym.module_info.classfile = fo;
+                        msym.completer = Completer.NULL_COMPLETER;
+                        classFinder.fillIn(msym.module_info);
+                        break;
+                    default:
+                        Assert.error();
+                        msym = syms.unnamedModule;
+                        break;
+                }
             }
 
             msym.classLocation = StandardLocation.CLASS_OUTPUT;
@@ -224,6 +249,12 @@
         }
     }
 
+    private String readModuleName(JavaFileObject jfo) throws IOException, ModuleNameReader.BadClassFile {
+        if (moduleNameReader == null)
+            moduleNameReader = new ModuleNameReader();
+        return moduleNameReader.readModuleName(jfo);
+    }
+
     private JavaFileObject getModuleInfoFromLocation(Location location, Kind kind) throws IOException {
         if (!fileManager.hasLocation(location))
             return null;
@@ -332,4 +363,8 @@
         }
     }
 
+    public interface ModuleInfoSourceFileCompleter {
+        public ModuleSymbol complete(JavaFileObject file);
+    }
+
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Jul 05 22:17:39 2017 +0200
@@ -916,7 +916,6 @@
 
         /**
          * Create a ModuleSymbol with an associated module-info ClassSymbol.
-         * The name of the module may be null, if it is not known yet.
          */
         public static ModuleSymbol create(Name name, Name module_info) {
             ModuleSymbol msym = new ModuleSymbol(name, null);
@@ -930,6 +929,7 @@
 
         public ModuleSymbol(Name name, Symbol owner) {
             super(MDL, 0, name, null, owner);
+            Assert.checkNonNull(name);
             this.type = new ModuleType(this);
         }
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Jul 05 22:17:39 2017 +0200
@@ -764,17 +764,6 @@
         return msym;
     }
 
-    public void enterModule(ModuleSymbol msym, Name name) {
-        Assert.checkNull(modules.get(name));
-        Assert.checkNull(msym.name);
-        msym.name = name;
-        addRootPackageFor(msym);
-        ClassSymbol info = msym.module_info;
-        info.fullname = msym.name.append('.', names.module_info);
-        info.flatname = info.fullname;
-        modules.put(name, msym);
-    }
-
     public ModuleSymbol getModule(Name name) {
         return modules.get(name);
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jul 05 22:17:39 2017 +0200
@@ -292,15 +292,12 @@
             Name name = TreeInfo.fullName(decl.qualId);
             ModuleSymbol sym;
             if (c != null) {
-               sym = (ModuleSymbol) c.owner;
-               if (sym.name == null) {
-                   //ModuleFinder.findSingleModule creates a stub of a ModuleSymbol without a name,
-                   //fill the name here after the module-info.java has been parsed
-                   //also enter the ModuleSymbol among modules:
-                   syms.enterModule(sym, name);
-               } else {
-                   // TODO: validate name
-               }
+                sym = (ModuleSymbol) c.owner;
+                Assert.checkNonNull(sym.name);
+                Name treeName = TreeInfo.fullName(decl.qualId);
+                if (sym.name != treeName) {
+                    log.error(decl.pos(), Errors.ModuleNameMismatch(name, sym.name));
+                }
             } else {
                 sym = syms.enterModule(name);
                 if (sym.module_info.sourcefile != null && sym.module_info.sourcefile != toplevel.sourcefile) {
@@ -1006,6 +1003,10 @@
         return new Symbol.Completer() {
             @Override
             public void complete(Symbol sym) throws CompletionFailure {
+                if (inInitModules) {
+                    sym.completer = this;
+                    return ;
+                }
                 ModuleSymbol msym = (ModuleSymbol) sym;
                 Set<ModuleSymbol> allModules = allModules();
                 for (ModuleSymbol m : allModules) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 05 22:17:39 2017 +0200
@@ -415,10 +415,10 @@
                 if (!isSameMemberWhenErased(dest, impl, impl_erasure))
                     return true;
 
-                // If the erasure of the return type is different, a
-                // bridge is needed.
-                return !types.isSameType(impl_erasure.getReturnType(),
-                                         method_erasure.getReturnType());
+                /* Bottom line: A bridge is needed if the erasure of the implementation
+                   is different from that of the method that it overrides.
+                */
+                return !types.isSameType(impl_erasure, method_erasure);
             } else {
                // method and impl are the same...
                 if ((method.flags() & ABSTRACT) != 0) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java	Wed Jul 05 22:17:39 2017 +0200
@@ -80,6 +80,7 @@
 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.jvm.ModuleNameReader;
 import com.sun.tools.javac.util.Pair;
 import com.sun.tools.javac.util.StringUtils;
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ModuleNameReader.java	Wed Jul 05 22:17:29 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.tools.javac.file;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import com.sun.tools.javac.jvm.ClassFile;
-
-import static com.sun.tools.javac.jvm.ClassFile.*;
-
-
-/**
- * Stripped down ClassReader, just sufficient to read module names from module-info.class files
- * while analyzing the module path.
- *
- * <p>
- * <b>This is NOT part of any supported API. If you write code that depends on this, you do so at
- * your own risk. This code and its internal interfaces are subject to change or deletion without
- * notice.</b>
- */
-public class ModuleNameReader {
-    static class BadClassFile extends Exception {
-        private static final long serialVersionUID = 0;
-        BadClassFile(String msg) {
-            super(msg);
-        }
-    }
-
-    private static final int INITIAL_BUFFER_SIZE = 0x0fff0;
-
-    /** The buffer containing the currently read class file.
-     */
-    private byte[] buf = new byte[INITIAL_BUFFER_SIZE];
-
-    /** The current input pointer.
-     */
-    private int bp;
-
-    /** The objects of the constant pool.
-     */
-    private Object[] poolObj;
-
-    /** For every constant pool entry, an index into buf where the
-     *  defining section of the entry is found.
-     */
-    private int[] poolIdx;
-
-    ModuleNameReader() {
-    }
-
-    String readModuleName(Path p) throws IOException, BadClassFile {
-        try (InputStream in = Files.newInputStream(p)) {
-            bp = 0;
-            buf = readInputStream(buf, in);
-
-            int magic = nextInt();
-            if (magic != JAVA_MAGIC)
-                throw new BadClassFile("illegal.start.of.class.file");
-
-            int minorVersion = nextChar();
-            int majorVersion = nextChar();
-
-            indexPool();
-
-            int accessflags = nextChar();
-            return readModuleInfoName(nextChar());
-        }
-    }
-
-    /** Extract a character at position bp from buf.
-     */
-    char getChar(int bp) {
-        return
-            (char)(((buf[bp] & 0xFF) << 8) + (buf[bp+1] & 0xFF));
-    }
-
-    /** Read a character.
-     */
-    char nextChar() {
-        return (char)(((buf[bp++] & 0xFF) << 8) + (buf[bp++] & 0xFF));
-    }
-
-    /** Read an integer.
-     */
-    int nextInt() {
-        return
-            ((buf[bp++] & 0xFF) << 24) +
-            ((buf[bp++] & 0xFF) << 16) +
-            ((buf[bp++] & 0xFF) << 8) +
-            (buf[bp++] & 0xFF);
-    }
-
-    /** Index all constant pool entries, writing their start addresses into
-     *  poolIdx.
-     */
-    void indexPool() throws BadClassFile {
-        poolIdx = new int[nextChar()];
-        poolObj = new Object[poolIdx.length];
-        int i = 1;
-        while (i < poolIdx.length) {
-            poolIdx[i++] = bp;
-            byte tag = buf[bp++];
-            switch (tag) {
-            case CONSTANT_Utf8: case CONSTANT_Unicode: {
-                int len = nextChar();
-                bp = bp + len;
-                break;
-            }
-            case CONSTANT_Class:
-            case CONSTANT_String:
-            case CONSTANT_MethodType:
-                bp = bp + 2;
-                break;
-            case CONSTANT_MethodHandle:
-                bp = bp + 3;
-                break;
-            case CONSTANT_Fieldref:
-            case CONSTANT_Methodref:
-            case CONSTANT_InterfaceMethodref:
-            case CONSTANT_NameandType:
-            case CONSTANT_Integer:
-            case CONSTANT_Float:
-            case CONSTANT_InvokeDynamic:
-                bp = bp + 4;
-                break;
-            case CONSTANT_Long:
-            case CONSTANT_Double:
-                bp = bp + 8;
-                i++;
-                break;
-            default:
-                throw new BadClassFile("malformed constant pool");
-            }
-        }
-    }
-
-    /** Read the class name of a module-info.class file.
-     * The name is stored in a CONSTANT_Class entry, where the
-     * class name is of the form module-name/module-info.
-     */
-    String readModuleInfoName(int i) throws BadClassFile {
-        int classIndex = poolIdx[i];
-        if (buf[classIndex] == CONSTANT_Class) {
-            int utf8Index = poolIdx[getChar(classIndex + 1)];
-            if (buf[utf8Index] == CONSTANT_Utf8) {
-                int len = getChar(utf8Index + 1);
-                int start = utf8Index + 3;
-                String suffix = "/module-info";
-                if (endsWith(buf, start, len, suffix))
-                    return new String(ClassFile.internalize(buf, start, len - suffix.length()));
-            }
-        }
-        throw new BadClassFile("bad module-info name");
-    }
-
-    private boolean endsWith(byte[] buf, int start, int len, String suffix) {
-        if (len <= suffix.length())
-            return false;
-        for (int i = 0; i < suffix.length(); i++) {
-            if (buf[start + len - suffix.length() + i] != suffix.charAt(i))
-                return false;
-        }
-        return true;
-    }
-
-    private static byte[] readInputStream(byte[] buf, InputStream s) throws IOException {
-        try {
-            buf = ensureCapacity(buf, s.available());
-            int r = s.read(buf);
-            int bp = 0;
-            while (r != -1) {
-                bp += r;
-                buf = ensureCapacity(buf, bp);
-                r = s.read(buf, bp, buf.length - bp);
-            }
-            return buf;
-        } finally {
-            try {
-                s.close();
-            } catch (IOException e) {
-                /* Ignore any errors, as this stream may have already
-                 * thrown a related exception which is the one that
-                 * should be reported.
-                 */
-            }
-        }
-    }
-
-    /*
-     * ensureCapacity will increase the buffer as needed, taking note that
-     * the new buffer will always be greater than the needed and never
-     * exactly equal to the needed size or bp. If equal then the read (above)
-     * will infinitely loop as buf.length - bp == 0.
-     */
-    private static byte[] ensureCapacity(byte[] buf, int needed) {
-        if (buf.length <= needed) {
-            byte[] old = buf;
-            buf = new byte[Integer.highestOneBit(needed) << 1];
-            System.arraycopy(old, 0, buf, 0, old.length);
-        }
-        return buf;
-    }
-}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jul 05 22:17:39 2017 +0200
@@ -2396,12 +2396,15 @@
         } else {
             c.flags_field = flags;
             Name modInfoName = readModuleInfoName(nextChar());
-            if (c.owner.name == null) {
-                syms.enterModule((ModuleSymbol) c.owner, Convert.packagePart(modInfoName));
-            } else {
-                // TODO: validate name
+            currentModule = (ModuleSymbol) c.owner;
+            if (currentModule.name.append('.', names.module_info) != modInfoName) {
+                //strip trailing .module-info, if exists:
+                int modInfoStart = modInfoName.length() - names.module_info.length();
+                modInfoName = modInfoName.subName(modInfoStart, modInfoName.length()) == names.module_info &&
+                              modInfoName.charAt(modInfoStart - 1) == '.' ?
+                                  modInfoName.subName(0, modInfoStart - 1) : modInfoName;
+                throw badClassFile("module.name.mismatch", modInfoName, currentModule.name);
             }
-            currentModule = (ModuleSymbol) c.owner;
         }
 
         // class attributes must be read before class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ModuleNameReader.java	Wed Jul 05 22:17:39 2017 +0200
@@ -0,0 +1,235 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.javac.jvm;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.jvm.ClassFile;
+
+import static com.sun.tools.javac.jvm.ClassFile.*;
+
+
+/**
+ * Stripped down ClassReader, just sufficient to read module names from module-info.class files
+ * while analyzing the module path.
+ *
+ * <p>
+ * <b>This is NOT part of any supported API. If you write code that depends on this, you do so at
+ * your own risk. This code and its internal interfaces are subject to change or deletion without
+ * notice.</b>
+ */
+public class ModuleNameReader {
+    public static class BadClassFile extends Exception {
+        private static final long serialVersionUID = 0;
+        BadClassFile(String msg) {
+            super(msg);
+        }
+    }
+
+    private static final int INITIAL_BUFFER_SIZE = 0x0fff0;
+
+    /** The buffer containing the currently read class file.
+     */
+    private byte[] buf = new byte[INITIAL_BUFFER_SIZE];
+
+    /** The current input pointer.
+     */
+    private int bp;
+
+    /** For every constant pool entry, an index into buf where the
+     *  defining section of the entry is found.
+     */
+    private int[] poolIdx;
+
+    public ModuleNameReader() {
+    }
+
+    public String readModuleName(Path p) throws IOException, BadClassFile {
+        try (InputStream in = Files.newInputStream(p)) {
+            return readModuleName(in);
+        }
+    }
+
+    public String readModuleName(JavaFileObject jfo) throws IOException, BadClassFile {
+        try (InputStream in = jfo.openInputStream()) {
+            return readModuleName(in);
+        }
+    }
+
+    public String readModuleName(InputStream in) throws IOException, BadClassFile {
+        bp = 0;
+        buf = readInputStream(buf, in);
+
+        int magic = nextInt();
+        if (magic != JAVA_MAGIC)
+            throw new BadClassFile("illegal.start.of.class.file");
+
+        int minorVersion = nextChar();
+        int majorVersion = nextChar();
+
+        indexPool();
+
+        int accessflags = nextChar();
+        return readModuleInfoName(nextChar());
+    }
+
+    /** Extract a character at position bp from buf.
+     */
+    char getChar(int bp) {
+        return
+            (char)(((buf[bp] & 0xFF) << 8) + (buf[bp+1] & 0xFF));
+    }
+
+    /** Read a character.
+     */
+    char nextChar() {
+        return (char)(((buf[bp++] & 0xFF) << 8) + (buf[bp++] & 0xFF));
+    }
+
+    /** Read an integer.
+     */
+    int nextInt() {
+        return
+            ((buf[bp++] & 0xFF) << 24) +
+            ((buf[bp++] & 0xFF) << 16) +
+            ((buf[bp++] & 0xFF) << 8) +
+            (buf[bp++] & 0xFF);
+    }
+
+    /** Index all constant pool entries, writing their start addresses into
+     *  poolIdx.
+     */
+    void indexPool() throws BadClassFile {
+        poolIdx = new int[nextChar()];
+        int i = 1;
+        while (i < poolIdx.length) {
+            poolIdx[i++] = bp;
+            byte tag = buf[bp++];
+            switch (tag) {
+            case CONSTANT_Utf8: case CONSTANT_Unicode: {
+                int len = nextChar();
+                bp = bp + len;
+                break;
+            }
+            case CONSTANT_Class:
+            case CONSTANT_String:
+            case CONSTANT_MethodType:
+                bp = bp + 2;
+                break;
+            case CONSTANT_MethodHandle:
+                bp = bp + 3;
+                break;
+            case CONSTANT_Fieldref:
+            case CONSTANT_Methodref:
+            case CONSTANT_InterfaceMethodref:
+            case CONSTANT_NameandType:
+            case CONSTANT_Integer:
+            case CONSTANT_Float:
+            case CONSTANT_InvokeDynamic:
+                bp = bp + 4;
+                break;
+            case CONSTANT_Long:
+            case CONSTANT_Double:
+                bp = bp + 8;
+                i++;
+                break;
+            default:
+                throw new BadClassFile("malformed constant pool");
+            }
+        }
+    }
+
+    /** Read the class name of a module-info.class file.
+     * The name is stored in a CONSTANT_Class entry, where the
+     * class name is of the form module-name/module-info.
+     */
+    String readModuleInfoName(int i) throws BadClassFile {
+        int classIndex = poolIdx[i];
+        if (buf[classIndex] == CONSTANT_Class) {
+            int utf8Index = poolIdx[getChar(classIndex + 1)];
+            if (buf[utf8Index] == CONSTANT_Utf8) {
+                int len = getChar(utf8Index + 1);
+                int start = utf8Index + 3;
+                String suffix = "/module-info";
+                if (endsWith(buf, start, len, suffix))
+                    return new String(ClassFile.internalize(buf, start, len - suffix.length()));
+            }
+        }
+        throw new BadClassFile("bad module-info name");
+    }
+
+    private boolean endsWith(byte[] buf, int start, int len, String suffix) {
+        if (len <= suffix.length())
+            return false;
+        for (int i = 0; i < suffix.length(); i++) {
+            if (buf[start + len - suffix.length() + i] != suffix.charAt(i))
+                return false;
+        }
+        return true;
+    }
+
+    private static byte[] readInputStream(byte[] buf, InputStream s) throws IOException {
+        try {
+            buf = ensureCapacity(buf, s.available());
+            int r = s.read(buf);
+            int bp = 0;
+            while (r != -1) {
+                bp += r;
+                buf = ensureCapacity(buf, bp);
+                r = s.read(buf, bp, buf.length - bp);
+            }
+            return buf;
+        } finally {
+            try {
+                s.close();
+            } catch (IOException e) {
+                /* Ignore any errors, as this stream may have already
+                 * thrown a related exception which is the one that
+                 * should be reported.
+                 */
+            }
+        }
+    }
+
+    /*
+     * ensureCapacity will increase the buffer as needed, taking note that
+     * the new buffer will always be greater than the needed and never
+     * exactly equal to the needed size or bp. If equal then the read (above)
+     * will infinitely loop as buf.length - bp == 0.
+     */
+    private static byte[] ensureCapacity(byte[] buf, int needed) {
+        if (buf.length <= needed) {
+            byte[] old = buf;
+            buf = new byte[Integer.highestOneBit(needed) << 1];
+            System.arraycopy(old, 0, buf, 0, old.length);
+        }
+        return buf;
+    }
+}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jul 05 22:17:39 2017 +0200
@@ -37,6 +37,7 @@
 import java.util.Queue;
 import java.util.ResourceBundle;
 import java.util.Set;
+import java.util.function.Function;
 
 import javax.annotation.processing.Processor;
 import javax.lang.model.SourceVersion;
@@ -67,7 +68,9 @@
 import com.sun.tools.javac.tree.JCTree.JCLambda;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
+import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.tree.JCTree.Tag;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.DefinedBy.Api;
 import com.sun.tools.javac.util.JCDiagnostic.Factory;
@@ -341,6 +344,13 @@
                 }
             };
 
+    protected final ModuleFinder.ModuleInfoSourceFileCompleter moduleInfoSourceFileCompleter =
+            fo -> (ModuleSymbol) readSourceFile(parseImplicitFile(fo), null, tl -> {
+                return tl.defs.nonEmpty() && tl.defs.head.hasTag(Tag.MODULEDEF) ?
+                        ((JCModuleDecl) tl.defs.head).sym.module_info :
+                        syms.defineClass(names.module_info, syms.errModule);
+            }).owner;
+
     /**
      * Command line options.
      */
@@ -411,6 +421,7 @@
         diags = Factory.instance(context);
 
         finder.sourceCompleter = sourceCompleter;
+        moduleFinder.sourceFileCompleter = moduleInfoSourceFileCompleter;
 
         options = Options.instance(context);
 
@@ -779,6 +790,19 @@
         readSourceFile(null, c);
     }
 
+    private JCTree.JCCompilationUnit parseImplicitFile(JavaFileObject filename) {
+        JavaFileObject prev = log.useSource(filename);
+        try {
+            JCTree.JCCompilationUnit t = parse(filename, filename.getCharContent(false));
+            return t;
+        } catch (IOException e) {
+            log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
+            return make.TopLevel(List.<JCTree>nil());
+        } finally {
+            log.useSource(prev);
+        }
+    }
+
     /** Compile a ClassSymbol from source, optionally using the given compilation unit as
      *  the source tree.
      *  @param tree the compilation unit in which the given ClassSymbol resides,
@@ -789,20 +813,20 @@
         if (completionFailureName == c.fullname) {
             throw new CompletionFailure(c, "user-selected completion failure by class name");
         }
-        JavaFileObject filename = c.classfile;
-        JavaFileObject prev = log.useSource(filename);
 
         if (tree == null) {
-            try {
-                tree = parse(filename, filename.getCharContent(false));
-            } catch (IOException e) {
-                log.error("error.reading.file", filename, JavacFileManager.getMessage(e));
-                tree = make.TopLevel(List.<JCTree>nil());
-            } finally {
-                log.useSource(prev);
-            }
+            tree = parseImplicitFile(c.classfile);
         }
 
+        readSourceFile(tree, c, cut -> c);
+    }
+
+    private ClassSymbol readSourceFile(JCCompilationUnit tree,
+                                       ClassSymbol expectedSymbol,
+                                       Function<JCCompilationUnit, ClassSymbol> symbolGetter)
+                                           throws CompletionFailure {
+        Assert.checkNonNull(tree);
+
         if (!taskListener.isEmpty()) {
             TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
             taskListener.started(e);
@@ -814,18 +838,20 @@
         // Note that if module resolution failed, we may not even
         // have enough modules available to access java.lang, and
         // so risk getting FatalError("no.java.lang") from MemberEnter.
-        if (!modules.enter(List.of(tree), c)) {
-            throw new CompletionFailure(c, diags.fragment("cant.resolve.modules"));
+        if (!modules.enter(List.of(tree), expectedSymbol)) {
+            throw new CompletionFailure(symbolGetter.apply(tree),
+                                        diags.fragment("cant.resolve.modules"));
         }
 
-        enter.complete(List.of(tree), c);
+        enter.complete(List.of(tree), expectedSymbol);
 
         if (!taskListener.isEmpty()) {
             TaskEvent e = new TaskEvent(TaskEvent.Kind.ENTER, tree);
             taskListener.finished(e);
         }
 
-        if (enter.getEnv(c) == null) {
+        ClassSymbol sym = symbolGetter.apply(tree);
+        if (sym == null || enter.getEnv(sym) == null) {
             boolean isPkgInfo =
                 tree.sourcefile.isNameCompatible("package-info",
                                                  JavaFileObject.Kind.SOURCE);
@@ -836,24 +862,26 @@
                 if (enter.getEnv(tree.modle) == null) {
                     JCDiagnostic diag =
                         diagFactory.fragment("file.does.not.contain.module");
-                    throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
+                    throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
                 }
             } else if (isPkgInfo) {
                 if (enter.getEnv(tree.packge) == null) {
                     JCDiagnostic diag =
                         diagFactory.fragment("file.does.not.contain.package",
-                                                 c.location());
-                    throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
+                                                 sym.location());
+                    throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
                 }
             } else {
                 JCDiagnostic diag =
                         diagFactory.fragment("file.doesnt.contain.class",
-                                            c.getQualifiedName());
-                throw new ClassFinder.BadClassFile(c, filename, diag, diagFactory);
+                                            sym.getQualifiedName());
+                throw new ClassFinder.BadClassFile(sym, tree.sourcefile, diag, diagFactory);
             }
         }
 
         implicitSourceFilesRead = true;
+
+        return sym;
     }
 
     /** Track when the JavaCompiler has been used to compile something. */
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Wed Jul 05 22:17:39 2017 +0200
@@ -425,8 +425,7 @@
     J("-J", "opt.arg.flag", "opt.J", STANDARD, INFO, ArgKind.ADJACENT) {
         @Override
         public boolean process(OptionHelper helper, String option) {
-            throw new AssertionError
-                ("the -J flag should be caught by the launcher.");
+            throw new AssertionError("the -J flag should be caught by the launcher.");
         }
     },
 
@@ -691,7 +690,7 @@
          * This option takes an argument.
          * If the name of option ends with ':' or '=', the argument must be provided directly
          * after that separator.
-         * Otherwise, if may appear after an '=' or in the following argument position.
+         * Otherwise, it may appear after an '=' or in the following argument position.
          */
         REQUIRED,
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 05 22:17:39 2017 +0200
@@ -1336,8 +1336,7 @@
 
         errorStatus = errorStatus || (compiler.errorCount() > 0);
 
-        if (!errorStatus)
-            round.finalCompiler();
+        round.finalCompiler();
 
         if (newSourceFiles.size() > 0)
             roots = roots.appendList(compiler.parseFiles(newSourceFiles));
@@ -1350,10 +1349,8 @@
         if (!taskListener.isEmpty())
             taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
 
-        if (errorStatus) {
-            if (compiler.errorCount() == 0)
-                compiler.log.nerrors++;
-            return true;
+        if (errorStatus && compiler.errorCount() == 0) {
+            compiler.log.nerrors++;
         }
 
         compiler.enterTreesIfNeeded(roots);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 22:17:39 2017 +0200
@@ -2770,6 +2770,10 @@
 compiler.err.module.name.mismatch=\
     module name {0} does not match expected name {1}
 
+# 0: name, 1: name
+compiler.misc.module.name.mismatch=\
+    module name {0} does not match expected name {1}
+
 compiler.err.module.decl.sb.in.module-info.java=\
     module declarations should be in a file named module-info.java
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java	Wed Jul 05 22:17:39 2017 +0200
@@ -165,9 +165,11 @@
     public int isSupportedOption(String option) {
         if (option == null)
             throw new NullPointerException();
-        for (ToolOption o: ToolOption.values()) {
-            if (o.opt.equals(option))
-                return o.hasArg ? 1 : 0;
+        for (ToolOption o : ToolOption.values()) {
+            for (String name : o.names) {
+                if (name.equals(option))
+                    return o.hasArg ? 1 : 0;
+            }
         }
         return -1;
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Wed Jul 05 22:17:39 2017 +0200
@@ -595,8 +595,9 @@
 
     @Override
     public Set<Doclet.Option> getSupportedOptions() {
+        Resources resources = getResources();
         Doclet.Option[] options = {
-            new Option(this, "-bottom", 1) {
+            new Option(resources, "-bottom", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -604,7 +605,7 @@
                     return true;
                 }
             },
-            new Option(this, "-charset", 1) {
+            new Option(resources, "-charset", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -612,7 +613,7 @@
                     return true;
                 }
             },
-            new Option(this, "-doctitle", 1) {
+            new Option(resources, "-doctitle", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -620,7 +621,7 @@
                     return true;
                 }
             },
-            new Option(this, "-footer", 1) {
+            new Option(resources, "-footer", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -628,7 +629,7 @@
                     return true;
                 }
             },
-            new Option(this, "-header", 1) {
+            new Option(resources, "-header", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -636,7 +637,7 @@
                     return true;
                 }
             },
-            new Option(this, "-helpfile", 1) {
+            new Option(resources, "-helpfile", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -644,7 +645,7 @@
                     return true;
                 }
             },
-            new Option(this, "-html4") {
+            new Option(resources, "-html4") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -652,7 +653,7 @@
                     return true;
                 }
             },
-            new Option(this, "-html5") {
+            new Option(resources, "-html5") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -660,7 +661,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nohelp") {
+            new Option(resources, "-nohelp") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -668,7 +669,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nodeprecatedlist") {
+            new Option(resources, "-nodeprecatedlist") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -676,7 +677,7 @@
                     return true;
                 }
             },
-            new Option(this, "-noindex") {
+            new Option(resources, "-noindex") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -684,7 +685,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nonavbar") {
+            new Option(resources, "-nonavbar") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -692,7 +693,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-nooverview") {
+            new Hidden(resources, "-nooverview") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -700,7 +701,7 @@
                     return true;
                 }
             },
-            new Option(this, "-notree") {
+            new Option(resources, "-notree") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -708,7 +709,7 @@
                     return true;
                 }
             },
-            new Option(this, "-overview", 1) {
+            new Option(resources, "-overview", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -716,7 +717,7 @@
                     return true;
                 }
             },
-            new Option(this, "--frames") {
+            new Option(resources, "--frames") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -724,7 +725,7 @@
                     return true;
                 }
             },
-            new Option(this, "--no-frames") {
+            new Option(resources, "--no-frames") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -732,7 +733,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-packagesheader", 1) {
+            new Hidden(resources, "-packagesheader", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -740,7 +741,7 @@
                     return true;
                 }
             },
-            new Option(this, "-splitindex") {
+            new Option(resources, "-splitindex") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -748,7 +749,7 @@
                     return true;
                 }
             },
-            new Option(this, "-stylesheetfile", 1) {
+            new Option(resources, "-stylesheetfile", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -756,7 +757,7 @@
                     return true;
                 }
             },
-            new Option(this, "-top", 1) {
+            new Option(resources, "-top", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -764,7 +765,7 @@
                     return true;
                 }
             },
-            new Option(this, "-use") {
+            new Option(resources, "-use") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -772,7 +773,7 @@
                     return true;
                 }
             },
-            new Option(this, "-windowtitle", 1) {
+            new Option(resources, "-windowtitle", 1) {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -780,7 +781,7 @@
                     return true;
                 }
             },
-            new XOption(this, "-Xdoclint") {
+            new XOption(resources, "-Xdoclint") {
                 @Override
                 public boolean process(String opt,  ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -788,7 +789,7 @@
                     return true;
                 }
             },
-            new XOption(this, "-Xdocrootparent", 1) {
+            new XOption(resources, "-Xdocrootparent", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -796,7 +797,7 @@
                     return true;
                 }
             },
-            new XOption(this, "doclet.xusage.xdoclint-extended.", "-Xdoclint:", 0) {
+            new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) {
                 @Override
                 public boolean matches(String option) {
                     return option.toLowerCase().startsWith(getName().toLowerCase());
@@ -809,7 +810,7 @@
                     return true;
                 }
             },
-            new XOption(this, "doclet.xusage.xdoclint-package.", "-Xdoclint/package:", 0) {
+            new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
                 @Override
                 public boolean matches(String option) {
                     return option.toLowerCase().startsWith(getName().toLowerCase());
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties	Wed Jul 05 22:17:39 2017 +0200
@@ -191,144 +191,196 @@
 doclet.Same_package_name_used=Package name format used twice: {0}
 
 # option specifiers
-doclet.usage.d.parameters=<directory>
-doclet.usage.d.description=Destination directory for output files
+doclet.usage.d.parameters=\
+    <directory>
+doclet.usage.d.description=\
+    Destination directory for output files
 
-doclet.usage.use.description=Create class and package usage pages
-
-doclet.usage.version.description=Include @version paragraphs
+doclet.usage.use.description=\
+    Create class and package usage pages
 
-doclet.usage.author.description=Include @author paragraphs
+doclet.usage.version.description=\
+    Include @version paragraphs
 
-doclet.usage.docfilessubdirs.description=Recursively copy doc-file subdirectories
+doclet.usage.author.description=\
+    Include @author paragraphs
 
-doclet.usage.splitindex.description=Split index into one file per letter
+doclet.usage.docfilessubdirs.description=\
+    Recursively copy doc-file subdirectories
 
-doclet.usage.overview.parameters=<file>
-doclet.usage.overview.description=Read overview documentation from HTML file
+doclet.usage.splitindex.description=\
+    Split index into one file per letter
 
+doclet.usage.overview.parameters=\
+    <file>
+doclet.usage.overview.description=\
+    Read overview documentation from HTML file
 
-doclet.usage.windowtitle.parameters=<text>
-doclet.usage.windowtitle.description=Browser window title for the documentation
-
-doclet.usage.doctitle.parameters=<html-code>
-doclet.usage.doctitle.description=Include title for the overview page
+doclet.usage.windowtitle.parameters=\
+    <text>
+doclet.usage.windowtitle.description=\
+    Browser window title for the documentation
 
-doclet.usage.header.parameters=<html-code>
-doclet.usage.header.description=Include header text for each page
-
-doclet.usage.html4.description=Generate HTML 4.01 output
+doclet.usage.doctitle.parameters=\
+    <html-code>
+doclet.usage.doctitle.description=\
+    Include title for the overview page
 
-doclet.usage.html5.description=Generate HTML 5 output
+doclet.usage.header.parameters=\
+    <html-code>
+doclet.usage.header.description=\
+    Include header text for each page
 
-doclet.usage.footer.parameters=<html-code>
-doclet.usage.footer.description=Include footer text for each page
+doclet.usage.html4.description=\
+    Generate HTML 4.01 output
+
+doclet.usage.html5.description=\
+    Generate HTML 5 output
 
-doclet.usage.top.parameters=<html-code>
-doclet.usage.top.description=Include top text for each page
+doclet.usage.footer.parameters=\
+    <html-code>
+doclet.usage.footer.description=\
+    Include footer text for each page
 
-doclet.usage.bottom.parameters=<html-code>
-doclet.usage.bottom.description=Include bottom text for each page
-
-doclet.usage.link.parameters=<url>
-doclet.usage.link.description=Create links to javadoc output at <url>
+doclet.usage.top.parameters=\
+    <html-code>
+doclet.usage.top.description=\
+    Include top text for each page
 
-doclet.usage.linkoffline.parameters=<url1> <url2>
-doclet.usage.linkoffline.description=Link to docs at <url1> using package list\n\
-\                                   at <url2>
+doclet.usage.bottom.parameters=\
+    <html-code>
+doclet.usage.bottom.description=\
+    Include bottom text for each page
 
-doclet.usage.excludedocfilessubdir.parameters=<name>:..
-doclet.usage.excludedocfilessubdir.description=\n\
-\                                   Exclude any doc-files subdirectories with\n\
-\                                   given name
+doclet.usage.link.parameters=\
+    <url>
+doclet.usage.link.description=\
+    Create links to javadoc output at <url>
 
-doclet.usage.group.parameters=<name> <p1>:<p2>..
-doclet.usage.group.description=Group specified packages together\n\
-\                                   in overview page
+doclet.usage.linkoffline.parameters=\
+    <url1> <url2>
+doclet.usage.linkoffline.description=\
+    Link to docs at <url1> using package list at <url2>
 
-doclet.usage.nocomment.description=Suppress description and tags, generate\n\
-\                                   only declarations
-
-doclet.usage.nodeprecated.description=Do not include @deprecated information
+doclet.usage.excludedocfilessubdir.parameters=\
+    <name>:..
+doclet.usage.excludedocfilessubdir.description=\
+    Exclude any doc-files subdirectories with given name
 
-doclet.usage.noqualifier.parameters=<name1>:<name2>:..
-doclet.usage.noqualifier.description=Exclude the list of qualifiers from the output
+doclet.usage.group.parameters=\
+    <name> <p1>:<p2>..
+doclet.usage.group.description=\
+    Group specified packages together in overview page
 
-doclet.usage.nosince.description=Do not include @since information
+doclet.usage.nocomment.description=\
+    Suppress description and tags, generate only declarations
 
-doclet.usage.notimestamp.description=Do not include hidden time stamp
+doclet.usage.nodeprecated.description=\
+    Do not include @deprecated information
 
-doclet.usage.nodeprecatedlist.description=Do not generate deprecated list
+doclet.usage.noqualifier.parameters=\
+    <name1>:<name2>:..
+doclet.usage.noqualifier.description=\
+    Exclude the list of qualifiers from the output
 
-doclet.usage.notree.description=Do not generate class hierarchy
+doclet.usage.nosince.description=\
+    Do not include @since information
 
-doclet.usage.noindex.description=Do not generate index
+doclet.usage.notimestamp.description=\
+    Do not include hidden time stamp
 
-doclet.usage.nohelp.description=Do not generate help link
+doclet.usage.nodeprecatedlist.description=\
+    Do not generate deprecated list
 
-doclet.usage.nonavbar.description=Do not generate navigation bar
+doclet.usage.notree.description=\
+    Do not generate class hierarchy
 
-doclet.usage.nooverview.description=Do not generate overview pages
+doclet.usage.noindex.description=\
+    Do not generate index
 
-doclet.usage.serialwarn.description=Generate warning about @serial tag
+doclet.usage.nohelp.description=\
+    Do not generate help link
+
+doclet.usage.nonavbar.description=\
+    Do not generate navigation bar
 
-doclet.usage.tag.parameters=<name>:<locations>:<header>
-doclet.usage.tag.description=\n\
-\                                   Specify single argument custom tags
+doclet.usage.nooverview.description=\
+    Do not generate overview pages
 
-doclet.usage.taglet.description=The fully qualified name of Taglet to register
+doclet.usage.serialwarn.description=\
+    Generate warning about @serial tag
 
-doclet.usage.tagletpath.description=The path to Taglets
+doclet.usage.tag.parameters=\
+    <name>:<locations>:<header>
+doclet.usage.tag.description=\
+    Specify single argument custom tags
 
-doclet.usage.charset.parameters=<charset>
-doclet.usage.charset.description=Charset for cross-platform viewing of\n\
-\                                   generated documentation
+doclet.usage.taglet.description=\
+    The fully qualified name of Taglet to register
 
-doclet.usage.helpfile.parameters=<file>
-doclet.usage.helpfile.description=Include file that help link links to
+doclet.usage.tagletpath.description=\
+    The path to Taglets
 
-doclet.usage.linksource.description=Generate source in HTML
+doclet.usage.charset.parameters=\
+    <charset>
+doclet.usage.charset.description=\
+    Charset for cross-platform viewing of generated documentation
 
-doclet.usage.sourcetab.parameters=<tab length>
-doclet.usage.sourcetab.description=Specify the number of spaces each tab\n\
-\                                   takes up in the source
+doclet.usage.helpfile.parameters=\
+    <file>
+doclet.usage.helpfile.description=\
+    Include file that help link links to
 
-doclet.usage.keywords.description=Include HTML meta tags with package,\n\
-\                                   class and member info
+doclet.usage.linksource.description=\
+    Generate source in HTML
 
-doclet.usage.stylesheetfile.parameters=<path>
-doclet.usage.stylesheetfile.description=File to change style of the generated\n\
-\                                   documentation
+doclet.usage.sourcetab.parameters=\
+    <tab length>
+doclet.usage.sourcetab.description=\
+    Specify the number of spaces each tab takes up in the source
 
-doclet.usage.docencoding.parameters=<name>
-doclet.usage.docencoding.description=Specify the character encoding for the output
-
-doclet.usage.frames.description=Enable the use of frames in the generated output (default)
+doclet.usage.keywords.description=\
+    Include HTML meta tags with package, class and member info
 
-doclet.usage.no-frames.description=Disable the use of frames in the generated output
+doclet.usage.stylesheetfile.parameters=\
+    <path>
+doclet.usage.stylesheetfile.description=\
+    File to change style of the generated documentation
 
-doclet.xusage.xdocrootparent.parameters=<url>
-doclet.xusage.xdocrootparent.description=Replaces all @docRoot followed by /..\n\
-\                                   in doc comments with <url>
+doclet.usage.docencoding.parameters=\
+    <name>
+doclet.usage.docencoding.description=\
+    Specify the character encoding for the output
 
-doclet.xusage.xdoclint.description=Enable recommended checks for problems in\n\
-\                                   javadoc comments
+doclet.usage.frames.description=\
+    Enable the use of frames in the generated output (default)
+
+doclet.usage.no-frames.description=\
+    Disable the use of frames in the generated output
 
-doclet.xusage.xdoclint-extended.parameters=(all|none|[-]<group>)
-# L10N: do not localize these words: all none accessibility html missing reference syntax
-doclet.xusage.xdoclint-extended.description=Enable or disable specific checks\n\
-\                                   for problems in javadoc comments, where \n\
-\                                   <group> is one of accessibility, html,\n\
-\                                   missing, reference, or syntax.\n
+doclet.usage.xdocrootparent.parameters=\
+    <url>
+doclet.usage.xdocrootparent.description=\
+    Replaces all @docRoot followed by /.. in doc comments with\n\
+    <url>
+
+doclet.usage.xdoclint.description=\
+    Enable recommended checks for problems in javadoc comments
 
-doclet.xusage.xdoclint-package.parameters=([-]<packages>)
-doclet.xusage.xdoclint-package.description=\n\
-\                                   Enable or disable checks in specific\n\
-\                                   packages. <packages> is a comma separated\n\
-\                                   list of package specifiers. Package\n\
-\                                   specifier is either a qualified name of a\n\
-\                                   package or a package name prefix followed\n\
-\                                   by .*, which expands to all sub-packages\n\
-\                                   of the given package. Prefix the package\n\
-\                                   specifier with - to disable checks for\n\
-\                                   the specified packages.\n
+doclet.usage.xdoclint-extended.parameters=\
+    (all|none|[-]<group>)
+# L10N: do not localize these words: all none accessibility html missing reference syntax
+doclet.usage.xdoclint-extended.description=\
+    Enable or disable specific checks for problems in javadoc\n\
+    comments, where <group> is one of accessibility, html,\n\
+    missing, reference, or syntax.
+
+doclet.usage.xdoclint-package.parameters=\
+    ([-]<packages>)
+doclet.usage.xdoclint-package.description=\
+    Enable or disable checks in specific packages. <packages> is a\n\
+    comma separated list of package specifiers. A package\n\
+    specifier is either a qualified name of a package or a package\n\
+    name prefix followed by .*, which expands to all sub-packages\n\
+    of the given package. Prefix the package specifier with - to\n\
+    disable checks for the specified packages.
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Wed Jul 05 22:17:39 2017 +0200
@@ -404,8 +404,9 @@
     }
 
     public Set<Doclet.Option> getSupportedOptions() {
+        Resources resources = getResources();
         Doclet.Option[] options = {
-            new Option(this, "-author") {
+            new Option(resources, "-author") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -413,7 +414,7 @@
                     return true;
                 }
             },
-            new Option(this, "-d", 1) {
+            new Option(resources, "-d", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -421,7 +422,7 @@
                     return true;
                 }
             },
-            new Option(this, "-docencoding", 1) {
+            new Option(resources, "-docencoding", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -429,7 +430,7 @@
                     return true;
                 }
             },
-            new Option(this, "-docfilessubdirs") {
+            new Option(resources, "-docfilessubdirs") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -437,7 +438,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-encoding", 1) {
+            new Hidden(resources, "-encoding", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -445,7 +446,7 @@
                     return true;
                 }
             },
-            new Option(this, "-excludedocfilessubdir", 1) {
+            new Option(resources, "-excludedocfilessubdir", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -453,7 +454,7 @@
                     return true;
                 }
             },
-            new Option(this, "-group", 2) {
+            new Option(resources, "-group", 2) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -461,7 +462,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-javafx") {
+            new Hidden(resources, "-javafx") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -469,7 +470,7 @@
                     return true;
                 }
             },
-            new Option(this, "-keywords") {
+            new Option(resources, "-keywords") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -477,7 +478,7 @@
                     return true;
                 }
             },
-            new Option(this, "-link", 1) {
+            new Option(resources, "-link", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -486,7 +487,7 @@
                     return true;
                 }
             },
-            new Option(this, "-linksource") {
+            new Option(resources, "-linksource") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -494,7 +495,7 @@
                     return true;
                 }
             },
-            new Option(this, "-linkoffline", 2) {
+            new Option(resources, "-linkoffline", 2) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -503,7 +504,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nocomment") {
+            new Option(resources, "-nocomment") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -511,7 +512,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nodeprecated") {
+            new Option(resources, "-nodeprecated") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -519,7 +520,7 @@
                     return true;
                 }
             },
-            new Option(this, "-nosince") {
+            new Option(resources, "-nosince") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -527,7 +528,7 @@
                     return true;
                 }
             },
-            new Option(this, "-notimestamp") {
+            new Option(resources, "-notimestamp") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -535,7 +536,7 @@
                     return true;
                 }
             },
-            new Option(this, "-noqualifier", 1) {
+            new Option(resources, "-noqualifier", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -543,7 +544,7 @@
                     return true;
                 }
             },
-            new Hidden(this, "-quiet") {
+            new Hidden(resources, "-quiet") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -551,7 +552,7 @@
                     return true;
                 }
             },
-            new Option(this, "-serialwarn") {
+            new Option(resources, "-serialwarn") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -559,7 +560,7 @@
                     return true;
                 }
             },
-            new Option(this, "-sourcetab", 1) {
+            new Option(resources, "-sourcetab", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -578,7 +579,7 @@
                     return true;
                 }
             },
-            new Option(this, "-tag", 1) {
+            new Option(resources, "-tag", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -589,7 +590,7 @@
                     return true;
                 }
             },
-             new Option(this, "-taglet", 1) {
+             new Option(resources, "-taglet", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -600,7 +601,7 @@
                     return true;
                 }
             },
-            new Option(this, "-tagletpath", 1) {
+            new Option(resources, "-tagletpath", 1) {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -608,7 +609,7 @@
                     return true;
                 }
             },
-            new Option(this, "-version") {
+            new Option(resources, "-version") {
                 @Override
                 public boolean process(String opt, ListIterator<String> args) {
                     optionsProcessed.add(this);
@@ -1057,37 +1058,30 @@
         private final String description;
         private final int argCount;
 
-        protected final Configuration c;
+        protected Option(Resources resources, String name, int argCount) {
+            this(resources, "doclet.usage." + name.toLowerCase().replaceAll("^-*", ""), name, argCount);
+        }
 
-        protected Option(Configuration config, String keyName, String name, int argCount) {
-            c = config;
+        protected Option(Resources resources, String keyBase, String name, int argCount) {
             this.name = name;
-            String desc = getOptionsMessage(keyName + "description");
+            String desc = getOptionsMessage(resources, keyBase + ".description");
             if (desc.isEmpty()) {
                 this.description = "<MISSING KEY>";
                 this.parameters = "<MISSING KEY>";
             } else {
                 this.description = desc;
-                this.parameters = getOptionsMessage(keyName + "parameters");
+                this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
             }
             this.argCount = argCount;
         }
 
-        protected Option(String prefix, Configuration config, String name, int argCount) {
-            this(config, prefix + name.toLowerCase().replaceAll("^-*", "") + ".", name, argCount);
-        }
-
-        protected Option(Configuration config, String name, int argCount) {
-            this("doclet.usage.", config,  name, argCount);
+        protected Option(Resources resources, String name) {
+            this(resources, name, 0);
         }
 
-        protected Option(Configuration config, String name) {
-            this(config, name, 0);
-        }
-
-        private String getOptionsMessage(String key) {
+        private String getOptionsMessage(Resources resources, String key) {
             try {
-                return c.getResources().getText(key);
+                return resources.getText(key);
             } catch (MissingResourceException ignore) {
                 return "";
             }
@@ -1113,19 +1107,9 @@
             return parameters;
         }
 
-        /**
-         * Maintains the formatting for javadoc -help. Note the space
-         * alignment.
-         */
         @Override
         public String toString() {
-            String opt = name + (name.endsWith(":") ? "" : " ") + parameters;
-            StringBuffer sb = new StringBuffer("  ").append(opt).append(" ");
-            for (int i = opt.length(); i < 32; i++) {
-                sb.append(" ");
-            }
-            sb.append(description);
-            return sb.toString();
+            return name;
         }
 
         @Override
@@ -1135,7 +1119,14 @@
 
         @Override
         public boolean matches(String option) {
-            return name.toLowerCase().equals(option.toLowerCase());
+            boolean matchCase = name.startsWith("--");
+            if (option.startsWith("--") && option.contains("=")) {
+                return name.equals(option.substring(option.indexOf("=") + 1));
+            } else if (matchCase) {
+                return name.equals(option);
+            } else {
+                return name.toLowerCase().equals(option.toLowerCase());
+            }
         }
 
         @Override
@@ -1146,16 +1137,16 @@
 
     public abstract class XOption extends Option {
 
-        public XOption(Configuration config, String keyname, String name, int argCount) {
-            super(config, keyname, name, argCount);
+        public XOption(Resources resources, String prefix, String name, int argCount) {
+            super(resources, prefix, name, argCount);
         }
 
-        public XOption(Configuration config, String name, int argCount) {
-            super("doclet.xusage.", config, name, argCount);
+        public XOption(Resources resources, String name, int argCount) {
+            super(resources, name, argCount);
         }
 
-        public XOption(Configuration config, String name) {
-            this(config, name, 0);
+        public XOption(Resources resources, String name) {
+            this(resources, name, 0);
         }
 
         @Override
@@ -1166,12 +1157,12 @@
 
     public abstract class Hidden extends Option {
 
-        public Hidden(Configuration config, String name, int argCount) {
-            super("doclet.xusage.", config, name, argCount);
+        public Hidden(Resources resources, String name, int argCount) {
+            super(resources, name, argCount);
         }
 
-        public Hidden(Configuration config, String name) {
-            this(config, name, 0);
+        public Hidden(Resources resources, String name) {
+            this(resources, name, 0);
         }
 
         @Override
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Messager.java	Wed Jul 05 22:17:39 2017 +0200
@@ -255,7 +255,7 @@
     private void incrementErrorCount(String prefix, String msg) {
         if (nerrors < MaxErrors) {
             PrintWriter errWriter = getWriter(WriterKind.ERROR);
-            errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
+            printRawLines(errWriter, prefix + ": " + getText("javadoc.error") + " - " + msg);
             errWriter.flush();
             prompt();
             nerrors++;
@@ -293,7 +293,7 @@
     private void incrementWarningCount(String prefix, String msg) {
         if (nwarnings < MaxWarnings) {
             PrintWriter warnWriter = getWriter(WriterKind.WARNING);
-            warnWriter.println(prefix + ": " + getText("javadoc.warning") + " - " + msg);
+            printRawLines(warnWriter, prefix + ": " + getText("javadoc.warning") + " - " + msg);
             warnWriter.flush();
             nwarnings++;
         }
@@ -318,9 +318,9 @@
 
         PrintWriter noticeWriter = getWriter(WriterKind.NOTICE);
         if (path == null) {
-            noticeWriter.println(msg);
+            printRawLines(noticeWriter, msg);
         } else {
-            noticeWriter.println(prefix + ": " + msg);
+            printRawLines(noticeWriter, prefix + ": " + msg);
         }
         noticeWriter.flush();
     }
@@ -334,9 +334,9 @@
 
         PrintWriter noticeWriter = getWriter(WriterKind.NOTICE);
         if (e == null) {
-            noticeWriter.println(msg);
+            printRawLines(noticeWriter, msg);
         } else {
-            noticeWriter.println(pos + ": " + msg);
+            printRawLines(noticeWriter, pos + ": " + msg);
         }
         noticeWriter.flush();
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java	Wed Jul 05 22:17:39 2017 +0200
@@ -31,14 +31,18 @@
 import java.io.PrintWriter;
 import java.nio.file.Path;
 import java.text.BreakIterator;
+import java.text.Collator;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Objects;
 import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
@@ -61,6 +65,7 @@
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.Doclet.Option;
 import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
 
 import static javax.tools.DocumentationTool.Location.*;
 
@@ -168,7 +173,10 @@
     }
 
     void usage(boolean exit) {
-        usage("main.usage", "-help", "main.usage.foot", exit);
+        usage("main.usage", "-help", "main.usage.foot");
+
+        if (exit)
+            throw new Messager.ExitJavadoc();
     }
 
     @Override
@@ -177,30 +185,128 @@
     }
 
     void Xusage(boolean exit) {
-        usage("main.Xusage", "-X", "main.Xusage.foot", exit);
-    }
-
-    private void usage(String main, String option, String foot, boolean exit) {
-        messager.notice(main);
-        // let doclet print usage information (does nothing on error)
-        if (docletClass != null) {
-            String name = doclet.getName();
-            Set<Option> supportedOptions = doclet.getSupportedOptions();
-            messager.notice("main.doclet.usage.header", name);
-            Option.Kind myKind = option.equals("-X")
-                    ? Option.Kind.EXTENDED
-                    : Option.Kind.STANDARD;
-            supportedOptions.stream()
-                    .filter(opt -> opt.getKind() == myKind)
-                    .forEach(opt -> messager.printNotice(opt.toString()));
-        }
-        if (foot != null)
-            messager.notice(foot);
+        usage("main.Xusage", "-X", "main.Xusage.foot");
 
         if (exit)
             throw new Messager.ExitJavadoc();
     }
 
+    private void usage(String header, String option, String footer) {
+        messager.notice(header);
+        showToolOptions(option.equals("-X") ? OptionKind.EXTENDED : OptionKind.STANDARD);
+
+        // let doclet print usage information
+        if (docletClass != null) {
+            String name = doclet.getName();
+            messager.notice("main.doclet.usage.header", name);
+            showDocletOptions(option.equals("-X") ? Option.Kind.EXTENDED : Option.Kind.STANDARD);
+        }
+
+        if (footer != null)
+            messager.notice(footer);
+    }
+
+    void showToolOptions(OptionKind kind) {
+        Comparator<ToolOption> comp = new Comparator<ToolOption>() {
+            final Collator collator = Collator.getInstance(Locale.US);
+            { collator.setStrength(Collator.PRIMARY); }
+
+            @Override
+            public int compare(ToolOption o1, ToolOption o2) {
+                return collator.compare(o1.primaryName, o2.primaryName);
+            }
+        };
+
+        Stream.of(ToolOption.values())
+                    .filter(opt -> opt.kind == kind)
+                    .sorted(comp)
+                    .forEach(opt -> showToolOption(opt));
+    }
+
+    void showToolOption(ToolOption option) {
+        List<String> names = option.getNames();
+        String parameters;
+        if (option.hasArg || option.primaryName.endsWith(":")) {
+            String sep = (option == ToolOption.J) || option.primaryName.endsWith(":") ? "" : " ";
+            parameters = sep + option.getParameters(messager);
+        } else {
+            parameters = "";
+        }
+        String description = option.getDescription(messager);
+        showUsage(names, parameters, description);
+    }
+
+    void showDocletOptions(Option.Kind kind) {
+        Comparator<Doclet.Option> comp = new Comparator<Doclet.Option>() {
+            final Collator collator = Collator.getInstance(Locale.US);
+            { collator.setStrength(Collator.PRIMARY); }
+
+            @Override
+            public int compare(Doclet.Option o1, Doclet.Option o2) {
+                return collator.compare(o1.getName(), o2.getName());
+            }
+        };
+
+        doclet.getSupportedOptions().stream()
+                .filter(opt -> opt.getKind() == kind)
+                .sorted(comp)
+                .forEach(opt -> showDocletOption(opt));
+    }
+
+    void showDocletOption(Doclet.Option option) {
+        List<String> names = Arrays.asList(option.getName());
+        String parameters;
+        if (option.getArgumentCount() > 0 || option.getName().endsWith(":")) {
+            String sep = option.getName().endsWith(":") ? "" : " ";
+            parameters = sep + option.getParameters();
+        } else {
+            parameters = "";
+        }
+        String description = option.getDescription();
+        showUsage(names, parameters, description);
+    }
+
+    // The following constants are intended to format the output to
+    // be similar to that of the java launcher: i.e. "java -help".
+
+    /** The indent for the option synopsis. */
+    private static final String SMALL_INDENT = "    ";
+    /** The automatic indent for the description. */
+    private static final String LARGE_INDENT = "                  ";
+    /** The space allowed for the synopsis, if the description is to be shown on the same line. */
+    private static final int DEFAULT_SYNOPSIS_WIDTH = 13;
+    /** The nominal maximum line length, when seeing if text will fit on a line. */
+    private static final int DEFAULT_MAX_LINE_LENGTH = 80;
+    /** The format for a single-line help entry. */
+    private static final String COMPACT_FORMAT = SMALL_INDENT + "%-" + DEFAULT_SYNOPSIS_WIDTH + "s %s";
+
+    void showUsage(List<String> names, String parameters, String description) {
+        String synopses = names.stream()
+                .map(s -> s + parameters)
+                .collect(Collectors.joining(", "));
+        // If option synopses and description fit on a single line of reasonable length,
+        // display using COMPACT_FORMAT
+        if (synopses.length() < DEFAULT_SYNOPSIS_WIDTH
+                && !description.contains("\n")
+                && (SMALL_INDENT.length() + DEFAULT_SYNOPSIS_WIDTH + 1 + description.length() <= DEFAULT_MAX_LINE_LENGTH)) {
+            messager.printNotice(String.format(COMPACT_FORMAT, synopses, description));
+            return;
+        }
+
+        // If option synopses fit on a single line of reasonable length, show that;
+        // otherwise, show 1 per line
+        if (synopses.length() <= DEFAULT_MAX_LINE_LENGTH) {
+            messager.printNotice(SMALL_INDENT + synopses);
+        } else {
+            for (String name: names) {
+                messager.printNotice(SMALL_INDENT + name + parameters);
+            }
+        }
+
+        // Finally, show the description
+        messager.printNotice(LARGE_INDENT + description.replace("\n", "\n" + LARGE_INDENT));
+    }
+
 
     /**
      * Main program - external wrapper. In order to maintain backward
@@ -433,14 +539,37 @@
             docletOptions = doclet.getSupportedOptions();
         }
         String arg = args.get(idx);
+        String argBase, argVal;
+        if (arg.startsWith("--") && arg.contains("=")) {
+            int sep = arg.indexOf("=");
+            argBase = arg.substring(0, sep);
+            argVal = arg.substring(sep + 1);
+        } else {
+            argBase = arg;
+            argVal = null;
+        }
 
         for (Doclet.Option opt : docletOptions) {
-            if (opt.matches(arg)) {
-                if (args.size() - idx < opt.getArgumentCount()) {
-                    usageError("main.requires_argument", arg);
+            if (opt.matches(argBase)) {
+                if (argVal != null) {
+                    switch (opt.getArgumentCount()) {
+                        case 0:
+                            usageError("main.unnecessary_arg_provided", argBase);
+                            break;
+                        case 1:
+                            opt.process(arg, Arrays.asList(argVal).listIterator());
+                            break;
+                        default:
+                            usageError("main.only_one_argument_with_equals", argBase);
+                            break;
+                    }
+                } else {
+                    if (args.size() - idx -1 < opt.getArgumentCount()) {
+                        usageError("main.requires_argument", arg);
+                    }
+                    opt.process(arg, args.listIterator(idx + 1));
+                    idx += opt.getArgumentCount();
                 }
-                opt.process(arg, args.listIterator(idx + 1));
-                idx += opt.getArgumentCount();
                 return idx;
             }
         }
@@ -463,11 +592,11 @@
         // Step 1: loop through the args, set locale early on, if found.
         for (int i = 0 ; i < argv.size() ; i++) {
             String arg = argv.get(i);
-            if (arg.equals(ToolOption.LOCALE.opt)) {
+            if (arg.equals(ToolOption.LOCALE.primaryName)) {
                 checkOneArg(argv, i++);
                 String lname = argv.get(i);
                 locale = getLocale(lname);
-            } else if (arg.equals(ToolOption.DOCLET.opt)) {
+            } else if (arg.equals(ToolOption.DOCLET.primaryName)) {
                 checkOneArg(argv, i++);
                 if (userDocletName != null) {
                     usageError("main.more_than_one_doclet_specified_0_and_1",
@@ -478,7 +607,7 @@
                             docletName, argv.get(i));
                 }
                 userDocletName = argv.get(i);
-            } else if (arg.equals(ToolOption.DOCLETPATH.opt)) {
+            } else if (arg.equals(ToolOption.DOCLETPATH.primaryName)) {
                 checkOneArg(argv, i++);
                 if (userDocletPath == null) {
                     userDocletPath = argv.get(i);
@@ -599,8 +728,12 @@
                 handleDocletOptions(i, args, true);
 
                 if (o.hasArg) {
-                    checkOneArg(args, i++);
-                    o.process(this, args.get(i));
+                    if (arg.startsWith("--") && arg.contains("=")) {
+                        o.process(this, arg.substring(arg.indexOf('=') + 1));
+                    } else {
+                        checkOneArg(args, i++);
+                        o.process(this, args.get(i));
+                    }
                 } else if (o.hasSuffix) {
                     o.process(this, arg);
                 } else {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Wed Jul 05 22:17:39 2017 +0200
@@ -35,9 +35,12 @@
 import javax.lang.model.element.ElementKind;
 
 import com.sun.tools.javac.main.Option;
+import com.sun.tools.javac.main.Option.OptionKind;
 import com.sun.tools.javac.main.OptionHelper;
 import com.sun.tools.javac.util.Options;
 
+import static com.sun.tools.javac.main.Option.OptionKind.*;
+
 /**
  * javadoc tool options.
  *
@@ -50,197 +53,169 @@
 
     // ----- options for underlying compiler -----
 
-    BOOTCLASSPATH("-bootclasspath", true) {
+    BOOTCLASSPATH("-bootclasspath", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
-    CLASSPATH("-classpath", true) {
+    CLASS_PATH("--class-path -classpath -cp", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.CLASS_PATH, arg);
         }
     },
 
-    CP("-cp", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
-        }
-    },
-
-    CLASS_PATH("--class-path", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.CLASS_PATH, arg);
-        }
-    },
-
-    EXTDIRS("-extdirs", true) {
+    EXTDIRS("-extdirs", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.EXTDIRS, arg);
         }
     },
 
-    SOURCEPATH("-sourcepath", true) {
+    SOURCE_PATH("--source-path -sourcepath", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
         }
     },
 
-    SOURCE_PATH("--source-path", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.SOURCE_PATH, arg);
-        }
-    },
-
-    SYSCLASSPATH("-sysclasspath", true) {
+    SYSCLASSPATH("-sysclasspath", HIDDEN, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.BOOT_CLASS_PATH, arg);
         }
     },
 
-    MODULE_SOURCE_PATH("--module-source-path", true) {
+    MODULE_SOURCE_PATH("--module-source-path", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.MODULE_SOURCE_PATH, arg);
         }
     },
 
-    UPGRADE_MODULE_PATH("--upgrade-module-path", true) {
+    UPGRADE_MODULE_PATH("--upgrade-module-path", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.UPGRADE_MODULE_PATH, arg);
         }
     },
 
-    SYSTEM("--system", true) {
+    SYSTEM("--system", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.SYSTEM, arg);
         }
     },
 
-    MODULE_PATH("--module-path", true) {
-        @Override
-        public void process(Helper helper, String arg) {
-            helper.setFileManagerOpt(Option.MODULE_PATH, arg);
-        }
-    },
-
-    P("-p", true) {
+    MODULE_PATH("--module-path -p", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.MODULE_PATH, arg);
         }
     },
 
-    ADD_MODULES("--add-modules", true) {
+    ADD_MODULES("--add-modules", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.ADD_MODULES.process(helper.getOptionHelper(), opt, arg);
+            Option.ADD_MODULES.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    LIMIT_MODULES("--limit-modules", true) {
+    LIMIT_MODULES("--limit-modules", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.LIMIT_MODULES.process(helper.getOptionHelper(), opt, arg);
+            Option.LIMIT_MODULES.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    MODULE("--module", true) {
+    MODULE("--module", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.addToList(this, ",", arg);
         }
     },
 
-    ENCODING("-encoding", true) {
+    ENCODING("-encoding", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFileManagerOpt(Option.ENCODING, arg);
         }
     },
 
-    RELEASE("--release", true) {
+    RELEASE("--release", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.RELEASE.process(helper.getOptionHelper(), opt, arg);
+            Option.RELEASE.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    SOURCE("-source", true) {
+    SOURCE("-source", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.SOURCE.process(helper.getOptionHelper(), opt, arg);
+            Option.SOURCE.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    XMAXERRS("-Xmaxerrs", true) {
+    XMAXERRS("-Xmaxerrs", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.XMAXERRS.process(helper.getOptionHelper(), opt, arg);
+            Option.XMAXERRS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    XMAXWARNS("-Xmaxwarns", true) {
+    XMAXWARNS("-Xmaxwarns", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.XMAXWARNS.process(helper.getOptionHelper(), opt, arg);
+            Option.XMAXWARNS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    ADD_READS("--add-reads", true) {
+    ADD_READS("--add-reads", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.ADD_READS.process(helper.getOptionHelper(), opt, arg);
+            Option.ADD_READS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    ADD_EXPORTS("--add-exports", true) {
+    ADD_EXPORTS("--add-exports", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.ADD_EXPORTS.process(helper.getOptionHelper(), opt, arg);
+            Option.ADD_EXPORTS.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
-    XMODULE("-Xmodule:", false) {
+    XMODULE("-Xmodule:", EXTENDED, false) {
         @Override
         public void process(Helper helper, String arg) {
             Option.XMODULE.process(helper.getOptionHelper(), arg);
         }
     },
 
-    PATCH_MODULE("--patch-module", true) {
+    PATCH_MODULE("--patch-module", EXTENDED, true) {
         @Override
         public void process(Helper helper, String arg) {
-            Option.PATCH_MODULE.process(helper.getOptionHelper(), opt, arg);
+            Option.PATCH_MODULE.process(helper.getOptionHelper(), primaryName, arg);
         }
     },
 
     // ----- doclet options -----
 
-    DOCLET("-doclet", true), // handled in setDocletInvoker
+    DOCLET("-doclet", STANDARD, true), // handled in setDocletInvoker
 
-    DOCLETPATH("-docletpath", true), // handled in setDocletInvoker
+    DOCLETPATH("-docletpath", STANDARD, true), // handled in setDocletInvoker
 
     // ----- selection options -----
 
-    SUBPACKAGES("-subpackages", true) {
+    SUBPACKAGES("-subpackages", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.addToList(this, ":", arg);
         }
     },
 
-    EXCLUDE("-exclude", true) {
+    EXCLUDE("-exclude", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.addToList(this, ":", arg);
@@ -249,72 +224,72 @@
 
     // ----- filtering options -----
 
-    PACKAGE("-package") {
+    PACKAGE("-package", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.setSimpleFilter("package");
         }
     },
 
-    PRIVATE("-private") {
+    PRIVATE("-private", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.setSimpleFilter("private");
         }
     },
 
-    PROTECTED("-protected") {
+    PROTECTED("-protected", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.setSimpleFilter("protected");
         }
     },
 
-    PUBLIC("-public") {
+    PUBLIC("-public", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.setSimpleFilter("public");
         }
     },
 
-    SHOW_MEMBERS("--show-members:") {
+    SHOW_MEMBERS("--show-members", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFilter(this, arg);
         }
     },
 
-    SHOW_TYPES("--show-types:") {
+    SHOW_TYPES("--show-types", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.setFilter(this, arg);
         }
     },
 
-    SHOW_PACKAGES("--show-packages:") {
+    SHOW_PACKAGES("--show-packages", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setShowPackageAccess(SHOW_PACKAGES, helper.getOptionArgumentValue(arg));
+            helper.setShowPackageAccess(SHOW_PACKAGES, arg);
         }
     },
 
-    SHOW_MODULE_CONTENTS("--show-module-contents:") {
+    SHOW_MODULE_CONTENTS("--show-module-contents", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setShowModuleContents(SHOW_MODULE_CONTENTS, helper.getOptionArgumentValue(arg));
+            helper.setShowModuleContents(SHOW_MODULE_CONTENTS, arg);
         }
     },
 
-    EXPAND_REQUIRES("--expand-requires:") {
+    EXPAND_REQUIRES("--expand-requires", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
-            helper.setExpandRequires(EXPAND_REQUIRES, helper.getOptionArgumentValue(arg));
+            helper.setExpandRequires(EXPAND_REQUIRES, arg);
         }
     },
 
     // ----- output control options -----
 
-    PROMPT("-prompt") {
+    PROMPT("-prompt", HIDDEN) {
         @Override
         public void process(Helper helper) {
             helper.compOpts.put("-prompt", "-prompt");
@@ -322,21 +297,21 @@
         }
     },
 
-    QUIET("-quiet") {
+    QUIET("-quiet", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.jdtoolOpts.put(QUIET, true);
         }
     },
 
-    VERBOSE("-verbose") {
+    VERBOSE("-verbose", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.compOpts.put("-verbose", "");
         }
     },
 
-    XWERROR("-Xwerror") {
+    XWERROR("-Xwerror", HIDDEN) {
         @Override
         public void process(Helper helper) {
             helper.rejectWarnings = true;
@@ -346,21 +321,21 @@
 
     // ----- other options -----
 
-    BREAKITERATOR("-breakiterator") {
+    BREAKITERATOR("-breakiterator", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.breakiterator = true;
         }
     },
 
-    LOCALE("-locale", true) {
+    LOCALE("-locale", STANDARD, true) {
         @Override
         public void process(Helper helper, String arg) {
             helper.docLocale = arg;
         }
     },
 
-    XCLASSES("-Xclasses") {
+    XCLASSES("-Xclasses", HIDDEN) {
         @Override
         public void process(Helper helper) {
             helper.jdtoolOpts.put(XCLASSES, true);
@@ -369,32 +344,54 @@
 
     // ----- help options -----
 
-    HELP("-help") {
+    HELP("--help -help", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.usage();
         }
     },
 
-    X("-X") {
+    X("-X", STANDARD) {
         @Override
         public void process(Helper helper) {
             helper.Xusage();
         }
+    },
+
+    // This option exists only for the purpose of documenting itself.
+    // It's actually implemented by the launcher.
+    J("-J", STANDARD, true) {
+        @Override
+        public void process(Helper helper) {
+            throw new AssertionError("the -J flag should be caught by the launcher.");
+        }
+    },
+
+    // This option exists only for the purpose of documenting itself.
+    // It's actually implemented ahead of the normal option decoding loop.
+    Xold("-Xold", EXTENDED) {
+        @Override
+        public void process(Helper helper) {
+            throw new AssertionError("the -Xold flag should be handled earlier.");
+        }
     };
 
-    public final String opt;
+    public final String primaryName;
+    public final List<String> names;
+    public final OptionKind kind;
     public final boolean hasArg;
     public final boolean hasSuffix; // ex: foo:bar or -foo=bar
 
-    ToolOption(String opt) {
-        this(opt, false);
+    ToolOption(String opt, OptionKind kind) {
+        this(opt, kind, false);
     }
 
-    ToolOption(String opt, boolean hasArg) {
-        this.opt = opt;
+    ToolOption(String names, OptionKind kind, boolean hasArg) {
+        this.names = Arrays.asList(names.split("\\s+"));
+        this.primaryName = this.names.get(0);
+        this.kind = kind;
         this.hasArg = hasArg;
-        char lastChar = opt.charAt(opt.length() - 1);
+        char lastChar = names.charAt(names.length() - 1);
         this.hasSuffix = lastChar == ':' || lastChar == '=';
     }
 
@@ -402,16 +399,42 @@
 
     void process(Helper helper) { }
 
+    List<String> getNames() {
+        return names;
+    }
+
+    String getParameters(Messager messager) {
+        return (hasArg || primaryName.endsWith(":"))
+                ? messager.getText(getKey(primaryName, ".arg"))
+                : null;
+    }
+
+    String getDescription(Messager messager) {
+        return messager.getText(getKey(primaryName, ".desc"));
+    }
+
+    private String getKey(String optionName, String suffix) {
+        return "main.opt."
+                + optionName
+                .replaceAll("^-*", "")              // remove leading '-'
+                .replaceAll("[^A-Za-z0-9]+$", "")   // remove trailing non-alphanumeric
+                .replaceAll("[^A-Za-z0-9]", ".")    // replace internal non-alphanumeric
+                + suffix;
+    }
+
+
     static ToolOption get(String name) {
         String oname = name;
         if (name.contains(":")) {
             oname = name.substring(0, name.indexOf(':') + 1);
         } else if (name.contains("=")) {
-            oname = name.substring(0, name.indexOf('=') + 1);
+            oname = name.substring(0, name.indexOf('='));
         }
         for (ToolOption o : values()) {
-            if (oname.equals(o.opt)) {
-                return o;
+            for (String n : o.names) {
+                if (oname.equals(n)) {
+                    return o;
+                }
             }
         }
         return null;
@@ -457,11 +480,6 @@
             jdtoolOpts.put(opt, list);
         }
 
-        String getOptionArgumentValue(String in) {
-            String[] values = in.trim().split(":");
-            return values[1];
-        }
-
         void setExpandRequires(ToolOption opt, String arg) {
             switch (arg) {
                 case "public":
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Wed Jul 05 22:17:39 2017 +0200
@@ -28,112 +28,234 @@
 main.warnings={0} warnings
 main.warning={0} warning
 
-main.usage=Usage: javadoc [options] [packagenames] [sourcefiles] [@files]\n\
-\  -overview <file>                 Read overview documentation from HTML file\n\
-\  -public                          Show only public classes and members\n\
-\  -protected                       Show protected/public classes and \n\
-\                                   members (default)\n\
-\  -package                         Show package/protected/public classes\n\
-\                                   and members\n\
-\  -private                         Show all classes and members\n\
-\  --show-members:value             Specifies which members (fields, methods\n\
-\                                   etc.) will be documented, where value can\n\
-\                                   be one of "public", "protected", "package"\n\
-\                                   or "private".\n\
-\                                   Default is protected, will show public and\n\
-\                                   protected members, "public" will show only\n\
-\                                   public members, "package" will show public,\n\
-\                                   protected and package members and \n\
-\                                   "private" will show all  members\n\
-\  --show-types:value               Specifies which types (classes, interfaces\n\
-\                                   etc.) will be documented, where value can be\n\
-\                                   one of "public", "protected", "package" or\n\
-\                                   "private".\n\
-\                                   Default is "protected", show public and\n\
-\                                   protected types, "package" will show public,\n\
-\                                   protected and package types and "private"\n\
-\                                   will show all types\n\
-\  --show-packages:value            Specifies which module's packages will be\n\
-\                                   documented. Possible values are "exported"\n\
-\                                   or "all" packages\n\
-\  --show-module-contents:value     Specifies the documentation granularity of\n\
-\                                   module declarations.\n\
-\                                   Possible values are "api" or "all".\n\
-\  --expand-requires:value          Instructs the tool to expand the "requires"\n\
-\                                   module dependencies "public" expands all the\n\
-\                                   "requires public" edges of the module graph.\n\
-\                                   "all" expands all the "requires" edges of\n\
-\                                   the module graph by default only the\n\
-\                                   specified modules will be considered.\n\
-\  -help                            Display command line options and exit\n\
-\  --module m1, m2..                Document the specified module(s)\n\
-\  -doclet <class>                  Generate output via alternate doclet\n\
-\  -docletpath <path>               Specify where to find doclet class files\n\
-\  --module-source-path <path>      Specify where to find input source files\n\
-\                                   for multiple modules\n\
-\  --upgrade-module-path <path>     Override location of upgradeable modules\n\
-\  --module-path <path>, -p <path>  Specify where to find application modules\n\
-\  --add-modules <module>(,<module>)*\n\
-\                                   Root modules to resolve in addition to the\n\
-\                                   initial modules,\n\
-\                                   or all modules on the module path if\n\
-\                                   <module> is ALL-MODULE-PATH.\n\
-\  --limit-modules <module>(,<module>)*\n\
-\                                   Limit the universe of observable modules\n\
-\  --source-path <path>             Specify where to find source files\n\
-\  -sourcepath <path>               Specify where to find source files\n\
-\  --class-path <path>              Specify where to find user class files\n\
-\  -classpath <path>                Specify where to find user class files\n\
-\  -cp <path>                       Specify where to find user class files\n\
-\  -exclude <pkglist>               Specify a list of packages to exclude\n\
-\  -subpackages <subpkglist>        Specify subpackages to recursively load\n\
-\  -breakiterator                   Compute first sentence with BreakIterator\n\
-\  -bootclasspath <path>            Override location of platform class files\n\
-\                                   used for non-modular releases\n\
-\  --system <jdk>                   Override location of system modules used\n\
-\                                   for modular releases.\n\
-\  --release <release>              Provide source compatibility with\n\
-\                                   specified release\n\
-\  -source <release>                Provide source compatibility with\n\
-\                                   specified release\n\
-\  -extdirs <dirlist>               Override location of installed extensions\n\
-\  -verbose                         Output messages about what Javadoc is doing\n\
-\  -locale <name>                   Locale to be used, e.g. en_US or en_US_WIN\n\
-\  -encoding <name>                 Source file encoding name\n\
-\  -quiet                           Do not display status messages\n\
-\  -J<flag>                         Pass <flag> directly to the runtime system\n\
-\  -X                               Print a synopsis of nonstandard\n\
-\                                   options and exit\n
+main.usage=Usage:\n\
+\    javadoc [options] [packagenames] [sourcefiles] [@files]\n\
+where options include:
+
+main.opt.public.desc=\
+    Show only public classes and members
+
+main.opt.protected.desc=\
+    Show protected/public classes and members (default)
+
+main.opt.package.desc=\
+    Show package/protected/public classes and members
+
+main.opt.private.desc=\
+    Show all classes and members
+
+main.opt.show.members.arg=\
+    <value>
+main.opt.show.members.desc=\
+    Specifies which members (fields, methods, etc.) will be\n\
+    documented, where value can be one of "public", "protected",\n\
+    "package" or "private". The default is "protected", which will\n\
+    show public and protected members, "public" will show only\n\
+    public members, "package" will show public, protected and\n\
+    package members and "private" will show all members.
+
+main.opt.show.types.arg=\
+    <value>
+main.opt.show.types.desc=\
+    Specifies which types (classes, interfaces, etc.) will be\n\
+    documented, where value can be one of "public", "protected",\n\
+    "package" or "private". The default is "protected", which will\n\
+    show public and protected types, "public" will show only\n\
+    public types, "package" will show public, protected and\n\
+    package types and "private" will show all types.
+
+main.opt.show.packages.arg=\
+    <value>
+main.opt.show.packages.desc=\
+    Specifies which module's packages will be documented. Possible\n\
+    values are "exported" or "all" packages.
+
+main.opt.show.module.contents.arg=\
+    <value>
+main.opt.show.module.contents.desc=\
+    Specifies the documentation granularity of module\n\
+    declarations. Possible values are "api" or "all".
+
+main.opt.expand.requires.arg=\
+    <value>
+main.opt.expand.requires.desc=\
+    Instructs the tool to expand the set of modules to be\n\
+    documented. By default, only the modules given explicitly on\n\
+    the command line will be documented. A value of "public" will\n\
+    additionally include all "requires public" dependencies of\n\
+    those modules. A value of "all" will include all dependencies\n\
+    of those modules.
+
+main.opt.help.desc=\
+    Display command line options and exit
+
+main.opt.module.arg=\
+    <module>(,<module>)*
+main.opt.module.desc=\
+    Document the specified module(s)
+
+main.opt.doclet.arg=\
+    <class>
+main.opt.doclet.desc=\
+    Generate output via alternate doclet
+
+main.opt.docletpath.arg=\
+    <path>
+main.opt.docletpath.desc=\
+    Specify where to find doclet class files
+
+main.opt.module.source.path.arg=\
+    <path>
+main.opt.module.source.path.desc=\
+    Specify where to find input source files for multiple modules
+
+main.opt.upgrade.module.path.arg=\
+    <path>
+main.opt.upgrade.module.path.desc=\
+    Override location of upgradeable modules
+
+main.opt.module.path.arg=\
+    <path>
+main.opt.module.path.desc=\
+    Specify where to find application modules
+
+main.opt.add.modules.arg=\
+    <module>(,<module>)*
+main.opt.add.modules.desc=\
+    Root modules to resolve in addition to the initial modules,\n\
+    or all modules on the module path if <module> is\n\
+    ALL-MODULE-PATH.
+
+main.opt.limit.modules.arg=\
+    <module>(,<module>)*
+main.opt.limit.modules.desc=\
+    Limit the universe of observable modules
+
+main.opt.source.path.arg=\
+    <path>
+main.opt.source.path.desc=\
+    Specify where to find source files
+
+main.opt.class.path.arg=\
+    <path>
+main.opt.class.path.desc=\
+    Specify where to find user class files
+
+main.opt.exclude.arg=\
+    <pkglist>
+main.opt.exclude.desc=\
+    Specify a list of packages to exclude
+
+main.opt.subpackages.arg=\
+    <subpkglist>
+main.opt.subpackages.desc=\
+    Specify subpackages to recursively load
+
+main.opt.breakiterator.desc=\
+    Compute first sentence with BreakIterator
+
+main.opt.bootclasspath.arg=\
+    <path>
+main.opt.bootclasspath.desc=\
+    Override location of platform class files used for non-modular\n\
+    releases
+
+main.opt.system.arg=\
+    <jdk>
+main.opt.system.desc=\
+    Override location of system modules used for modular releases
+
+main.opt.release.arg=\
+    <release>
+main.opt.release.desc=\
+    Provide source compatibility with specified release
+
+main.opt.source.arg=\
+    <release>
+main.opt.source.desc=\
+    Provide source compatibility with specified release
+
+main.opt.extdirs.arg=\
+    <dirlist>
+main.opt.extdirs.desc=\
+    Override location of installed extensions
+
+main.opt.verbose.desc=\
+    Output messages about what Javadoc is doing
+
+main.opt.locale.arg=\
+    <name>
+main.opt.locale.desc=\
+    Locale to be used, e.g. en_US or en_US_WIN
+
+main.opt.encoding.arg=\
+    <name>
+main.opt.encoding.desc=\
+    Source file encoding name
+
+main.opt.quiet.desc=\
+    Do not display status messages
+
+main.opt.J.arg=\
+    <flag>
+main.opt.J.desc=\
+    Pass <flag> directly to the runtime system
+
+main.opt.X.desc=\
+    Print a synopsis of nonstandard options and exit
 
 main.usage.foot=\n\
 GNU-style options may use '=' instead of whitespace to separate the name of an\n\
 option from its value.\n
 
-main.Xusage=\
-\  -Xmaxerrs <number>               Set the maximum number of errors to print\n\
-\  -Xmaxwarns <number>              Set the maximum number of warnings to print\n\
-\  --add-exports <module>/<package>=<other-module>(,<other-module>)*\n\
-\                                   Specify a package to be considered as exported\n\
-\                                   from its defining module to additional modules,\n\
-\                                   or to all unnamed modules if <other-module> is\n\
-\                                   ALL-UNNAMED.\n\
-\  --add-reads <module>=<other-module>(,<other-module>)*\n\
-\                                   Specify additional modules to be considered as\n\
-\                                   required by a given module. <other-module> may be\n\
-\                                   ALL-UNNAMED to require the unnamed module.\n\
-\  -Xmodule:<module-name>           Specify a module to which the classes being\n\
-\                                   compiled belong.\n\
-\  --patch-module <module>=<file>(:<file>)*\n\
-\                                   Override or augment a module with classes\n\
-\                                   and resources in JAR files or directories\n\
-\  -Xold                            Invoke the legacy javadoc tool\n
+main.Xusage=
+
+main.opt.Xmaxerrs.arg=\
+    <number>
+main.opt.Xmaxerrs.desc=\
+    Set the maximum number of errors to print
+
+main.opt.Xmaxwarns.arg=\
+    <number>
+main.opt.Xmaxwarns.desc=\
+    Set the maximum number of warnings to print
+
+main.opt.add.exports.arg=\
+    <module>/<package>=<other-module>(,<other-module>)*
+main.opt.add.exports.desc=\
+    Specify a package to be considered as exported from its\n\
+    defining module to additional modules, or to all unnamed\n\
+    modules if <other-module> is ALL-UNNAMED
 
-main.Xusage.foot=\
+main.opt.add.reads.arg=\
+    <module>=<other-module>(,<other-module>)*
+main.opt.add.reads.desc=\
+    Specify additional modules to be considered as required by a\n\
+    given module. <other-module> may be ALL-UNNAMED to require\n\
+    the unnamed module.
+
+main.opt.Xmodule.arg=\
+    <module-name>
+main.opt.Xmodule.desc=\
+    Specify a module to which the classes being compiled belong
+
+main.opt.patch.module.arg=\
+    <module>=<file>(:<file>)*
+main.opt.patch.module.desc=\
+    Override or augment a module with classes and resources in\n\
+    JAR files or directories
+
+main.opt.Xold.desc=\
+    Invoke the legacy javadoc tool
+
+main.Xusage.foot=\n\
 These options are non-standard and subject to change without notice.
 
-main.doclet.usage.header=Provided by the {0} doclet:
+main.doclet.usage.header=\nProvided by the {0} doclet:
 
 main.requires_argument=option {0} requires an argument.
+main.unnecessary_arg_provided=option {0} does not require an argument
+main.only_one_argument_with_equals=cannot use ''='' syntax for options that require multiple arguments
 main.invalid_flag=invalid flag: {0}
 main.No_modules_packages_or_classes_specified=No modules, packages or classes specified.
 main.module_not_found=module {0} not found.\n
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Wed Jul 05 22:17:39 2017 +0200
@@ -150,7 +150,7 @@
                 task.options.help = true;
             }
         },
-        new Option(true, "-dotoutput") {
+        new Option(true, "-dotoutput", "--dot-output") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 Path p = Paths.get(arg);
                 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
@@ -191,7 +191,7 @@
                 }
             }
         },
-        new Option(false, "-apionly") {
+        new Option(false, "-apionly", "--api-only") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.apiOnly = true;
             }
@@ -203,7 +203,7 @@
                 task.options.addmods.addAll(mods);
             }
         },
-        new Option(true, "--gen-module-info") {
+        new Option(true, "--generate-module-info") {
             void process(JdepsTask task, String opt, String arg) throws BadArgs {
                 Path p = Paths.get(arg);
                 if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) {
@@ -212,7 +212,7 @@
                 task.options.genModuleInfo = Paths.get(arg);
             }
         },
-        new Option(false, "-jdkinternals") {
+        new Option(false, "-jdkinternals", "--jdk-internals") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.findJDKInternals = true;
                 task.options.verbose = CLASS;
@@ -263,19 +263,36 @@
                 task.options.addmods.add(arg);
             }
         },
+        new Option(true, "--multi-release") {
+            void process(JdepsTask task, String opt, String arg) throws BadArgs {
+                if (arg.equalsIgnoreCase("base")) {
+                    task.options.multiRelease = JarFile.baseVersion();
+                } else {
+                    try {
+                        int v = Integer.parseInt(arg);
+                        if (v < 9) {
+                            throw new BadArgs("err.invalid.arg.for.option", arg);
+                        }
+                    } catch (NumberFormatException x) {
+                        throw new BadArgs("err.invalid.arg.for.option", arg);
+                    }
+                    task.options.multiRelease = Runtime.Version.parse(arg);
+                }
+            }
+        },
 
         // ---- Target filtering options ----
-        new Option(true, "-p", "-package") {
+        new Option(true, "-p", "-package", "--package") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.packageNames.add(arg);
             }
         },
-        new Option(true, "-e", "-regex") {
+        new Option(true, "-e", "-regex", "--regex") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.regex = Pattern.compile(arg);
             }
         },
-        new Option(true, "-requires") {
+        new Option(true, "--require") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.requires.add(arg);
             }
@@ -336,7 +353,7 @@
             }
         },
 
-        new Option(false, "-I", "-inverse") {
+        new Option(false, "-I", "--inverse") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.inverse = true;
                 // equivalent to the inverse of compile-time view analysis
@@ -361,7 +378,7 @@
             }
         },
 
-        new Option(false, "-version") {
+        new Option(false, "-version", "--version") {
             void process(JdepsTask task, String opt, String arg) {
                 task.options.version = true;
             }
@@ -390,23 +407,6 @@
                 }
             }
         },
-        new Option(true, "--multi-release") {
-            void process(JdepsTask task, String opt, String arg) throws BadArgs {
-                if (arg.equalsIgnoreCase("base")) {
-                    task.options.multiRelease = JarFile.baseVersion();
-                } else {
-                    try {
-                        int v = Integer.parseInt(arg);
-                        if (v < 9) {
-                            throw new BadArgs("err.invalid.arg.for.option", arg);
-                        }
-                    } catch (NumberFormatException x) {
-                        throw new BadArgs("err.invalid.arg.for.option", arg);
-                    }
-                    task.options.multiRelease = Runtime.Version.parse(arg);
-                }
-            }
-        },
     };
 
     private static final String PROGNAME = "jdeps";
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Wed Jul 05 22:17:39 2017 +0200
@@ -13,162 +13,168 @@
 
 main.opt.h=\
 \  -h -? -help\n\
-\  --help                            Print this usage message
+\  --help                        Print this usage message
 
 main.opt.version=\
-\  -version                          Version information
+\  -version --version            Version information
 
 main.opt.v=\
-\  -v           -verbose             Print all class level dependencies\n\
-\                                    Equivalent to -verbose:class -filter:none.\n\
-\  -verbose:package                  Print package-level dependencies excluding\n\
-\                                    dependencies within the same package by default\n\
-\  -verbose:class                    Print class-level dependencies excluding\n\
-\                                    dependencies within the same package by default
+\  -v       -verbose             Print all class level dependences\n\
+\                                Equivalent to -verbose:class -filter:none.\n\
+\  -verbose:package              Print package-level dependences excluding\n\
+\                                dependences within the same package by default\n\
+\  -verbose:class                Print class-level dependences excluding\n\
+\                                dependences within the same package by default
 
 main.opt.s=\
-\  -s           -summary             Print dependency summary only.
+\  -s       -summary             Print dependency summary only.
 
 main.opt.f=\
-\  -f <regex>  -filter <regex>       Filter dependences matching the given\n\
-\                                    pattern. If given multiple times, the last\n\
-\                                    one will be used.\n\
-\  -filter:package                   Filter dependences within the same package.\n\
-\                                    This is the default.\n\
-\  -filter:archive                   Filter dependences within the same archive.\n\
-\  -filter:module                    Filter dependences within the same module.\n\
-\  -filter:none                      No -filter:package and -filter:archive\n\
-\                                    filtering.  Filtering specified via the\n\
-\                                    -filter option still applies.\n\
+\  -f <regex> -filter <regex>    Filter dependences matching the given\n\
+\                                pattern. If given multiple times, the last\n\
+\                                one will be used.\n\
+\  -filter:package               Filter dependences within the same package.\n\
+\                                This is the default.\n\
+\  -filter:archive               Filter dependences within the same archive.\n\
+\  -filter:module                Filter dependences within the same module.\n\
+\  -filter:none                  No -filter:package and -filter:archive\n\
+\                                filtering.  Filtering specified via the\n\
+\                                -filter option still applies.\n\
 
 main.opt.p=\n\
-\Options to filter dependencies:\n\
-\  -p <pkgname> -package <pkgname>   Finds dependences matching the given package\n\
-\                                    name (may be given multiple times).
+\Options to filter dependences:\n\
+\  -p <pkg>\n\
+\  -package <pkg>\n\
+\  --package <pkg>               Finds dependences matching the given package\n\
+\                                name (may be given multiple times).
 
 main.opt.e=\
-\  -e <regex> -regex <regex>         Finds dependences matching the given pattern.
+\  -e <regex>\n\
+\  -regex <regex>\n\
+\  --regex <regex>               Finds dependences matching the given pattern.
 
-main.opt.requires=\
-\  -requires <module-name>           Finds dependences matching the given module\n\
-\                                    name (may be given multiple times).\n\
-\                                    -package, -regex, -requires are mutual exclusive.
+main.opt.require=\
+\  --require <module-name>       Finds dependences matching the given module\n\
+\                                name (may be given multiple times). --package,\n\
+\                                --regex, --require are mutual exclusive.
 
 main.opt.include=\n\
  \Options to filter classes to be analyzed:\n\
-\  -include <regex>                  Restrict analysis to classes matching pattern\n\
-\                                    This option filters the list of classes to\n\
-\                                    be analyzed.  It can be used together with\n\
-\                                    -p and -e which apply pattern to the dependences
+\  -include <regex>              Restrict analysis to classes matching pattern\n\
+\                                This option filters the list of classes to\n\
+\                                be analyzed.  It can be used together with\n\
+\                                -p and -e which apply pattern to the dependences
 
 main.opt.P=\
-\  -P           -profile             Show profile containing a package
+\  -P       -profile             Show profile containing a package
 
 main.opt.cp=\
 \  -cp <path>\n\
 \  -classpath <path>\n\
-\  --class-path <path>               Specify where to find class files
+\  --class-path <path>           Specify where to find class files
 
 main.opt.module-path=\
-\  --module-path <module path>...    Specify module path
+\  --module-path <module path>   Specify module path
 
 main.opt.upgrade-module-path=\
-\  --upgrade-module-path <module path>...  Specify upgrade module path
+\  --upgrade-module-path <module path>  Specify upgrade module path
 
 main.opt.system=\
-\  --system <java-home>              Specify an alternate system module path
+\  --system <java-home>          Specify an alternate system module path
 
 main.opt.add-modules=\
 \  --add-modules <module-name>[,<module-name>...]\n\
-\                                    Adds modules to the root set for analysis
+\                                Adds modules to the root set for analysis
 
 main.opt.m=\
 \  -m <module-name>\n\
-\  --module <module-name>            Specify the root module for analysis
+\  --module <module-name>        Specify the root module for analysis
 
 main.opt.R=\
-\  -R           -recursive           Recursively traverse all run-time dependencies.\n\
-\                                    The -R option implies -filter:none.  If -p,\n\
-\                                    -e, -foption is specified, only the matching\n\
-\                                    dependences are analyzed.
+\  -R       -recursive           Recursively traverse all run-time dependences.\n\
+\                                The -R option implies -filter:none.  If -p,\n\
+\                                -e, -foption is specified, only the matching\n\
+\                                dependences are analyzed.
 
 main.opt.I=\
-\  -I           -inverse             Analyzes the dependences per other given options\n\
-\                                    and then find all artifacts that directly\n\
-\                                    and indirectly depend on the matching nodes.\n\
-\                                    This is equivalent to the inverse of\n\
-\                                    compile-time view analysis and print\n\
-\                                    dependency summary.  This option must use\n\
-\                                    with -requires, -package or -regex option.
+\  -I       --inverse            Analyzes the dependences per other given options\n\
+\                                and then find all artifacts that directly\n\
+\                                and indirectly depend on the matching nodes.\n\
+\                                This is equivalent to the inverse of\n\
+\                                compile-time view analysis and print\n\
+\                                dependency summary.  This option must use\n\
+\                                with --require, --package or --regex option.
 
 main.opt.compile-time=\
-\  --compile-time                    Compile-time view of transitive dependencies\n\
-\                                    i.e. compile-time view of -R option.\n\
-\                                    Analyzes the dependences per other given options\n\
-\                                    If a dependence is found from a directory,\n\
-\                                    a JAR file or a module, all classes in that \n\
-\                                    containing archive are analyzed.
+\  --compile-time                Compile-time view of transitive dependences\n\
+\                                i.e. compile-time view of -R option.\n\
+\                                Analyzes the dependences per other given options\n\
+\                                If a dependence is found from a directory,\n\
+\                                a JAR file or a module, all classes in that \n\
+\                                containing archive are analyzed.
 
 main.opt.apionly=\
-\  -apionly                          Restrict analysis to APIs i.e. dependences\n\
-\                                    from the signature of public and protected\n\
-\                                    members of public classes including field\n\
-\                                    type, method parameter types, returned type,\n\
-\                                    checked exception types etc.
+\  -apionly\n\
+\  --api-only                    Restrict analysis to APIs i.e. dependences\n\
+\                                from the signature of public and protected\n\
+\                                members of public classes including field\n\
+\                                type, method parameter types, returned type,\n\
+\                                checked exception types etc.
 
-main.opt.gen-module-info=\
-\  --gen-module-info <dir>           Generate module-info.java under the specified\n\
-\                                    directory. The specified JAR files will be\n\
-\                                    analyzed. This option cannot be used with\n\
-\                                    -dotoutput or -cp.
+main.opt.generate-module-info=\
+\  --generate-module-info <dir>  Generate module-info.java under the specified\n\
+\                                directory. The specified JAR files will be\n\
+\                                analyzed. This option cannot be used with\n\
+\                                --dot-output or --class-path.
 
 main.opt.check=\
 \  --check <module-name>[,<module-name>...\n\
-\                                    Analyze the dependence of the specified modules\n\
-\                                    It prints the module descriptor, the resulting\n\
-\                                    module dependences after analysis and the\n\
-\                                    graph after transition reduction.  It also\n\
-\                                    identifies any unused qualified exports.
+\                                Analyze the dependence of the specified modules\n\
+\                                It prints the module descriptor, the resulting\n\
+\                                module dependences after analysis and the\n\
+\                                graph after transition reduction.  It also\n\
+\                                identifies any unused qualified exports.
 
 
 main.opt.dotoutput=\
-\  -dotoutput <dir>                  Destination directory for DOT file output
+\  -dotoutput <dir>\n\
+\  --dot-output <dir>            Destination directory for DOT file output
 
 main.opt.jdkinternals=\
-\  -jdkinternals                     Finds class-level dependences on JDK internal\n\
-\                                    APIs. By default, it analyzes all classes\n\
-\                                    on -classpath and input files unless -include\n\
-\                                    option is specified. This option cannot be\n\
-\                                    used with -p, -e and -s options.\n\
-\                                    WARNING: JDK internal APIs are inaccessible.
+\  -jdkinternals\n\
+\  --jdk-internals               Finds class-level dependences on JDK internal\n\
+\                                APIs. By default, it analyzes all classes\n\
+\                                on --class-path and input files unless -include\n\
+\                                option is specified. This option cannot be\n\
+\                                used with -p, -e and -s options.\n\
+\                                WARNING: JDK internal APIs are inaccessible.
 
 main.opt.depth=\
-\  -depth=<depth>                    Specify the depth of the transitive\n\
-\                                    dependency analysis
+\  -depth=<depth>                Specify the depth of the transitive\n\
+\                                dependency analysis
 
 main.opt.q=\
-\  -q           -quiet               Do not show missing dependencies from \n\
-\                                    -genmoduleinfo output.
+\  -q       -quiet               Do not show missing dependences from \n\
+\                                --generate-module-info output.
 
 main.opt.multi-release=\
-\  --multi-release <version>         Specifies the version when processing\n\
-\                                    multi-release jar files.  <version> should\n\
-\                                    be integer >= 9 or base.
+\  --multi-release <version>     Specifies the version when processing\n\
+\                                multi-release jar files.  <version> should\n\
+\                                be integer >= 9 or base.
 
 err.unknown.option=unknown option: {0}
 err.missing.arg=no value given for {0}
 err.invalid.arg.for.option=invalid argument for option: {0}
 err.option.after.class=option must be specified before classes: {0}
-err.genmoduleinfo.not.jarfile={0} not valid for --gen-module-info option (must be non-modular JAR file)
+err.genmoduleinfo.not.jarfile={0} not valid for --generate-module-info option (must be non-modular JAR file)
 err.profiles.msg=No profile information
 err.exception.message={0}
 err.invalid.path=invalid path: {0}
 err.invalid.module.option=Cannot set {0} with {1} option.
-err.invalid.filters=Only one of -package (-p), -regex (-e), -requires option can be set
+err.invalid.filters=Only one of --package (-p), --regex (-e), --require option can be set
 err.module.not.found=module not found: {0}
 err.root.module.not.set=root module set empty
-err.invalid.inverse.option={0} cannot be used with -inverse option
-err.inverse.filter.not.set={0} cannot be used with -inverse option
+err.invalid.inverse.option={0} cannot be used with --inverse option
 err.multirelease.option.exists={0} is not a multi-release jar file, but the --multi-release option is set
 err.multirelease.option.notfound={0} is a multi-release jar file, but the --multi-release option is not set
 err.multirelease.version.associated=class {0} already associated with version {1}, trying to add version {2}
@@ -178,7 +184,7 @@
 warn.replace.useJDKInternals=\
 JDK internal APIs are unsupported and private to JDK implementation that are\n\
 subject to be removed or changed incompatibly and could break your application.\n\
-Please modify your code to eliminate dependency on any JDK internal APIs.\n\
+Please modify your code to eliminate dependence on any JDK internal APIs.\n\
 For the most recent update on JDK internal API replacements, please check:\n\
 {0}
 
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Jul 05 22:17:39 2017 +0200
@@ -199,6 +199,7 @@
     private boolean feedbackInitialized = false;
     private String commandLineFeedbackMode = null;
     private List<String> remoteVMOptions = new ArrayList<>();
+    private List<String> compilerOptions = new ArrayList<>();
 
     SourceCodeAnalysis analysis;
     JShell state = null;
@@ -558,9 +559,14 @@
         parser.accepts("s");
         parser.accepts("v");
         OptionSpec<String> r = parser.accepts("R").withRequiredArg();
+        OptionSpec<String> c = parser.accepts("C").withRequiredArg();
         parser.acceptsAll(asList("h", "help"));
         parser.accepts("version");
         parser.accepts("full-version");
+
+        parser.accepts("X");
+        OptionSpec<String> addExports = parser.accepts("add-exports").withRequiredArg();
+
         NonOptionArgumentSpec<String> loadFileSpec = parser.nonOptions();
 
         OptionSet options;
@@ -585,6 +591,10 @@
             printUsage();
             return null;
         }
+        if (options.has("X")) {
+            printUsageX();
+            return null;
+        }
         if (options.has("version")) {
             cmdout.printf("jshell %s\n", version());
             return null;
@@ -630,7 +640,19 @@
             commandLineFeedbackMode = "verbose";
         }
         if (options.has(r)) {
-            remoteVMOptions = options.valuesOf(r);
+            remoteVMOptions.addAll(options.valuesOf(r));
+        }
+        if (options.has(c)) {
+            compilerOptions.addAll(options.valuesOf(c));
+        }
+
+        if (options.has(addExports)) {
+            List<String> exports = options.valuesOf(addExports).stream()
+                    .map(mp -> mp + "=ALL-UNNAMED")
+                    .flatMap(mp -> Stream.of("--add-exports", mp))
+                    .collect(toList());
+            remoteVMOptions.addAll(exports);
+            compilerOptions.addAll(exports);
         }
 
         return options.valuesOf(loadFileSpec);
@@ -640,6 +662,10 @@
         cmdout.print(getResourceString("help.usage"));
     }
 
+    private void printUsageX() {
+        cmdout.print(getResourceString("help.usage.x"));
+    }
+
     /**
      * Message handler to use during initial start-up.
      */
@@ -683,7 +709,8 @@
                 .idGenerator((sn, i) -> (currentNameSpace == startNamespace || state.status(sn).isActive())
                         ? currentNameSpace.tid(sn)
                         : errorNamespace.tid(sn))
-                .remoteVMOptions(remoteVMOptions.toArray(new String[remoteVMOptions.size()]))
+                .remoteVMOptions(remoteVMOptions.stream().toArray(String[]::new))
+                .compilerOptions(compilerOptions.stream().toArray(String[]::new))
                 .build();
         shutdownSubscription = state.onShutdown((JShell deadState) -> {
             if (deadState == state) {
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Wed Jul 05 22:17:39 2017 +0200
@@ -164,8 +164,15 @@
 \                            Use one -J for each runtime flag or flag argument\n\
 \    -R<flag>              Pass <flag> to the remote runtime system.\n\
 \                            Use one -R for each remote flag or flag argument\n\
+\    -C<flag>              Pass <flag> to the compiler.\n\
+\                            Use one -C for each compiler flag or flag argument\n\
 \    --help                Print this synopsis of standard options\n\
-\    --version             Version information\n
+\    --version             Version information\n\
+\    -X                    Print help on non-standard options\n
+help.usage.x = \
+\    --add-exports <module>/<package>   Export specified module-private package to snippets\n\
+\    \n\
+\These options are non-standard and subject to change without notice.\n
 
 help.list.summary = list the source you have typed
 help.list.args = [<name or id>|-all|-start]
--- a/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java	Wed Jul 05 22:17:39 2017 +0200
@@ -41,6 +41,7 @@
 import java.util.Arrays;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.List;
@@ -410,6 +411,23 @@
     }
 
     /**
+     * Get the content of the one of the output streams written by
+     * javadoc.
+     */
+    public String getOutput(Output output) {
+        return outputMap.get(output);
+    }
+
+    /**
+     * Get the content of the one of the output streams written by
+     * javadoc.
+     */
+    public List<String> getOutputLines(Output output) {
+        String text = outputMap.get(output);
+        return (text == null) ? Collections.emptyList() : Arrays.asList(text.split(NL));
+    }
+
+    /**
      * Check for files in (or not in) the generated output.
      * @param expectedFound true if all of the files are expected
      *  to be found, or false if all of the files are expected to be
--- a/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Wed Jul 05 22:17:39 2017 +0200
@@ -32,6 +32,9 @@
  * @run main TestHelpOption
  */
 
+import java.util.*;
+import java.util.stream.*;
+
 public class TestHelpOption extends JavadocTester {
 
     public static void main(String... args) throws Exception {
@@ -40,6 +43,26 @@
     }
 
     @Test
+    void testLineLengths() {
+        javadoc("-d", "out1",
+                "-sourcepath", testSrc,
+                "-X",
+                testSrc("TestXOption.java"));
+        checkExit(Exit.OK);
+        List<String> longLines = getOutputLines(Output.OUT).stream()
+                .filter(s -> s.length() > 80)
+                .collect(Collectors.toList());
+        checking("line lengths");
+        if (longLines.isEmpty()) {
+            passed("all lines OK");
+        } else {
+            out.println("long lines:");
+            longLines.stream().forEach(s -> out.println(">>>" + s + "<<<"));
+            failed(longLines.size() + " long lines");
+        }
+    }
+
+    @Test
     void testWithOption() {
         javadoc("-d", "out1",
                 "-sourcepath", testSrc,
@@ -107,7 +130,7 @@
                 "-use ",
                 "-version ",
                 "-author ",
-                "-docfilessubdirs ",
+                "-docfilessubdirs\n",
                 "-splitindex ",
                 "-windowtitle ",
                 "-doctitle ",
@@ -119,11 +142,11 @@
                 "-excludedocfilessubdir ",
                 "-group ",
                 "-nocomment ",
-                "-nodeprecated ",
+                "-nodeprecated\n",
                 "-noqualifier ",
                 "-nosince ",
                 "-notimestamp ",
-                "-nodeprecatedlist ",
+                "-nodeprecatedlist\n",
                 "-notree ",
                 "-noindex ",
                 "-nohelp ",
--- a/langtools/test/jdk/javadoc/doclet/testXOption/TestXOption.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/javadoc/doclet/testXOption/TestXOption.java	Wed Jul 05 22:17:39 2017 +0200
@@ -31,6 +31,9 @@
  * @run main TestXOption
  */
 
+import java.util.*;
+import java.util.stream.*;
+
 public class TestXOption extends JavadocTester {
 
     public static void main(String... args) throws Exception {
@@ -39,6 +42,26 @@
     }
 
     @Test
+    void testLineLengths() {
+        javadoc("-d", "out1",
+                "-sourcepath", testSrc,
+                "-X",
+                testSrc("TestXOption.java"));
+        checkExit(Exit.OK);
+        List<String> longLines = getOutputLines(Output.OUT).stream()
+                .filter(s -> s.length() > 80)
+                .collect(Collectors.toList());
+        checking("line lengths");
+        if (longLines.isEmpty()) {
+            passed("all lines OK");
+        } else {
+            out.println("long lines:");
+            longLines.stream().forEach(s -> out.println(">>>" + s + "<<<"));
+            failed(longLines.size() + " long lines");
+        }
+    }
+
+    @Test
     void testWithOption() {
         javadoc("-d", "out1",
                 "-sourcepath", testSrc,
@@ -58,14 +81,9 @@
     }
 
     private void checkOutput(boolean expectFound) {
-        // TODO: It's an ugly hidden side-effect of the current doclet API
-        // that the -X output from the tool and the -X output from the doclet
-        // come out on different streams!
-        // When we clean up the doclet API, this should be rationalized.
         checkOutput(Output.OUT, expectFound,
                 "-Xmaxerrs ",
-                "-Xmaxwarns ");
-        checkOutput(Output.OUT, expectFound,
+                "-Xmaxwarns ",
                 "-Xdocrootparent ",
                 "-Xdoclint ",
                 "-Xdoclint:");
--- a/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/CheckResourceKeys.java	Wed Jul 05 22:17:39 2017 +0200
@@ -145,6 +145,9 @@
             // ignore these synthesized keys, tested by usageTests
             if (rk.startsWith("doclet.usage.") || rk.startsWith("doclet.xusage"))
                 continue;
+            // ignore these synthesized keys, tested by usageTests
+            if (rk.matches("main\\.opt\\..*\\.(arg|desc)"))
+                continue;
             if (codeKeys.contains(rk))
                 continue;
 
@@ -161,6 +164,9 @@
             // ignore these synthesized keys, tested by usageTests
             if (ck.startsWith("doclet.usage.") || ck.startsWith("doclet.xusage."))
                 continue;
+            // ignore this partial key, tested by usageTests
+            if (ck.equals("main.opt."))
+                continue;
             if (resourceKeys.contains(ck))
                 continue;
             error("No resource for \"" + ck + "\"");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/OptionSyntaxTest.java	Wed Jul 05 22:17:39 2017 +0200
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8166144
+ * @summary support new-style options
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * @modules jdk.compiler/com.sun.tools.javac.main
+ * @modules jdk.javadoc/jdk.javadoc.internal.api
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @library /tools/lib
+ * @build toolbox.JavacTask toolbox.JavadocTask toolbox.ModuleBuilder toolbox.TestRunner toolbox.ToolBox
+ * @run main OptionSyntaxTest
+ */
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.Set;
+
+import javax.lang.model.SourceVersion;
+
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
+
+import toolbox.JavadocTask;
+import toolbox.ModuleBuilder;
+import toolbox.Task;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+
+public class OptionSyntaxTest extends TestRunner {
+    public static class TestDoclet implements Doclet {
+        @Override
+        public boolean run(DocletEnvironment root) {
+            System.out.println("TestDoclet.run");
+            return true;
+        }
+
+        @Override
+        public String getName() {
+            return "Test";
+        }
+
+        @Override
+        public Set<Option> getSupportedOptions() {
+            return options;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+
+        @Override
+        public void init(Locale locale, Reporter reporter) {
+        }
+
+        private final Set<Doclet.Option> options = new HashSet<>(Arrays.asList(
+                new DOption("-old", 0),
+                new DOption("-oldWithArg", 1),
+                new DOption("-oldWithArgs", 2),
+                new DOption("--new", 0),
+                new DOption("--newWithArg", 1),
+                new DOption("--newWithArgs", 2)
+        ));
+
+    }
+
+    static class DOption implements Doclet.Option {
+        private final String name;
+        private final int argCount;
+
+        DOption(String name, int argCount) {
+            this.name = name;
+            this.argCount = argCount;
+        }
+
+        @Override
+        public int getArgumentCount() {
+            return argCount;
+        }
+
+        @Override
+        public String getDescription() {
+            return "description[" + name + "]";
+        }
+
+        @Override
+        public Kind getKind() {
+            return Doclet.Option.Kind.STANDARD;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String getParameters() {
+            return argCount > 0 ? "parameters[" + name + "," + argCount + "]" : null;
+        }
+
+        @Override
+        public boolean matches(String option) {
+            return option.equals(name);
+        }
+
+        @Override
+        public boolean process(String option, ListIterator<String> arguments) {
+            List<String> args = new ArrayList<>();
+            for (int i = 0; i < argCount && arguments.hasNext(); i++) {
+                args.add(arguments.next());
+            }
+            System.out.println("process " + option + " " + args);
+            return args.stream().filter(s -> s.startsWith("arg")).count() == argCount;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        OptionSyntaxTest t = new OptionSyntaxTest();
+        t.runTests();
+    }
+
+    private final ToolBox tb = new ToolBox();
+    private final Path src = Paths.get("src");
+    private final Path modules = Paths.get("modules");
+
+    OptionSyntaxTest() throws IOException {
+        super(System.err);
+        initModules();
+    }
+
+    void initModules() throws IOException {
+        new ModuleBuilder(tb, "m1")
+                .exports("p1")
+                .classes("package p1; public class C1 { }")
+                .write(src);
+
+        new ModuleBuilder(tb, "m2")
+                .exports("p2")
+                .classes("package p2; public class C2 { }")
+                .build(modules);
+
+    }
+
+    @Test
+    public void testBasic() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewSourcePath() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "--source-path", "src/m1",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewSourcePathEquals() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "--source-path=src/m1",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testOldDocletArgs() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "-old",
+                       "-oldWithArg", "arg",
+                       "-oldWithArgs", "arg1", "arg2",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewDocletArgs() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--new",
+                       "--newWithArg", "arg",
+                       "--newWithArgs", "arg1", "arg2",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewDocletArgsEquals() {
+        new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--new", "--newWithArg=arg",
+                       "p1")
+                .run()
+                .writeAll();
+    }
+
+    @Test
+    public void testNewDocletArgsMissingArgs() throws Exception {
+        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--newWithArg")
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("option --newWithArg requires an argument"))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testNewDocletArgsExtraArgs() throws Exception {
+        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--new=arg",
+                       "p1")
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("option --new does not require an argument"))
+            throw new Exception("expected output not found");
+    }
+
+    @Test
+    public void testNewDocletArgsExtraArgs2() throws Exception {
+        String log = new JavadocTask(tb, Task.Mode.CMDLINE)
+                .options("-docletpath", System.getProperty("test.classes"),
+                       "-doclet", TestDoclet.class.getName(),
+                       "-sourcepath", "src/m1",
+                       "--newWithArgs=arg1 arg2",
+                       "p1")
+                .run(Task.Expect.FAIL)
+                .writeAll()
+                .getOutput(Task.OutputKind.DIRECT);
+        if (!log.contains("cannot use '=' syntax for options that require multiple arguments"))
+            throw new Exception("expected output not found");
+    }
+
+}
--- a/langtools/test/jdk/javadoc/tool/api/basic/IsSupportedOptionTest.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/api/basic/IsSupportedOptionTest.java	Wed Jul 05 22:17:39 2017 +0200
@@ -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
@@ -35,7 +35,7 @@
 import javax.tools.ToolProvider;
 
 /**
- * Tests for DocumentationTool.usSupportedOption method.
+ * Tests for DocumentationTool.isSupportedOption method.
  */
 public class IsSupportedOptionTest extends APITest {
     public static void main(String... args) throws Exception {
--- a/langtools/test/jdk/javadoc/tool/modules/FilterOptions.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/modules/FilterOptions.java	Wed Jul 05 22:17:39 2017 +0200
@@ -70,7 +70,7 @@
     @Test
     public void testModuleModeApi(Path base) throws Exception {
         execTask("--module-source-path", src,
-                "--module", "m1", "--show-module-contents:api");
+                "--module", "m1", "--show-module-contents", "api");
 
         checkModuleMode("API");
     }
@@ -78,7 +78,7 @@
     @Test
     public void testModuleModeAll(Path base) throws Exception {
         execTask("--module-source-path", src,
-                "--module", "m1", "--show-module-contents:all");
+                "--module", "m1", "--show-module-contents", "all");
 
         checkModuleMode("ALL");
     }
@@ -87,7 +87,7 @@
     public void testShowPackagesExported(Path base)  throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-packages:exported"); // default
+                "--show-packages", "exported"); // default
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -99,7 +99,7 @@
     public void testShowPackagesAll(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-packages:all");
+                "--show-packages", "all");
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
         checkPackagesIncluded("pub", "pro");
@@ -112,7 +112,7 @@
     public void testShowTypesPrivate(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:private");
+                "--show-types", "private");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -129,7 +129,7 @@
     public void testShowTypesPackage(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:package");
+                "--show-types", "package");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -145,7 +145,7 @@
     public void testShowTypesProtected(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:protected");
+                "--show-types", "protected");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -162,7 +162,7 @@
     public void testShowTypesPublic(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-types:public");
+                "--show-types", "public");
 
         checkModulesSpecified("m1");
         checkModulesIncluded("m1");
@@ -179,7 +179,7 @@
     public void testShowMembersPrivate(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:private");
+                "--show-members", "private");
 
         checkMembers(Visibility.PRIVATE);
     }
@@ -188,7 +188,7 @@
     public void testShowMembersPackage(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:package");
+                "--show-members", "package");
 
         checkMembers(Visibility.PACKAGE);
     }
@@ -197,7 +197,7 @@
     public void testShowMembersProtected(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:protected");
+                "--show-members", "protected");
 
         checkMembers(Visibility.PROTECTED);
     }
@@ -206,7 +206,7 @@
     public void testShowMembersPublic(Path base) throws Exception {
         execTask("--module-source-path", src,
                 "--module", "m1",
-                "--show-members:public");
+                "--show-members", "public");
 
         checkMembers(Visibility.PUBLIC);
     }
--- a/langtools/test/jdk/javadoc/tool/modules/Modules.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/modules/Modules.java	Wed Jul 05 22:17:39 2017 +0200
@@ -440,7 +440,7 @@
 
         execTask("--module-source-path", src.toString(),
                 "--module", "M",
-                "--expand-requires:public");
+                "--expand-requires", "public");
 
         checkModulesSpecified("M", "N", "O");
         checkModulesIncluded("M", "N", "O");
@@ -465,7 +465,7 @@
 
         execTask("--module-source-path", src.toString(),
                 "--module", "M",
-                "--expand-requires:all");
+                "--expand-requires", "all");
 
         checkModulesSpecified("M", "java.base", "N", "L", "O");
         checkModulesIncluded("M", "java.base", "N", "L", "O");
@@ -493,7 +493,7 @@
 
         execNegativeTask("--module-source-path", src.toString(),
                 "--module", "MIA",
-                "--expand-requires:all");
+                "--expand-requires", "all");
 
         assertErrorPresent("javadoc: error - module MIA not found.");
     }
@@ -515,7 +515,7 @@
 
         execNegativeTask("--module-source-path", src.toString(),
                 "--module", "M,N,L,MIA,O,P",
-                "--expand-requires:all");
+                "--expand-requires", "all");
 
         assertErrorPresent("javadoc: error - module MIA not found");
     }
--- a/langtools/test/jdk/jshell/HistoryTest.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/jshell/HistoryTest.java	Wed Jul 05 22:17:39 2017 +0200
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8166744
  * @summary Test Completion
  * @modules jdk.internal.le/jdk.internal.jline.extra
  *          jdk.jshell/jdk.internal.jshell.tool
@@ -75,6 +76,44 @@
              });
     }
 
+    public void test8166744() {
+        test(
+             a -> {if (!a) setCommandInput("class C {\n");},
+             a -> {if (!a) setCommandInput("void f() {\n");},
+             a -> {if (!a) setCommandInput("}\n");},
+             a -> {assertCommand(a, "}", "|  created class C");},
+             a -> {
+                 if (!a) {
+                     try {
+                         previousAndAssert(getHistory(), "}");
+                         previousAndAssert(getHistory(), "}");
+                         previousAndAssert(getHistory(), "void f() {");
+                         previousAndAssert(getHistory(), "class C {");
+                         getHistory().add("class C{");
+                     } catch (Exception ex) {
+                         throw new IllegalStateException(ex);
+                     }
+                 }
+                 assertCommand(a, "int dummy;", "dummy ==> 0");
+             });
+        test(
+             a -> {if (!a) setCommandInput("class C {\n");},
+             a -> {if (!a) setCommandInput("void f() {\n");},
+             a -> {if (!a) setCommandInput("}\n");},
+             a -> {assertCommand(a, "}", "|  created class C");},
+             a -> {
+                 if (!a) {
+                     try {
+                         previousSnippetAndAssert(getHistory(), "class C {");
+                         getHistory().add("class C{");
+                     } catch (Exception ex) {
+                         throw new IllegalStateException(ex);
+                     }
+                 }
+                 assertCommand(a, "int dummy;", "dummy ==> 0");
+             });
+    }
+
     private EditingHistory getHistory() throws Exception {
         Field input = repl.getClass().getDeclaredField("input");
         input.setAccessible(true);
--- a/langtools/test/jdk/jshell/ToolBasicTest.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java	Wed Jul 05 22:17:39 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347
+ * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714
  * @summary Tests for Basic tests for REPL tool
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -574,4 +574,20 @@
         }
     }
 
+    public void testAddExports() {
+        test(false, new String[]{"--no-startup"},
+                a -> assertCommandOutputStartsWith(a, "import jdk.internal.misc.VM;", "|  Error:")
+        );
+        test(false, new String[]{"--no-startup",
+            "-R--add-exports", "-Rjava.base/jdk.internal.misc=ALL-UNNAMED",
+            "-C--add-exports", "-Cjava.base/jdk.internal.misc=ALL-UNNAMED"},
+                a -> assertImport(a, "import jdk.internal.misc.VM;", "", "jdk.internal.misc.VM"),
+                a -> assertCommand(a, "System.err.println(VM.isBooted())", "", "", null, "", "true\n")
+        );
+        test(false, new String[]{"--no-startup", "--add-exports", "java.base/jdk.internal.misc"},
+                a -> assertImport(a, "import jdk.internal.misc.VM;", "", "jdk.internal.misc.VM"),
+                a -> assertCommand(a, "System.err.println(VM.isBooted())", "", "", null, "", "true\n")
+        );
+    }
+
 }
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Wed Jul 05 22:17:39 2017 +0200
@@ -66,6 +66,7 @@
 compiler.misc.kindname.type.variable.bound
 compiler.misc.kindname.value
 compiler.misc.incompatible.eq.lower.bounds              # cannot happen?
+compiler.misc.module.name.mismatch
 compiler.misc.no.unique.minimal.instance.exists
 compiler.misc.no.unique.maximal.instance.exists         # cannot happen?
 compiler.misc.resume.abort                              # prompt for a response
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/bridges/ReorderedBoundsTest.java	Wed Jul 05 22:17:39 2017 +0200
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8166363
+ * @summary Method with reordered type parameter bounds compiles with Override annotation but does not actually override superclass method.
+ * @run main ReorderedBoundsTest
+ */
+
+import java.io.Serializable;
+
+public class ReorderedBoundsTest {
+  public static class Parent {
+    public <T extends Appendable & Serializable> String printClassName(T t) {
+      return "Parent";
+    }
+  }
+
+  public static class OrderedChild extends Parent {
+    @Override
+    public <T extends Appendable & Serializable> String printClassName(T t) {
+      return "OrderedChild";
+    }
+  }
+
+  public static class ReorderedChild extends Parent {
+    @Override
+    public <T extends Serializable & Appendable> String printClassName(T t) {
+      return "ReorderedChild";
+    }
+  }
+
+  public static void main(String[] args) {
+
+    String s;
+    Parent p = new OrderedChild();
+    if (!(s = p.printClassName(new StringBuilder())).equals("OrderedChild"))
+        throw new AssertionError("Bad output: " + s);
+
+    p = new ReorderedChild();
+    if (!(s = p.printClassName(new StringBuilder())).equals("ReorderedChild"))
+        throw new AssertionError("Bad output: " + s);
+  }
+}
\ No newline at end of file
--- a/langtools/test/tools/javac/modules/EdgeCases.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/tools/javac/modules/EdgeCases.java	Wed Jul 05 22:17:39 2017 +0200
@@ -58,6 +58,8 @@
 import toolbox.JarTask;
 import toolbox.JavacTask;
 import toolbox.Task;
+import toolbox.Task.Expect;
+import toolbox.Task.OutputKind;
 
 public class EdgeCases extends ModuleTestBase {
 
@@ -304,4 +306,147 @@
         }
     }
 
+    @Test
+    public void testImplicitJavaBase(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path src_java_base = src.resolve("java.base");
+        Files.createDirectories(src_java_base);
+        tb.writeJavaFiles(src_java_base, "module java.base { exports java.lang; }");
+        tb.writeJavaFiles(src_java_base,
+                          "package java.lang; public class Object {}");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        //module-info from source:
+        new JavacTask(tb)
+            .options("-sourcepath", src_java_base.toString())
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run()
+            .writeAll();
+
+        //module-info from class:
+        if (!Files.exists(classes.resolve("module-info.class"))) {
+            throw new AssertionError("module-info.class not created!");
+        }
+
+        new JavacTask(tb)
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run()
+            .writeAll();
+
+        //broken module-info.class:
+        Files.newOutputStream(classes.resolve("module-info.class")).close();
+
+        List<String> log = new JavacTask(tb)
+            .options("-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "- compiler.err.cant.access: <error>.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.illegal.start.of.class.file))",
+                "1 error");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+
+        //broken module-info.java:
+        Files.delete(classes.resolve("module-info.class"));
+
+        try (Writer out = Files.newBufferedWriter(src_java_base.resolve("module-info.java"))) {
+            out.write("class Broken {}");
+        }
+
+        log = new JavacTask(tb)
+            .options("-sourcepath", src_java_base.toString(),
+                                "-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(src_java_base.resolve("java").resolve("lang").resolve("Object.java")))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        expected = Arrays.asList("X");
+
+        if (expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    @Test
+    public void testModuleInfoNameMismatchSource(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Path m1 = src.resolve("m1");
+        Files.createDirectories(m1);
+        tb.writeJavaFiles(m1, "module other { }",
+                              "package test; public class Test {}");
+        Path classes = base.resolve("classes");
+        tb.createDirectories(classes);
+
+        List<String> log = new JavacTask(tb)
+            .options("--module-source-path", src.toString(),
+                     "-XDrawDiagnostics")
+            .outdir(classes)
+            .files(findJavaFiles(m1.resolve("test").resolve("Test.java")))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "module-info.java:1:1: compiler.err.module.name.mismatch: other, m1",
+                "- compiler.err.cant.access: m1.module-info, (compiler.misc.cant.resolve.modules)",
+                "2 errors");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
+    @Test
+    public void testModuleInfoNameMismatchClass(Path base) throws Exception {
+        Path src = base.resolve("src");
+        Files.createDirectories(src);
+        tb.writeJavaFiles(src, "module other { }",
+                               "package test; public class Test {}");
+        Path classes = base.resolve("classes");
+        Path m1Classes = classes.resolve("m1");
+        tb.createDirectories(m1Classes);
+
+        new JavacTask(tb)
+            .outdir(m1Classes)
+            .files(findJavaFiles(src))
+            .run()
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        Path src2 = base.resolve("src2");
+        Files.createDirectories(src2);
+        tb.writeJavaFiles(src2, "module use { requires m1; }");
+
+        Path classes2 = base.resolve("classes2");
+        tb.createDirectories(classes2);
+
+        List<String> log = new JavacTask(tb)
+            .options("--module-path", classes.toString(),
+                     "-XDrawDiagnostics")
+            .outdir(classes2)
+            .files(findJavaFiles(src2))
+            .run(Expect.FAIL)
+            .writeAll()
+            .getOutputLines(OutputKind.DIRECT);
+
+        List<String> expected = Arrays.asList(
+                "- compiler.err.cant.access: m1.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.module.name.mismatch: other, m1))",
+                "1 error");
+
+        if (!expected.equals(log)) {
+            throw new AssertionError("Unexpected output: " + log);
+        }
+    }
+
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java	Wed Jul 05 22:17:39 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8073844
+ * @summary If an error is produced by an annotation processor, the code should not be Attred, \
+ *          unless requested
+ * @modules jdk.compiler
+ * @compile StopAfterError.java
+ * @compile/fail/ref=StopAfterError.out -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
+ * @compile/fail/ref=StopAfterError.out -XDshould-stop.ifError=PROCESS -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
+ * @compile/fail/ref=StopAfterErrorContinue.out -XDshould-stop.ifError=ATTR -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
+ */
+
+import java.util.Set;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+
+@SupportedAnnotationTypes("*")
+public class StopAfterError extends AbstractProcessor {
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (roundEnv.processingOver()) {
+            processingEnv.getMessager().printMessage(Kind.ERROR, "Stop!");
+        }
+        return false;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latestSupported();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.out	Wed Jul 05 22:17:39 2017 +0200
@@ -0,0 +1,2 @@
+- compiler.err.proc.messager: Stop!
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterErrorAux.java	Wed Jul 05 22:17:39 2017 +0200
@@ -0,0 +1,6 @@
+/* /nodynamiccopyright/ */
+class StopAfterErrorAux {
+    public void test() {
+        should not; get here;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterErrorContinue.out	Wed Jul 05 22:17:39 2017 +0200
@@ -0,0 +1,4 @@
+- compiler.err.proc.messager: Stop!
+StopAfterErrorAux.java:4:9: compiler.err.cant.resolve.location: kindname.class, should, , , (compiler.misc.location: kindname.class, StopAfterErrorAux, null)
+StopAfterErrorAux.java:4:21: compiler.err.cant.resolve.location: kindname.class, get, , , (compiler.misc.location: kindname.class, StopAfterErrorAux, null)
+3 errors
--- a/langtools/test/tools/jdeps/APIDeps.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/tools/jdeps/APIDeps.java	Wed Jul 05 22:17:39 2017 +0200
@@ -135,7 +135,7 @@
                            "java.util.Set",
                            "c.C", "d.D", "c.I", "e.E", "m.Bar"},
              new String[] {"compact1", testDirBasename, mDir.getName()},
-             new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "-apionly"});
+             new String[] {"-classpath", testDir.getPath(), "-verbose", "-P", "--api-only"});
         return errors;
     }
 
--- a/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/tools/jdeps/jdkinternals/ShowReplacement.java	Wed Jul 05 22:17:39 2017 +0200
@@ -116,7 +116,7 @@
     @Test
     public void removedPackage() {
         Path file = Paths.get("q", "RemovedPackage.class");
-        String[] output = JdepsUtil.jdeps("-jdkinternals", CLASSES_DIR.resolve(file).toString());
+        String[] output = JdepsUtil.jdeps("--jdk-internals", CLASSES_DIR.resolve(file).toString());
         int i = 0;
         // expect no replacement
         while (i < output.length && !output[i].contains("Suggested Replacement")) {
--- a/langtools/test/tools/jdeps/modules/GenModuleInfo.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/tools/jdeps/modules/GenModuleInfo.java	Wed Jul 05 22:17:39 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary Tests jdeps --gen-module-info option
+ * @summary Tests jdeps --generate-module-info option
  * @library ../lib
  * @build CompilerUtils JdepsUtil
  * @modules jdk.jdeps/com.sun.tools.jdeps
@@ -106,7 +106,7 @@
                 .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                 .map(Path::toString);
 
-        JdepsUtil.jdeps(Stream.concat(Stream.of("--gen-module-info", DEST_DIR.toString()),
+        JdepsUtil.jdeps(Stream.concat(Stream.of("--generate-module-info", DEST_DIR.toString()),
                                       files).toArray(String[]::new));
 
         // check file exists
--- a/langtools/test/tools/jdeps/modules/InverseDeps.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/tools/jdeps/modules/InverseDeps.java	Wed Jul 05 22:17:39 2017 +0200
@@ -91,7 +91,7 @@
     @DataProvider(name = "testrequires")
     public Object[][] expected1() {
         return new Object[][] {
-            // -requires and result
+            // --require and result
             { "java.sql", new String[][] {
                     new String[] { "java.sql", "m5" },
                 }
@@ -117,7 +117,7 @@
 
     @Test(dataProvider = "testrequires")
     public void testrequires(String name, String[][] expected) throws Exception {
-        String cmd1 = String.format("jdeps -inverse --module-path %s -requires %s --add-modules %s%n",
+        String cmd1 = String.format("jdeps --inverse --module-path %s --require %s --add-modules %s%n",
                 MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
@@ -128,7 +128,7 @@
             runJdeps(jdeps, expected);
         }
 
-        String cmd2 = String.format("jdeps -inverse --module-path %s -requires %s" +
+        String cmd2 = String.format("jdeps --inverse --module-path %s --require %s" +
             " --add-modules ALL-MODULE-PATH%n", LIBS_DIR, name);
 
             // automatic module
@@ -164,7 +164,7 @@
 
     @Test(dataProvider = "testpackage")
     public void testpackage(String name, String[][] expected) throws Exception {
-        String cmd = String.format("jdeps -inverse --module-path %s -package %s --add-modules %s%n",
+        String cmd = String.format("jdeps --inverse --module-path %s -package %s --add-modules %s%n",
             MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
             jdeps.appModulePath(MODS_DIR.toString())
@@ -195,7 +195,7 @@
 
     @Test(dataProvider = "testregex")
     public void testregex(String name, String[][] expected) throws Exception {
-        String cmd = String.format("jdeps -inverse --module-path %s -regex %s --add-modules %s%n",
+        String cmd = String.format("jdeps --inverse --module-path %s -regex %s --add-modules %s%n",
                 MODS_DIR, name, modules.stream().collect(Collectors.joining(",")));
 
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd)) {
@@ -240,7 +240,7 @@
 
         Path jarfile = LIBS_DIR.resolve("m7.jar");
 
-        String cmd1 = String.format("jdeps -inverse -classpath %s -regex %s %s%n",
+        String cmd1 = String.format("jdeps --inverse -classpath %s -regex %s %s%n",
             cpath, name, jarfile);
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd1)) {
             jdeps.verbose("-verbose:class")
@@ -253,7 +253,7 @@
         Set<Path> paths = modules.stream()
                                  .map(mn -> LIBS_DIR.resolve(mn + ".jar"))
                                  .collect(Collectors.toSet());
-        String cmd2 = String.format("jdeps -inverse -regex %s %s%n", name, paths);
+        String cmd2 = String.format("jdeps --inverse -regex %s %s%n", name, paths);
         try (JdepsUtil.Command jdeps = JdepsUtil.newCommand(cmd2)) {
             jdeps.verbose("-verbose:class").regex(name);
             paths.forEach(jdeps::addRoot);
--- a/langtools/test/tools/jdeps/modules/src/m3/module-info.java	Wed Jul 05 22:17:29 2017 +0200
+++ b/langtools/test/tools/jdeps/modules/src/m3/module-info.java	Wed Jul 05 22:17:39 2017 +0200
@@ -24,7 +24,7 @@
 module m3 {
     requires public java.sql;
     requires public m2;
-    requires java.logging;   // TODO: --gen-module-info to do transitive reduction
+    requires java.logging;   // TODO: --generate-module-info to do transitive reduction
     requires public m1;
     exports p3;
 }