changeset 4966:e2475ff79b59

Merge
author alanb
date Mon, 26 Jun 2017 07:49:55 +0100
parents 3938af370ffd 141a3c187e1a
children 1dce953430d8
files .hgtags src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java src/java.compiler/share/classes/module-info.java src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java src/jdk.compiler/share/classes/module-info.java src/jdk.javadoc/share/classes/module-info.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java src/jdk.jdeps/share/classes/module-info.java src/jdk.jshell/share/classes/module-info.java test/tools/javac/modules/EdgeCases.java test/tools/javac/modules/LegacyXModuleTest.java
diffstat 18 files changed, 244 insertions(+), 157 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sat Jun 17 15:33:14 2017 +0100
+++ b/.hgtags	Mon Jun 26 07:49:55 2017 +0100
@@ -420,3 +420,4 @@
 03669efa77f51852f5301623cad4a2e1bb4fb9f6 jdk-9+172
 123eb0956a459bca29d0812c62fca50da563ee40 jdk-9+173
 50c077995aa249890ece698a2a2db4c4fba90e10 jdk-9+174
+83f6eb009d8f6e94fd348c7d23e4b00754d745db jdk-9+175
--- a/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/java.compiler/share/classes/javax/lang/model/element/ModuleElement.java	Mon Jun 26 07:49:55 2017 +0100
@@ -42,8 +42,16 @@
      * Returns the fully qualified name of this module.  For an
      * {@linkplain #isUnnamed() unnamed module}, an empty name is returned.
      *
+     * @apiNote If the module name consists of one identifier, then
+     * this method returns that identifier, which is deemed to be
+     * module's fully qualified name despite not being in qualified
+     * form.  If the module name consists of more than one identifier,
+     * then this method returns the entire name.
+     *
      * @return the fully qualified name of this module, or an
      * empty name if this is an unnamed module
+     *
+     * @jls 6.2 Names and Identifiers
      */
     @Override
     Name getQualifiedName();
@@ -52,8 +60,16 @@
      * Returns the simple name of this module.  For an {@linkplain
      * #isUnnamed() unnamed module}, an empty name is returned.
      *
+     * @apiNote If the module name consists of one identifier, then
+     * this method returns that identifier.  If the module name
+     * consists of more than one identifier, then this method returns
+     * the rightmost such identifier, which is deemed to be the
+     * module's simple name.
+     *
      * @return the simple name of this module or an empty name if
      * this is an unnamed module
+     *
+     * @jls 6.2 Names and Identifiers
      */
     @Override
     Name getSimpleName();
--- a/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/java.compiler/share/classes/javax/lang/model/element/PackageElement.java	Mon Jun 26 07:49:55 2017 +0100
@@ -44,6 +44,13 @@
      * This is also known as the package's <i>canonical</i> name.
      * For an {@linkplain #isUnnamed() unnamed package}, an empty name is returned.
      *
+     * @apiNote The fully qualified name of a named package that is
+     * not a subpackage of a named package is its simple name. The
+     * fully qualified name of a named package that is a subpackage of
+     * another named package consists of the fully qualified name of
+     * the containing package, followed by "{@code .}", followed by the simple
+     * (member) name of the subpackage.
+     *
      * @return the fully qualified name of this package, or an
      * empty name if this is an unnamed package
      * @jls 6.7 Fully Qualified Names and Canonical Names
--- a/src/java.compiler/share/classes/module-info.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/java.compiler/share/classes/module-info.java	Mon Jun 26 07:49:55 2017 +0100
@@ -23,16 +23,18 @@
  * questions.
  */
 
- /**
-  * Defines the Language Model, Annotation Processing, and Java Compiler APIs.
-  * <P>
-  * These APIs model declarations and types of the Java programming language,
-  * and define interfaces for tools such as compilers which can be invoked
-  * from a program.
-  *
-  * @moduleGraph
-  * @since 9
-  */
+/**
+ * Defines the Language Model, Annotation Processing, and Java Compiler APIs.
+ * <p>
+ * These APIs model declarations and types of the Java programming language,
+ * and define interfaces for tools such as compilers which can be invoked
+ * from a program.
+ * <p>
+ * This module is upgradeble.
+ *
+ * @moduleGraph
+ * @since 9
+ */
 module java.compiler {
     exports javax.annotation.processing;
     exports javax.lang.model;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Jun 26 07:49:55 2017 +0100
@@ -950,6 +950,17 @@
         }
 
         @Override @DefinedBy(Api.LANGUAGE_MODEL)
+        public Name getSimpleName() {
+            Name fullName = getQualifiedName();
+            int lastPeriod = fullName.lastIndexOf((byte)'.');
+            if (lastPeriod == -1) {
+                return fullName;
+            } else {
+                return fullName.subName(lastPeriod + 1, fullName.length());
+            }
+        }
+
+        @Override @DefinedBy(Api.LANGUAGE_MODEL)
         public boolean isOpen() {
             return flags.contains(ModuleFlags.OPEN);
         }
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Mon Jun 26 07:49:55 2017 +0100
@@ -146,8 +146,6 @@
 
     public final boolean multiModuleMode;
 
-    private final String legacyModuleOverride;
-
     private final Name java_se;
     private final Name java_;
 
@@ -196,14 +194,6 @@
         allowAccessIntoSystem = options.isUnset(Option.RELEASE);
         lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);
 
-        Collection<String> xmodules = options.keySet()
-                                             .stream()
-                                             .filter(opt -> opt.startsWith(XMODULES_PREFIX))
-                                             .map(opt -> opt.substring(XMODULES_PREFIX.length()))
-                                             .collect(Collectors.toList());
-
-        legacyModuleOverride = xmodules.size() == 1 ? xmodules.iterator().next() : null;
-
         multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH);
         ClassWriter classWriter = ClassWriter.instance(context);
         classWriter.multiModuleMode = multiModuleMode;
@@ -469,9 +459,6 @@
                             if (moduleOverride != null) {
                                 checkNoAllModulePath();
                                 defaultModule = moduleFinder.findModule(names.fromString(moduleOverride));
-                                if (legacyModuleOverride != null) {
-                                    defaultModule.sourceLocation = StandardLocation.SOURCE_PATH;
-                                }
                                 defaultModule.patchOutputLocation = StandardLocation.CLASS_OUTPUT;
                             } else {
                                 // Question: why not do findAllModules and initVisiblePackages here?
@@ -546,11 +533,6 @@
     }
 
     private void checkSourceLocation(JCCompilationUnit tree, ModuleSymbol msym) {
-        // skip check if legacy module override still in use
-        if (legacyModuleOverride != null) {
-            return;
-        }
-
         try {
             JavaFileObject fo = tree.sourcefile;
             if (fileManager.contains(msym.sourceLocation, fo)) {
@@ -582,7 +564,7 @@
 
     private String singleModuleOverride(List<JCCompilationUnit> trees) {
         if (!fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH)) {
-            return legacyModuleOverride;
+            return null;
         }
 
         Set<String> override = new LinkedHashSet<>();
@@ -602,7 +584,7 @@
         }
 
         switch (override.size()) {
-            case 0: return legacyModuleOverride;
+            case 0: return null;
             case 1: return override.iterator().next();
             default:
                 log.error(Errors.TooManyPatchedModules(override));
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Jun 26 07:49:55 2017 +0100
@@ -838,7 +838,7 @@
 
         for(TypeElement a  : annotationsPresent) {
             ModuleElement mod = elementUtils.getModuleOf(a);
-            String moduleSpec = allowModules && mod != null ? mod.getSimpleName() + "/" : "";
+            String moduleSpec = allowModules && mod != null ? mod.getQualifiedName() + "/" : "";
             unmatchedAnnotations.put(moduleSpec + a.getQualifiedName().toString(),
                                      a);
         }
--- a/src/jdk.compiler/share/classes/module-info.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.compiler/share/classes/module-info.java	Mon Jun 26 07:49:55 2017 +0100
@@ -88,6 +88,7 @@
     exports com.sun.source.tree;
     exports com.sun.source.util;
     exports com.sun.tools.javac;
+
     exports com.sun.tools.doclint to
         jdk.javadoc;
     exports com.sun.tools.javac.api to
@@ -127,16 +128,16 @@
     uses com.sun.source.util.Plugin;
     uses com.sun.tools.javac.platform.PlatformProvider;
 
-    provides java.util.spi.ToolProvider
-        with com.sun.tools.javac.main.JavacToolProvider;
+    provides java.util.spi.ToolProvider with
+        com.sun.tools.javac.main.JavacToolProvider;
 
-    provides com.sun.tools.javac.platform.PlatformProvider
-        with com.sun.tools.javac.platform.JDKPlatformProvider;
+    provides com.sun.tools.javac.platform.PlatformProvider with
+        com.sun.tools.javac.platform.JDKPlatformProvider;
 
-    provides javax.tools.JavaCompiler
-        with com.sun.tools.javac.api.JavacTool;
+    provides javax.tools.JavaCompiler with
+        com.sun.tools.javac.api.JavacTool;
 
-    provides javax.tools.Tool
-        with com.sun.tools.javac.api.JavacTool;
+    provides javax.tools.Tool with
+        com.sun.tools.javac.api.JavacTool;
 }
 
--- a/src/jdk.javadoc/share/classes/module-info.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.javadoc/share/classes/module-info.java	Mon Jun 26 07:49:55 2017 +0100
@@ -58,9 +58,10 @@
  * @since 9
  */
 module jdk.javadoc {
+    requires java.xml;
+
     requires transitive java.compiler;
     requires transitive jdk.compiler;
-    requires java.xml;
 
     exports com.sun.javadoc;
     exports com.sun.tools.doclets;
@@ -69,13 +70,13 @@
 
     exports jdk.javadoc.doclet;
 
-    provides java.util.spi.ToolProvider
-        with jdk.javadoc.internal.tool.JavadocToolProvider;
+    provides java.util.spi.ToolProvider with
+        jdk.javadoc.internal.tool.JavadocToolProvider;
 
-    provides javax.tools.DocumentationTool
-        with jdk.javadoc.internal.api.JavadocTool;
+    provides javax.tools.DocumentationTool with
+        jdk.javadoc.internal.api.JavadocTool;
 
-    provides javax.tools.Tool
-        with jdk.javadoc.internal.api.JavadocTool;
+    provides javax.tools.Tool with
+        jdk.javadoc.internal.api.JavadocTool;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.javadoc/share/legal/pako.md	Mon Jun 26 07:49:55 2017 +0100
@@ -0,0 +1,45 @@
+## Pako v1.0
+
+### Pako License
+<pre>
+Copyright (C) 2014-2017 by Vitaly Puzrin and Andrei Tuputcyn
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+(C) 1995-2013 Jean-loup Gailly and Mark Adler
+(C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software
+in a product, an acknowledgment in the product documentation would be
+appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+</pre>
+
+
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModuleInfoBuilder.java	Mon Jun 26 07:49:55 2017 +0100
@@ -203,21 +203,43 @@
         writer.format("%smodule %s {%n", open ? "open " : "", md.name());
 
         Map<String, Module> modules = configuration.getModules();
-        // first print the JDK modules
-        md.requires().stream()
-          .filter(req -> !req.name().equals("java.base"))   // implicit requires
-          .sorted(Comparator.comparing(Requires::name))
-          .forEach(req -> writer.format("    requires %s;%n",
-                                        toString(req.modifiers(), req.name())));
+
+        // first print requires
+        Set<Requires> reqs = md.requires().stream()
+            .filter(req -> !req.name().equals("java.base") && req.modifiers().isEmpty())
+            .collect(Collectors.toSet());
+        reqs.stream()
+            .sorted(Comparator.comparing(Requires::name))
+            .forEach(req -> writer.format("    requires %s;%n",
+                                          toString(req.modifiers(), req.name())));
+        if (!reqs.isEmpty()) {
+            writer.println();
+        }
+
+        // requires transitive
+        reqs = md.requires().stream()
+                 .filter(req -> !req.name().equals("java.base") && !req.modifiers().isEmpty())
+                 .collect(Collectors.toSet());
+        reqs.stream()
+            .sorted(Comparator.comparing(Requires::name))
+            .forEach(req -> writer.format("    requires %s;%n",
+                                          toString(req.modifiers(), req.name())));
+        if (!reqs.isEmpty()) {
+            writer.println();
+        }
 
         if (!open) {
             md.exports().stream()
               .peek(exp -> {
                   if (exp.isQualified())
                       throw new InternalError(md.name() + " qualified exports: " + exp);
-              })
+                  })
               .sorted(Comparator.comparing(Exports::source))
               .forEach(exp -> writer.format("    exports %s;%n", exp.source()));
+
+            if (!md.exports().isEmpty()) {
+                writer.println();
+            }
         }
 
         md.provides().stream()
@@ -228,8 +250,11 @@
                                       String.format("    provides %s with%n",
                                                     p.service().replace('$', '.')),
                                       ";")))
