Merge
authorlana
Thu, 13 Apr 2017 16:26:29 +0000
changeset 44686 bdc14701b969
parent 44618 4ca00828fc0f (current diff)
parent 44685 8888c1a60279 (diff)
child 44687 461453f51399
Merge
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Thu Apr 13 16:26:29 2017 +0000
@@ -409,7 +409,7 @@
      * @param section set of elements
      * @return true if there are elements to be displayed
      */
-    public boolean display(SortedSet<? extends Element> section) {
+    public boolean display(Set<? extends Element> section) {
         return section != null && !section.isEmpty();
     }
 
@@ -423,6 +423,25 @@
         return section != null && !section.isEmpty();
     }
 
+    /*
+     * Returns true, in API mode, if at least one type element in
+     * the typeElements set is referenced by a javadoc tag in tagsMap.
+     */
+    private boolean displayServices(Set<TypeElement> typeElements,
+                                    Map<TypeElement, Content> tagsMap) {
+        return typeElements != null &&
+                typeElements.stream().anyMatch((v) -> displayServiceDirective(v, tagsMap));
+    }
+
+    /*
+     * Returns true, in API mode, if the type element is referenced
+     * from a javadoc tag in tagsMap.
+     */
+    private boolean displayServiceDirective(TypeElement typeElement,
+                                            Map<TypeElement, Content> tagsMap) {
+        return moduleMode == ModuleMode.ALL || tagsMap.containsKey(typeElement);
+    }
+
     /**
      * Add the summary header.
      *
@@ -768,14 +787,18 @@
      * {@inheritDoc}
      */
     public void addServicesSummary(Content summaryContentTree) {
-        if (display(uses) || display(provides)) {
+
+        boolean haveUses = displayServices(uses, usesTrees);
+        boolean haveProvides = displayServices(provides.keySet(), providesTrees);
+
+        if (haveProvides || haveUses) {
             HtmlTree li = new HtmlTree(HtmlTag.LI);
             li.addStyle(HtmlStyle.blockList);
             addSummaryHeader(HtmlConstants.START_OF_SERVICES_SUMMARY, SectionName.SERVICES,
                     contents.navServices, li);
             String text;
             String tableSummary;
-            if (display(provides)) {
+            if (haveProvides) {
                 text = configuration.getText("doclet.Provides_Summary");
                 tableSummary = configuration.getText("doclet.Member_Table_Summary",
                         configuration.getText("doclet.Provides_Summary"),
@@ -788,7 +811,7 @@
                     li.addContent(table);
                 }
             }
-            if (display(uses)) {
+            if (haveUses){
                 text = configuration.getText("doclet.Uses_Summary");
                 tableSummary = configuration.getText("doclet.Member_Table_Summary",
                         configuration.getText("doclet.Uses_Summary"),
@@ -818,17 +841,13 @@
         HtmlTree tdSummary;
         Content description;
         for (TypeElement t : uses) {
-            // For each uses directive in the module declaration, if we are in the "api" mode and
-            // if there are service types listed using @uses javadoc tag, check if the service type in
-            // the uses directive is specified using the @uses tag. If not, we do not display the
-            // service type in the "api" mode.
-            if (moduleMode == ModuleMode.API && display(usesTrees) && !usesTrees.containsKey(t)) {
+            if (!displayServiceDirective(t, usesTrees)) {
                 continue;
             }
             typeLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, t));
             thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, typeLinkContent);
             tdSummary = new HtmlTree(HtmlTag.TD);
-        tdSummary.addStyle(HtmlStyle.colLast);
+            tdSummary.addStyle(HtmlStyle.colLast);
             if (display(usesTrees)) {
                 description = usesTrees.get(t);
                 if (description != null) {
@@ -837,9 +856,9 @@
             }
             addSummaryComment(t, tdSummary);
             HtmlTree tr = HtmlTree.TR(thType);
-        tr.addContent(tdSummary);
-        tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
-        tbody.addContent(tr);
+            tr.addContent(tdSummary);
+            tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
+            tbody.addContent(tr);
             altColor = !altColor;
         }
     }
@@ -851,18 +870,13 @@
      */
     public void addProvidesList(Content tbody) {
         boolean altColor = true;
-        TypeElement srv;
         SortedSet<TypeElement> implSet;
         Content description;
         for (Map.Entry<TypeElement, SortedSet<TypeElement>> entry : provides.entrySet()) {
-            srv = entry.getKey();
-            // For each provides directive in the module declaration, if we are in the "api" mode and
-            // if there are service types listed using @provides javadoc tag, check if the service type in
-            // the provides directive is specified using the @provides tag. If not, we do not display the
-            // service type in the "api" mode.
-            if (moduleMode == ModuleMode.API && display(providesTrees) && !providesTrees.containsKey(srv)) {
+            TypeElement srv = entry.getKey();
+            if (!displayServiceDirective(srv, providesTrees)) {
                 continue;
-    }
+            }
             implSet = entry.getValue();
             Content srvLinkContent = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.PACKAGE, srv));
             HtmlTree thType = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, srvLinkContent);
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Thu Apr 13 16:26:29 2017 +0000
@@ -267,7 +267,17 @@
     // compiler/runtime init option values
     private static class Options {
 
-        private Map<OptionKind, List<String>> optMap = new HashMap<>();
+        private final Map<OptionKind, List<String>> optMap;
+
+        // New blank Options
+        Options() {
+            optMap = new HashMap<>();
+        }
+
+        // Options as a copy
+        private Options(Options opts) {
+            optMap = new HashMap<>(opts.optMap);
+        }
 
         private String[] selectOptions(Predicate<Entry<OptionKind, List<String>>> pred) {
             return optMap.entrySet().stream()
@@ -293,17 +303,20 @@
                     .addAll(vals);
         }
 
-        void override(Options newer) {
+        // return a new Options, with parameter options overriding receiver options
+        Options override(Options newer) {
+            Options result = new Options(this);
             newer.optMap.entrySet().stream()
                     .forEach(e -> {
                         if (e.getKey().onlyOne) {
                             // Only one allowed, override last
-                            optMap.put(e.getKey(), e.getValue());
+                            result.optMap.put(e.getKey(), e.getValue());
                         } else {
                             // Additive
-                            addAll(e.getKey(), e.getValue());
+                            result.addAll(e.getKey(), e.getValue());
                         }
                     });
+            return result;
         }
     }
 
@@ -874,7 +887,14 @@
         // initialize editor settings
         configEditor();
         // initialize JShell instance
-        resetState();
+        try {
+            resetState();
+        } catch (IllegalStateException ex) {
+            // Display just the cause (not a exception backtrace)
+            cmderr.println(ex.getMessage());
+            //abort
+            return;
+        }
         // Read replay history from last jshell session into previous history
         replayableHistoryPrevious = ReplayableHistory.fromPrevious(prefs);
         // load snippet/command files given on command-line
@@ -2570,15 +2590,17 @@
     }
 
     private boolean cmdReset(String rawargs) {
+        Options oldOptions = rawargs.trim().isEmpty()? null : options;
         if (!parseCommandLineLikeFlags(rawargs, new OptionParserBase())) {
             return false;
         }
         live = false;
         fluffmsg("jshell.msg.resetting.state");
-        return true;
+        return doReload(null, false, oldOptions);
     }
 
     private boolean cmdReload(String rawargs) {
+        Options oldOptions = rawargs.trim().isEmpty()? null : options;
         OptionParserReload ap = new OptionParserReload();
         if (!parseCommandLineLikeFlags(rawargs, ap)) {
             return false;
@@ -2595,7 +2617,7 @@
             history = replayableHistory;
             fluffmsg("jshell.err.reload.restarting.state");
         }
-        boolean success = doReload(history, !ap.quiet());
+        boolean success = doReload(history, !ap.quiet(), oldOptions);
         if (success && ap.restore()) {
             // if we are restoring from previous, then if nothing was added
             // before time of exit, there is nothing to save
@@ -2622,17 +2644,32 @@
             }
             return false;
         }
+        Options oldOptions = options;
         if (!parseCommandLineLikeFlags(rawargs, new OptionParserBase())) {
             return false;
         }
         fluffmsg("jshell.msg.set.restore");
-        return doReload(replayableHistory, false);
+        return doReload(replayableHistory, false, oldOptions);
     }
 
-    private boolean doReload(ReplayableHistory history, boolean echo) {
-        resetState();
-        run(new ReloadIOContext(history.iterable(),
-                echo ? cmdout : null));
+    private boolean doReload(ReplayableHistory history, boolean echo, Options oldOptions) {
+        if (oldOptions != null) {
+            try {
+                resetState();
+            } catch (IllegalStateException ex) {
+                currentNameSpace = mainNamespace; // back out of start-up (messages)
+                errormsg("jshell.err.restart.failed", ex.getMessage());
+                // attempt recovery to previous option settings
+                options = oldOptions;
+                resetState();
+            }
+        } else {
+            resetState();
+        }
+        if (history != null) {
+            run(new ReloadIOContext(history.iterable(),
+                    echo ? cmdout : null));
+        }
         return true;
     }
 
@@ -2648,7 +2685,7 @@
             errormsg("jshell.err.unexpected.at.end", ap.nonOptions(), rawargs);
             return false;
         }
-        options.override(opts);
+        options = options.override(opts);
         return true;
     }
 
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Thu Apr 13 16:26:29 2017 +0000
@@ -77,6 +77,9 @@
 jshell.err.reload.restarting.previous.state = Restarting and restoring from previous state.
 jshell.err.reload.restarting.state = Restarting and restoring state.
 
+jshell.err.restart.failed = Restart failed: {0}\n\n\
+Reverting to previous settings and restarting...
+
 jshell.msg.vars.not.active = (not-active)
 
 jshell.err.out.of.range = Out of range
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/FailOverExecutionControlProvider.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/FailOverExecutionControlProvider.java	Thu Apr 13 16:26:29 2017 +0000
@@ -133,7 +133,10 @@
     private Logger logger() {
         if (logger == null) {
             logger = Logger.getLogger("jdk.jshell.execution");
-            logger.setLevel(Level.ALL);
+            if (logger.getLevel() == null) {
+                // Logging has not been specifically requested, turn it off
+                logger.setLevel(Level.OFF);
+            }
         }
         return logger;
     }
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java	Thu Apr 13 16:26:29 2017 +0000
@@ -26,6 +26,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -146,6 +148,9 @@
      */
     private VirtualMachine listenTarget(int port, List<String> remoteVMOptions) {
         ListeningConnector listener = (ListeningConnector) connector;
+        // Files to collection to output of a start-up failure
+        File crashErrorFile = createTempFile("error");
+        File crashOutputFile = createTempFile("output");
         try {
             // Start listening, get the JDI connection address
             String addr = listener.startListening(connectorArgs);
@@ -163,23 +168,57 @@
             args.add(remoteAgent);
             args.add("" + port);
             ProcessBuilder pb = new ProcessBuilder(args);
+            pb.redirectError(crashErrorFile);
+            pb.redirectOutput(crashOutputFile);
             process = pb.start();
 
             // Accept the connection from the remote agent
             vm = timedVirtualMachineCreation(() -> listener.accept(connectorArgs),
                     () -> process.waitFor());
+            try {
+                listener.stopListening(connectorArgs);
+            } catch (IOException | IllegalConnectorArgumentsException ex) {
+                // ignore
+            }
+            crashErrorFile.delete();
+            crashOutputFile.delete();
             return vm;
         } catch (Throwable ex) {
             if (process != null) {
                 process.destroyForcibly();
             }
-            throw reportLaunchFail(ex, "listen");
-        } finally {
             try {
                 listener.stopListening(connectorArgs);
-            } catch (IOException | IllegalConnectorArgumentsException ex) {
+            } catch (IOException | IllegalConnectorArgumentsException iex) {
                 // ignore
             }
+            String text = readFile(crashErrorFile) + readFile(crashOutputFile);
+            crashErrorFile.delete();
+            crashOutputFile.delete();
+            if (text.isEmpty()) {
+                throw reportLaunchFail(ex, "listen");
+            } else {
+                throw new IllegalArgumentException(text);
+            }
+        }
+    }
+
+    private File createTempFile(String label) {
+        try {
+            File f = File.createTempFile("remote", label);
+            f.deleteOnExit();
+            return f;
+        } catch (IOException ex) {
+            throw new InternalError("Failed create temp ", ex);
+        }
+    }
+
+    private String readFile(File f) {
+        try {
+            return new String(Files.readAllBytes(f.toPath()),
+                    StandardCharsets.UTF_8);
+        } catch (IOException ex) {
+            return "error reading " + f + " : " + ex.toString();
         }
     }
 
--- a/langtools/test/ProblemList.txt	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/ProblemList.txt	Thu Apr 13 16:26:29 2017 +0000
@@ -55,6 +55,7 @@
 tools/javac/warnings/suppress/TypeAnnotations.java                              8057683    generic-all    improve ordering of errors with type annotations
 tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java     8160396    generic-all    current version of jtreg needs a new promotion to include lastes version of ASM
 tools/javac/platform/PlatformProviderTest.java                                  8176801    generic-all    fails due to warnings printed to stderr
+tools/javac/lambda/speculative/T8177933.java                                    8178437    generic-all    intermittently fails due to stack randomization
 
 ###########################################################################
 #
--- a/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/lib/JavadocTester.java	Thu Apr 13 16:26:29 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.function.Function;
 
 
 /**
@@ -237,12 +238,23 @@
      * @throws Exception if any errors occurred
      */
     public void runTests() throws Exception {
+        runTests(m -> new Object[0]);
+    }
+
+    /**
+     * Run all methods annotated with @Test, followed by printSummary.
+     * Typically called on a tester object in main()
+     * @param f a function which will be used to provide arguments to each
+     *          invoked method
+     * @throws Exception if any errors occurred
+     */
+    public void runTests(Function<Method, Object[]> f) throws Exception {
         for (Method m: getClass().getDeclaredMethods()) {
             Annotation a = m.getAnnotation(Test.class);
             if (a != null) {
                 try {
                     out.println("Running test " + m.getName());
-                    m.invoke(this, new Object[] { });
+                    m.invoke(this, f.apply(m));
                 } catch (InvocationTargetException e) {
                     Throwable cause = e.getCause();
                     throw (cause instanceof Exception) ? ((Exception) cause) : e;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModuleServices.java	Thu Apr 13 16:26:29 2017 +0000
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2017, 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 8178067
+ * @summary tests the module's services, such as provides and uses
+ * @modules jdk.javadoc/jdk.javadoc.internal.api
+ *          jdk.javadoc/jdk.javadoc.internal.tool
+ *          jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @library ../lib /tools/lib
+ * @build toolbox.ToolBox toolbox.ModuleBuilder JavadocTester
+ * @run main TestModuleServices
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.*;
+
+public class TestModuleServices extends JavadocTester {
+
+    public final ToolBox tb;
+    public static void main(String... args) throws Exception {
+        TestModuleServices tester = new TestModuleServices();
+        tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
+    }
+
+    public TestModuleServices() {
+        tb = new ToolBox();
+    }
+
+    @Test
+    public void checkUsesNoApiTagModuleModeDefault(Path base) throws Exception {
+        ModuleBuilder mb = new ModuleBuilder(tb, "m")
+                .comment("module m.\n@provides p1.A abc") // bogus tag
+                .uses("p1.A")
+                .uses("p1.B")
+                .exports("p1")
+                .classes("package p1; public class A {}")
+                .classes("package p1; public class B {}");
+                mb.write(base);
+
+        javadoc("-d", base.toString() + "/out",
+                "-quiet",
+                "--module-source-path", base.toString(),
+                "--module", "m");
+        checkExit(Exit.OK);
+
+        checkOutput("m-summary.html", false,
+                "<h3>Services</h3>");
+    }
+
+    @Test
+    public void checkUsesNoApiTagModuleModeAll(Path base) throws Exception {
+        ModuleBuilder mb = new ModuleBuilder(tb, "m")
+                .uses("p1.A")
+                .uses("p1.B")
+                .exports("p1")
+                .classes("package p1; public class A {}")
+                .classes("package p1; public class B {}");
+        mb.write(base);
+
+        javadoc("-d", base.toString() + "/out",
+                "-quiet",
+                "--show-module-contents", "all",
+                "--module-source-path", base.toString(),
+                "--module", "m");
+        checkExit(Exit.OK);
+
+        checkOutput("m-summary.html", true,
+                "<h3>Services</h3>");
+
+        checkOutput("m-summary.html", true,
+                "<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
+                "<caption><span>Uses</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
+                "<tr>\n" +
+                "<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
+                "<th class=\"colLast\" scope=\"col\">Description</th>\n" +
+                "</tr>\n" +
+                "<tbody>\n" +
+                "<tr class=\"altColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"class in p1\">A</a></th>\n" +
+                "<td class=\"colLast\">&nbsp;</td>\n" +
+                "</tr>\n" +
+                "<tr class=\"rowColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p1/B.html\" title=\"class in p1\">B</a></th>\n" +
+                "<td class=\"colLast\">&nbsp;</td>\n" +
+                "</tr>\n" +
+                "</tbody>\n" +
+                "</table>\n");
+    }
+
+    @Test
+    public void checkUsesWithApiTagModuleModeDefault(Path base) throws Exception {
+        ModuleBuilder mb = new ModuleBuilder(tb, "m")
+                .comment("module m.\n@uses p1.A")
+                .uses("p1.A")
+                .uses("p1.B")
+                .exports("p1")
+                .classes("package p1; public class A {}")
+                .classes("package p1; public class B {}");
+        mb.write(base);
+
+        javadoc("-d", base.toString() + "/out",
+                "-quiet",
+                "--module-source-path", base.toString(),
+                "--module", "m");
+        checkExit(Exit.OK);
+
+        checkOutput("m-summary.html", true,
+                "<h3>Services</h3>");
+
+        checkOutput("m-summary.html", true,
+                "<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
+                "<caption><span>Uses</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
+                "<tr>\n" +
+                "<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
+                "<th class=\"colLast\" scope=\"col\">Description</th>\n" +
+                "</tr>\n" +
+                "<tbody>\n" +
+                "<tr class=\"altColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"class in p1\">A</a></th>\n" +
+                "<td class=\"colLast\">&nbsp;</td>\n" +
+                "</tr>\n" +
+                "</tbody>\n" +
+                "</table>\n");
+    }
+
+    @Test
+    public void checkProvidesNoApiTagModuleModeDefault(Path base) throws Exception {
+        ModuleBuilder mb = new ModuleBuilder(tb, "m")
+                .comment("module m.\n@uses p1.A")
+                .provides("p1.A", "p1.B")
+                .exports("p1")
+                .classes("package p1; public interface A {}")
+                .classes("package p1; public class B implements A {}")
+                .provides("p2.A", "p2.B")
+                .exports("p2")
+                .classes("package p2; public interface A {}")
+                .classes("package p2; public class B implements A {}");
+        mb.write(base);
+
+        javadoc("-d", base.toString() + "/out",
+                "-quiet",
+                "--module-source-path", base.toString(),
+                "--module", "m");
+
+        checkExit(Exit.OK);
+
+        checkOutput("m-summary.html", false,
+                "<h3>Services</h3>");
+    }
+
+    @Test
+    public void checkProvidesNoApiTagModuleModeAll(Path base) throws Exception {
+        ModuleBuilder mb = new ModuleBuilder(tb, "m")
+                .comment("module m.\n@uses p1.A") // bogus uses tag
+                .provides("p1.A", "p1.B")
+                .exports("p1")
+                .classes("package p1; public interface A {}")
+                .classes("package p1; public class B implements A {}")
+                .provides("p2.A", "p2.B")
+                .exports("p2")
+                .classes("package p2; public interface A {}")
+                .classes("package p2; public class B implements A {}");
+        mb.write(base);
+
+        javadoc("-d", base.toString() + "/out",
+                "-quiet",
+                "--show-module-contents", "all",
+                "--module-source-path", base.toString(),
+                "--module", "m");
+
+        checkExit(Exit.OK);
+
+        checkOutput("m-summary.html", true,
+                "<h3>Services</h3>");
+
+        checkOutput("m-summary.html", true,
+                "<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
+                "<caption><span>Provides</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
+                "<tr>\n" +
+                "<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
+                "<th class=\"colLast\" scope=\"col\">Description</th>\n" +
+                "</tr>\n" +
+                "<tbody>\n" +
+                "<tr class=\"altColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"interface in p1\">A</a></th>\n" +
+                "<td class=\"colLast\">&nbsp;<br>(<span class=\"implementationLabel\">Implementation(s):</span>&nbsp;<a href=\"p1/B.html\" title=\"class in p1\">B</a>)</td>\n" +
+                "</tr>\n" +
+                "<tr class=\"rowColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p2/A.html\" title=\"interface in p2\">A</a></th>\n" +
+                "<td class=\"colLast\">&nbsp;<br>(<span class=\"implementationLabel\">Implementation(s):</span>&nbsp;<a href=\"p2/B.html\" title=\"class in p2\">B</a>)</td>\n" +
+                "</tr>\n" +
+                "</tbody>\n");
+    }
+
+    @Test
+    public void checkProvidesWithApiTagModuleModeDefault(Path base) throws Exception {
+        ModuleBuilder mb = new ModuleBuilder(tb, "m")
+                .comment("module m.\n@provides p1.A abc")
+                .provides("p1.A", "p1.B")
+                .exports("p1")
+                .classes("package p1; public interface A {}")
+                .classes("package p1; public class B implements A {}")
+                .provides("p2.A", "p2.B")
+                .exports("p2")
+                .classes("package p2; public interface A {}")
+                .classes("package p2; public class B implements A {}");
+        mb.write(base);
+
+        javadoc("-d", base.toString() + "/out",
+                "-quiet",
+                "--module-source-path", base.toString(),
+                "--module", "m");
+
+        checkExit(Exit.OK);
+
+        checkOutput("m-summary.html", true,
+                "<h3>Services</h3>");
+
+        checkOutput("m-summary.html", true,
+                "<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
+                "<caption><span>Provides</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
+                "<tr>\n" +
+                "<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
+                "<th class=\"colLast\" scope=\"col\">Description</th>\n" +
+                "</tr>\n" +
+                "<tbody>\n" +
+                "<tr class=\"altColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"interface in p1\">A</a></th>\n" +
+                "<td class=\"colLast\">abc&nbsp;</td>\n" +
+                "</tr>\n" +
+                "</tbody>\n" +
+                "</table>\n");
+    }
+
+    @Test
+    public void checkUsesProvidesWithApiTagsModeDefault(Path base) throws Exception {
+        ModuleBuilder mb = new ModuleBuilder(tb, "m")
+                .comment("module m.\n@provides p1.A abc\n@uses p2.B def")
+                .provides("p1.A", "p1.B")
+                .exports("p1")
+                .classes("package p1; public interface A {}")
+                .classes("package p1; public class B implements A {}")
+                .provides("p2.A", "p2.B")
+                .uses("p2.B")
+                .exports("p2")
+                .classes("package p2; public interface A {}")
+                .classes("package p2; public class B implements A {}");
+        mb.write(base);
+
+        javadoc("-d", base.toString() + "/out",
+                "-quiet",
+                "--module-source-path", base.toString(),
+                "--module", "m");
+
+        checkExit(Exit.OK);
+
+        checkOutput("m-summary.html", true,
+                "<h3>Services</h3>");
+
+        checkOutput("m-summary.html", true,
+                "<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
+                "<caption><span>Provides</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
+                "<tr>\n" +
+                "<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
+                "<th class=\"colLast\" scope=\"col\">Description</th>\n" +
+                "</tr>\n" +
+                "<tbody>\n" +
+                "<tr class=\"altColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"interface in p1\">A</a></th>\n" +
+                "<td class=\"colLast\">abc&nbsp;</td>\n" +
+                "</tr>\n" +
+                "</tbody>\n" +
+                "</table>",
+                "<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
+                "<caption><span>Uses</span><span class=\"tabEnd\">&nbsp;</span></caption>\n" +
+                "<tr>\n" +
+                "<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
+                "<th class=\"colLast\" scope=\"col\">Description</th>\n" +
+                "</tr>\n" +
+                "<tbody>\n" +
+                "<tr class=\"altColor\">\n" +
+                "<th class=\"colFirst\" scope=\"row\"><a href=\"p2/B.html\" title=\"class in p2\">B</a></th>\n" +
+                "<td class=\"colLast\">def&nbsp;</td>\n" +
+                "</tr>\n" +
+                "</tbody>\n" +
+                "</table>\n");
+    }
+
+}
--- a/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/javadoc/doclet/testModules/TestModules.java	Thu Apr 13 16:26:29 2017 +0000
@@ -591,10 +591,6 @@
                 + "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkgmdlB/TestClassInModuleB.html\" title=\"class in testpkgmdlB\">TestClassInModuleB</a></th>\n"
                 + "<td class=\"colLast\">With a test description for uses.&nbsp;</td>\n"
                 + "</tr>",
-                "<tr class=\"altColor\">\n"
-                + "<th class=\"colFirst\" scope=\"row\"><a href=\"testpkg2mdlB/TestInterface2InModuleB.html\" title=\"interface in testpkg2mdlB\">TestInterface2InModuleB</a></th>\n"
-                + "<td class=\"colLast\">&nbsp;</td>\n"
-                + "</tr>",
                 "<caption><span>Opens</span><span class=\"tabEnd\">&nbsp;</span></caption>\n"
                 + "<tr>\n"
                 + "<th class=\"colFirst\" scope=\"col\">Package</th>\n"
--- a/langtools/test/jdk/jshell/DyingRemoteAgent.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/DyingRemoteAgent.java	Thu Apr 13 16:26:29 2017 +0000
@@ -22,6 +22,8 @@
  */
 
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import jdk.jshell.JShell;
 import jdk.jshell.execution.JdiExecutionControlProvider;
 import jdk.jshell.execution.RemoteExecutionControl;
@@ -45,6 +47,8 @@
         pm.put(JdiExecutionControlProvider.PARAM_REMOTE_AGENT, DyingRemoteAgent.class.getName());
         pm.put(JdiExecutionControlProvider.PARAM_HOST_NAME, host==null? "" : host);
         pm.put(JdiExecutionControlProvider.PARAM_LAUNCH, ""+isLaunch);
+        // turn on logging of launch failures
+        Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
         return JShell.builder()
                 .executionEngine(ecp, pm)
                 .build();
--- a/langtools/test/jdk/jshell/HangingRemoteAgent.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/HangingRemoteAgent.java	Thu Apr 13 16:26:29 2017 +0000
@@ -22,6 +22,8 @@
  */
 
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import jdk.jshell.JShell;
 import jdk.jshell.execution.JdiExecutionControlProvider;
 import jdk.jshell.execution.RemoteExecutionControl;
@@ -59,6 +61,8 @@
         pm.put(JdiExecutionControlProvider.PARAM_HOST_NAME, host==null? "" : host);
         pm.put(JdiExecutionControlProvider.PARAM_LAUNCH, ""+isLaunch);
         pm.put(JdiExecutionControlProvider.PARAM_TIMEOUT, ""+TIMEOUT);
+        // turn on logging of launch failures
+        Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
         return JShell.builder()
                 .executionEngine(ecp, pm)
                 .build();
--- a/langtools/test/jdk/jshell/HistoryTest.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/HistoryTest.java	Thu Apr 13 16:26:29 2017 +0000
@@ -33,6 +33,8 @@
 
 import java.lang.reflect.Field;
 import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import jdk.internal.jline.extra.EditingHistory;
 import org.testng.annotations.Test;
 import jdk.internal.jshell.tool.JShellTool;
@@ -45,6 +47,8 @@
 
     @Override
     protected void testRawRun(Locale locale, String[] args) {
+        // turn on logging of launch failures
+        Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
         repl = ((JShellToolBuilder) builder(locale))
                 .rawTool();
         try {
--- a/langtools/test/jdk/jshell/JdiBadOptionLaunchExecutionControlTest.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/JdiBadOptionLaunchExecutionControlTest.java	Thu Apr 13 16:26:29 2017 +0000
@@ -29,6 +29,8 @@
  * @run testng JdiBadOptionLaunchExecutionControlTest
  */
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.testng.annotations.Test;
 import jdk.jshell.JShell;
 import static org.testng.Assert.assertTrue;
@@ -42,6 +44,8 @@
 
     public void badOptionLaunchTest() {
         try {
+            // turn on logging of launch failures
+            Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
             JShell.builder()
                     .executionEngine("jdi:launch(true)")
                     .remoteVMOptions("-BadBadOption")
--- a/langtools/test/jdk/jshell/JdiBadOptionListenExecutionControlTest.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/JdiBadOptionListenExecutionControlTest.java	Thu Apr 13 16:26:29 2017 +0000
@@ -29,6 +29,8 @@
  * @run testng JdiBadOptionListenExecutionControlTest
  */
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.testng.annotations.Test;
 import jdk.jshell.JShell;
 import static org.testng.Assert.assertTrue;
@@ -38,16 +40,18 @@
 public class JdiBadOptionListenExecutionControlTest {
 
     private static final String EXPECTED_ERROR =
-            "Launching JShell execution engine threw: Failed remote listen:";
+            "Unrecognized option: -BadBadOption";
 
     public void badOptionListenTest() {
         try {
+            // turn on logging of launch failures
+            Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
             JShell.builder()
                     .executionEngine("jdi")
                     .remoteVMOptions("-BadBadOption")
                     .build();
         } catch (IllegalStateException ex) {
-            assertTrue(ex.getMessage().startsWith(EXPECTED_ERROR), ex.getMessage());
+            assertTrue(ex.getMessage().contains(EXPECTED_ERROR), ex.getMessage());
             return;
         }
         fail("Expected IllegalStateException");
--- a/langtools/test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/JdiBogusHostListenExecutionControlTest.java	Thu Apr 13 16:26:29 2017 +0000
@@ -29,6 +29,8 @@
  * @run testng JdiBogusHostListenExecutionControlTest
  */
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.testng.annotations.Test;
 import jdk.jshell.JShell;
 import static org.testng.Assert.assertTrue;
@@ -42,6 +44,8 @@
 
     public void badOptionListenTest() {
         try {
+            // turn on logging of launch failures
+            Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
             JShell.builder()
                     .executionEngine("jdi:hostname(BattyRumbleBuckets-Snurfle-99-Blip)")
                     .build();
--- a/langtools/test/jdk/jshell/ReplToolTesting.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/ReplToolTesting.java	Thu Apr 13 16:26:29 2017 +0000
@@ -34,6 +34,8 @@
 import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import java.util.prefs.AbstractPreferences;
 import java.util.prefs.BackingStoreException;
 import java.util.regex.Matcher;
@@ -265,6 +267,8 @@
     }
 
     protected JavaShellToolBuilder builder(Locale locale) {
+        // turn on logging of launch failures
+        Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
         return JavaShellToolBuilder
                     .builder()
                     .in(cmdin, userin)
--- a/langtools/test/jdk/jshell/StartOptionTest.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/StartOptionTest.java	Thu Apr 13 16:26:29 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -22,7 +22,7 @@
  */
 
 /*
- * @test 8151754 8080883 8160089 8170162 8166581 8172102 8171343
+ * @test 8151754 8080883 8160089 8170162 8166581 8172102 8171343 8178023
  * @summary Testing start-up options.
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -43,6 +43,8 @@
 import java.util.Locale;
 import java.util.function.Consumer;
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -63,6 +65,8 @@
     private InputStream cmdInStream;
 
     private JavaShellToolBuilder builder() {
+        // turn on logging of launch failures
+        Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
         return JavaShellToolBuilder
                     .builder()
                     .out(new PrintStream(cmdout), new PrintStream(console), new PrintStream(userout))
@@ -179,14 +183,11 @@
     }
 
     public void testStartupFailedOption() throws Exception {
-        try {
-            builder().run("-R-hoge-foo-bar");
-        } catch (IllegalStateException ex) {
-            String s = ex.getMessage();
-            assertTrue(s.startsWith("Launching JShell execution engine threw: Failed remote"), s);
-            return;
-        }
-        fail("Expected IllegalStateException");
+        start(
+                s -> assertEquals(s.trim(), "", "cmdout: "),
+                s -> assertEquals(s.trim(), "", "userout: "),
+                s -> assertTrue(s.contains("Unrecognized option: -hoge-foo-bar"), "cmderr: " + s),
+                "-R-hoge-foo-bar");
     }
 
     public void testStartupUnknown() throws Exception {
@@ -201,6 +202,14 @@
         }
     }
 
+    public void testUnknownModule() throws Exception {
+        start(
+                s -> assertEquals(s.trim(), "", "cmdout: "),
+                s -> assertEquals(s.trim(), "", "userout: "),
+                s -> assertTrue(s.contains("rror") && s.contains("unKnown"), "cmderr: " + s),
+                "--add-modules", "unKnown");
+    }
+
     public void testFeedbackOptionConflict() throws Exception {
         start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.",
                 "--feedback", "concise", "--feedback", "verbose");
--- a/langtools/test/jdk/jshell/ToolProviderTest.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/ToolProviderTest.java	Thu Apr 13 16:26:29 2017 +0000
@@ -87,15 +87,6 @@
     }
 
     @Override
-    public void testStartupFailedOption() throws Exception {
-        if (runShellServiceLoader("-R-hoge-foo-bar") == 0) {
-            fail("Expected tool failure");
-        } else {
-            check(cmderr, s -> s.startsWith("Launching JShell execution engine threw: Failed remote"), "cmderr");
-        }
-    }
-
-    @Override
     public void testShowVersion() throws Exception {
         start(
                 s -> {
--- a/langtools/test/jdk/jshell/ToolReloadTest.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/ToolReloadTest.java	Thu Apr 13 16:26:29 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /*
  * @test
  * @key intermittent
- * @bug 8081845 8147898 8143955  8165405
+ * @bug 8081845 8147898 8143955  8165405 8178023
  * @summary Tests for /reload in JShell tool
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -40,6 +40,7 @@
 import java.util.function.Function;
 
 import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
 
 
 @Test
@@ -199,6 +200,27 @@
         );
     }
 
+    public void testEnvBadModule() {
+        test(
+                (a) -> assertVariable(a, "int", "x", "5", "5"),
+                (a) -> assertMethod(a, "int m(int z) { return z * z; }",
+                        "(int)int", "m"),
+                (a) -> assertCommandCheckOutput(a, "/env --add-module unKnown",
+                        s -> {
+                            assertTrue(s.startsWith(
+                                "|  Setting new options and restoring state.\n" +
+                                "|  Restart failed:"));
+                            assertTrue(s.contains("unKnown"),
+                                    "\"unKnown\" missing from: " + s);
+                            assertTrue(s.contains("previous settings"),
+                                    "\"previous settings\" missing from: " + s);
+                                      }),
+                (a) -> evaluateExpression(a, "int", "m(x)", "25"),
+                (a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
+                (a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
+        );
+    }
+
     public void testReloadExitRestore() {
         test(false, new String[]{"--no-startup"},
                 (a) -> assertVariable(a, "int", "x", "5", "5"),
--- a/langtools/test/jdk/jshell/UITesting.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/jdk/jshell/UITesting.java	Thu Apr 13 16:26:29 2017 +0000
@@ -29,6 +29,8 @@
 import java.io.Writer;
 import java.util.HashMap;
 import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -37,6 +39,9 @@
 public class UITesting {
 
     protected void doRunTest(Test test) throws Exception {
+        // turn on logging of launch failures
+        Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL);
+
         PipeInputStream input = new PipeInputStream();
         StringBuilder out = new StringBuilder();
         PrintStream outS = new PrintStream(new OutputStream() {
--- a/langtools/test/tools/lib/toolbox/ModuleBuilder.java	Thu Apr 13 16:01:14 2017 +0000
+++ b/langtools/test/tools/lib/toolbox/ModuleBuilder.java	Thu Apr 13 16:26:29 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -247,7 +247,9 @@
         List<String> sources = new ArrayList<>();
         StringBuilder sb = new StringBuilder();
         if (!comment.isEmpty()) {
-            sb.append("/**\n").append(comment.replace("\n", " *")).append(" */\n");
+            sb.append("/**\n * ")
+                    .append(comment.replace("\n", "\n * "))
+                    .append("\n */\n");
         }
         sb.append("module ").append(name).append(" {\n");
         requires.forEach(r -> sb.append("    " + r + "\n"));