changeset 44288:c33a416cfcf8

8176539: javadoc ignores module-info files on the command line Reviewed-by: jjg
author ksrini
date Mon, 13 Mar 2017 17:02:18 -0700
parents 829205b133d4
children 842ccb558d7d
files langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties langtools/test/jdk/javadoc/tool/modules/CommandLineFiles.java langtools/test/jdk/javadoc/tool/modules/ModuleTestBase.java langtools/test/jdk/javadoc/tool/modules/Modules.java langtools/test/jdk/javadoc/tool/modules/PackageOptions.java
diffstat 6 files changed, 85 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Mon Mar 13 16:46:17 2017 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java	Mon Mar 13 17:02:18 2017 -0700
@@ -160,11 +160,7 @@
             // Parse the files and collect the package names.
             for (String arg: javaNames) {
                 if (fm != null && arg.endsWith(".java") && new File(arg).exists()) {
-                    if (new File(arg).getName().equals("module-info.java")) {
-                        messager.printWarningUsingKey("main.file_ignored", arg);
-                    } else {
-                        parse(fm.getJavaFileObjects(arg), classTrees, true);
-                    }
+                    parse(fm.getJavaFileObjects(arg), classTrees, true);
                 } else if (isValidPackageName(arg)) {
                     packageNames.add(arg);
                 } else if (arg.endsWith(".java")) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Mon Mar 13 16:46:17 2017 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/resources/javadoc.properties	Mon Mar 13 17:02:18 2017 -0700
@@ -278,7 +278,6 @@
 main.illegal_locale_name=Locale not available: {0}
 main.malformed_locale_name=Malformed locale name: {0}
 main.file_not_found=File not found: "{0}"
-main.file_ignored=File ignored: "{0}" (not yet supported)
 main.illegal_class_name=Illegal class name: "{0}"
 main.illegal_package_name=Illegal package name: "{0}"
 main.illegal_option_value=Illegal option value: "{0}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/jdk/javadoc/tool/modules/CommandLineFiles.java	Mon Mar 13 17:02:18 2017 -0700
@@ -0,0 +1,72 @@
+/*
+ * 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 8176539
+ * @summary Test use case when all java files are listed
+ * @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 /tools/lib
+ * @build toolbox.ToolBox toolbox.TestRunner
+ * @run main CommandLineFiles
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import toolbox.*;
+
+public class CommandLineFiles extends ModuleTestBase {
+
+    public static void main(String... args) throws Exception {
+        new CommandLineFiles().runTests();
+    }
+
+    @Test
+    public void testExplicitJavaFiles(Path base) throws Exception {
+        Path src = Paths.get(base.toString(), "src");
+        Path mpath = Paths.get(src. toString(), "m");
+
+        tb.writeJavaFiles(mpath,
+                "module m { exports p; }",
+                "package p; public class C { }");
+
+        List<String> cmdList = new ArrayList<>();
+        cmdList.add("--source-path");
+        cmdList.add(mpath.toString());
+        Arrays.asList(tb.findJavaFiles(src)).stream()
+                .map(Path::toString)
+                .collect(Collectors.toCollection(() -> cmdList));
+        execTask(cmdList.toArray(new String[cmdList.size()]));
+        assertMessageNotPresent("warning:");
+    }
+
+}
--- a/langtools/test/jdk/javadoc/tool/modules/ModuleTestBase.java	Mon Mar 13 16:46:17 2017 -0700
+++ b/langtools/test/jdk/javadoc/tool/modules/ModuleTestBase.java	Mon Mar 13 17:02:18 2017 -0700
@@ -180,11 +180,11 @@
         assertPresent(regex, STDOUT);
     }
 
-    void assertErrorPresent(String regex) throws Exception {
+    void assertMessagePresent(String regex) throws Exception {
         assertPresent(regex, Task.OutputKind.DIRECT);
     }
 
-    void assertErrorNotPresent(String regex) throws Exception {
+    void assertMessageNotPresent(String regex) throws Exception {
         assertNotPresent(regex, Task.OutputKind.DIRECT);
     }
 
--- a/langtools/test/jdk/javadoc/tool/modules/Modules.java	Mon Mar 13 16:46:17 2017 -0700
+++ b/langtools/test/jdk/javadoc/tool/modules/Modules.java	Mon Mar 13 17:02:18 2017 -0700
@@ -111,8 +111,8 @@
         execNegativeTask("--source-path", mod.toString(),
                 javafile.toString());
 
-        assertErrorPresent("error: cannot access module-info");
-        assertErrorNotPresent("error - fatal error encountered");
+        assertMessagePresent("error: cannot access module-info");
+        assertMessageNotPresent("error - fatal error encountered");
 
     }
 
@@ -174,7 +174,7 @@
         // no module path
         execNegativeTask("--module-source-path", src.toString(),
                 "--module", "m2");
-        assertErrorPresent("error: module not found: m1");
+        assertMessagePresent("error: module not found: m1");
     }
 
     @Test
@@ -213,7 +213,7 @@
         execNegativeTask("--module-source-path", src.toString(),
                 "--module-path", modulePath.toString(),
                 "--module", "m2");
-        assertErrorPresent("error: cannot find symbol");
+        assertMessagePresent("error: cannot find symbol");
 
         // dependency from module path
         ModuleBuilder mb3 = new ModuleBuilder(tb, "m3");
@@ -226,7 +226,7 @@
                 "--module-path", modulePath.toString(),
                 "--upgrade-module-path", upgradePath.toString(),
                 "--module", "m3");
-        assertErrorPresent("Z.java:1: error: cannot find symbol");
+        assertMessagePresent("Z.java:1: error: cannot find symbol");
     }
 
     @Test
@@ -292,7 +292,7 @@
                 "--module-path", modulePath.toString(),
                 "--limit-modules", "java.base",
                 "--module", "m2");
-        assertErrorPresent("error: module not found: m1");
+        assertMessagePresent("error: module not found: m1");
     }
 
     @Test
@@ -525,7 +525,7 @@
                 "--module", "MIA",
                 "--expand-requires", "all");
 
-        assertErrorPresent("javadoc: error - module MIA not found.");
+        assertMessagePresent("javadoc: error - module MIA not found.");
     }
 
     @Test
@@ -547,7 +547,7 @@
                 "--module", "M,N,L,MIA,O,P",
                 "--expand-requires", "all");
 
-        assertErrorPresent("javadoc: error - module MIA not found");
+        assertMessagePresent("javadoc: error - module MIA not found");
     }
 
     void createAuxiliaryModules(Path src) throws IOException {
--- a/langtools/test/jdk/javadoc/tool/modules/PackageOptions.java	Mon Mar 13 16:46:17 2017 -0700
+++ b/langtools/test/jdk/javadoc/tool/modules/PackageOptions.java	Mon Mar 13 17:02:18 2017 -0700
@@ -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
@@ -180,7 +180,7 @@
                          "--module", "m1",
                          "-subpackages", "m1pub.pub1:pro");
 
-        assertErrorPresent("javadoc: error - No source files for package pro");
+        assertMessagePresent("javadoc: error - No source files for package pro");
     }
 
     @Test