-          .forEach(writer::println);
+                     .forEach(writer::println);
 
+        if (!md.provides().isEmpty()) {
+            writer.println();
+        }
         writer.println("}");
     }
 
--- a/src/jdk.jdeps/share/classes/module-info.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.jdeps/share/classes/module-info.java	Mon Jun 26 07:49:55 2017 +0100
@@ -59,6 +59,7 @@
 module jdk.jdeps {
     requires java.compiler;
     requires jdk.compiler;
+
     exports com.sun.tools.classfile to jdk.jlink;
 
     provides java.util.spi.ToolProvider with
--- a/src/jdk.jshell/share/classes/module-info.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/src/jdk.jshell/share/classes/module-info.java	Mon Jun 26 07:49:55 2017 +0100
@@ -65,27 +65,28 @@
  * @since 9
  */
 module jdk.jshell {
-    requires transitive java.compiler;
-    requires transitive jdk.jdi;
-    requires transitive java.prefs;
     requires java.logging;
     requires jdk.compiler;
+    requires jdk.internal.ed;
     requires jdk.internal.le;
-    requires jdk.internal.ed;
     requires jdk.internal.opt;
 
+    requires transitive java.compiler;
+    requires transitive java.prefs;
+    requires transitive jdk.jdi;
+
     exports jdk.jshell;
+    exports jdk.jshell.execution;
     exports jdk.jshell.spi;
-    exports jdk.jshell.execution;
     exports jdk.jshell.tool;
 
     uses jdk.jshell.spi.ExecutionControlProvider;
     uses jdk.internal.editor.spi.BuildInEditorProvider;
 
-    provides javax.tools.Tool
-        with jdk.internal.jshell.tool.JShellToolProvider;
-    provides jdk.jshell.spi.ExecutionControlProvider
-        with jdk.jshell.execution.JdiExecutionControlProvider,
-             jdk.jshell.execution.LocalExecutionControlProvider,
-             jdk.jshell.execution.FailOverExecutionControlProvider;
+    provides javax.tools.Tool with
+        jdk.internal.jshell.tool.JShellToolProvider;
+    provides jdk.jshell.spi.ExecutionControlProvider with
+        jdk.jshell.execution.JdiExecutionControlProvider,
+        jdk.jshell.execution.LocalExecutionControlProvider,
+        jdk.jshell.execution.FailOverExecutionControlProvider;
 }
--- a/test/tools/javac/file/MultiReleaseJar/MutliReleaseModuleInfoTest.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/test/tools/javac/file/MultiReleaseJar/MutliReleaseModuleInfoTest.java	Mon Jun 26 07:49:55 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -132,7 +132,7 @@
             }
             boolean foundjd = false;
             for (RequiresDirective rd : ElementFilter.requiresIn(sm.getDirectives())) {
-                foundjd |= rd.getDependency().getSimpleName().contentEquals("java.desktop");
+                foundjd |= rd.getDependency().getQualifiedName().contentEquals("java.desktop");
             }
             if (!foundjd) {
                 throw new AssertionError("Missing dependency on java desktop module!");
--- a/test/tools/javac/modules/EdgeCases.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/test/tools/javac/modules/EdgeCases.java	Mon Jun 26 07:49:55 2017 +0100
@@ -595,12 +595,12 @@
 
                 System.out.println("from directives:");
                 for (RequiresDirective rd : ElementFilter.requiresIn(testE.getDirectives())) {
-                    System.out.println(rd.getDependency().getSimpleName());
+                    System.out.println(rd.getDependency().getQualifiedName());
                 }
 
                 System.out.println("from requires:");
                 for (RequiresDirective rd : ((ModuleSymbol) testE).requires) {
-                    System.out.println(rd.getDependency().getSimpleName());
+                    System.out.println(rd.getDependency().getQualifiedName());
                 }
             }
 
--- a/test/tools/javac/modules/LegacyXModuleTest.java	Sat Jun 17 15:33:14 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * 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 8178012
- * @summary tests for multi-module mode compilation
- * @library /tools/lib
- * @modules
- *      jdk.compiler/com.sun.tools.javac.api
- *      jdk.compiler/com.sun.tools.javac.main
- * @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase
- * @run main LegacyXModuleTest
- */
-
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-
-import toolbox.JavacTask;
-import toolbox.Task;
-
-public class LegacyXModuleTest extends ModuleTestBase {
-
-    public static void main(String... args) throws Exception {
-        new LegacyXModuleTest().runTests();
-    }
-
-    @Test
-    public void testLegacyXModule(Path base) throws Exception {
-        //note: avoiding use of java.base, as that gets special handling on some places:
-        Path src = base.resolve("src");
-        tb.writeJavaFiles(src, "package com.sun.tools.javac.comp; public class Extra { Modules modules; }");
-        Path classes = base.resolve("classes");
-        tb.createDirectories(classes);
-
-        new JavacTask(tb)
-            .options("-XD-Xmodule:jdk.compiler")
-            .outdir(classes)
-            .files(findJavaFiles(src))
-            .run()
-            .writeAll()
-            .getOutput(Task.OutputKind.DIRECT);
-
-        List<String> log = new JavacTask(tb)
-                .options("-XD-Xmodule:java.compiler",
-                         "-XD-Xmodule:jdk.compiler",
-                         "-XDrawDiagnostics")
-                .outdir(classes)
-                .files(findJavaFiles(src))
-                .run(Task.Expect.FAIL)
-                .writeAll()
-                .getOutputLines(Task.OutputKind.DIRECT);
-
-        List<String> actual =
-                Arrays.asList("Extra.java:1:56: compiler.err.cant.resolve.location: kindname.class, Modules, , , " +
-                                                "(compiler.misc.location: kindname.class, com.sun.tools.javac.comp.Extra, null)",
-                              "1 error");
-
-        if (!Objects.equals(actual, log))
-            throw new Exception("expected output not found: " + log);
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/element/TestModuleElementNames.java	Mon Jun 26 07:49:55 2017 +0100
@@ -0,0 +1,68 @@
+/*
+ * 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 8163989
+ * @summary Test basic workings of naming methods on ModuleElement
+ * @library /tools/javac/lib
+ * @modules java.compiler
+ *          jdk.compiler
+ * @build   JavacTestingAbstractProcessor TestModuleElementNames
+ * @compile -processor TestModuleElementNames -proc:only TestModuleElementNames.java
+ */
+
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+
+/**
+ * Test basic workings of names of ModuleElement.
+ */
+public class TestModuleElementNames extends JavacTestingAbstractProcessor {
+    public boolean process(Set<? extends TypeElement> annotations,
+                           RoundEnvironment roundEnv) {
+        if (!roundEnv.processingOver()) {
+            checkNames(eltUtils.getModuleElement(""),          "",          "",          true);
+            checkNames(eltUtils.getModuleElement("java.base"), "base",      "java.base", false);
+        }
+        return true;
+    }
+
+    private void checkNames(ModuleElement mod, String expectedSimple, String expectedQual, boolean expectedUnnamed) {
+        boolean unnamed = mod.isUnnamed();
+        String simpleName    = mod.getSimpleName().toString();
+        String qualifiedName = mod.getQualifiedName().toString();
+
+        if (unnamed != expectedUnnamed) {
+            throw new RuntimeException("Unnamed mismatch on " + qualifiedName);
+        }
+
+        if (!simpleName.equals(expectedSimple) ||
+            !qualifiedName.equals(expectedQual)) {
+            throw new RuntimeException("Unexpected name,\tqualitifed ``" + qualifiedName +
+                                       "''\tsimmple ``" + simpleName + "''");
+        }
+    }
+}
--- a/test/tools/javac/processing/model/element/TestPackageElement.java	Sat Jun 17 15:33:14 2017 +0100
+++ b/test/tools/javac/processing/model/element/TestPackageElement.java	Mon Jun 26 07:49:55 2017 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6449798 6399404 8173776
+ * @bug 6449798 6399404 8173776 8163989
  * @summary Test basic workings of PackageElement
  * @author  Joseph D. Darcy
  * @library /tools/javac/lib
@@ -54,8 +54,7 @@
         if (!roundEnv.processingOver()) {
             PackageElement unnamedPkg = eltUtils.getPackageElement("");
 
-            if (!unnamedPkg.getQualifiedName().contentEquals(""))
-                throw new RuntimeException("The unnamed package is named!");
+            testNames(unnamedPkg, "", "");
 
             // The next line tests an implementation detail upon which
             // some diagnostics depend.
@@ -70,11 +69,23 @@
             if (javaLang.isUnnamed())
                 throw new RuntimeException("Package java.lang is unnamed!");
 
+            testNames(javaLang, "java.lang", "lang");
+
             testEnclosingElement(javaLang);
         }
         return true;
     }
 
+    void testNames(PackageElement pkg, String expectedQualified, String expectedSimple) {
+        String tmp = pkg.getQualifiedName().toString();
+        if (!tmp.equals(expectedQualified))
+            throw new RuntimeException("Unexpected qualifed name ``" + tmp + "''.");
+
+        tmp = pkg.getSimpleName().toString();
+        if (!tmp.equals(expectedSimple))
+            throw new RuntimeException("Unexpected simple name ``" + tmp + "''.");
+    }
+
     void testEnclosingElement(PackageElement javaLang) {
         SourceVersion version = processingEnv.getSourceVersion();
         Element enclosing = javaLang.getEnclosingElement();