diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
index 030867ef113..8516f22a011 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java
@@ -31,6 +31,7 @@ import java.io.*;
import java.util.List;
import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
@@ -121,6 +122,12 @@ public class SourceToHTMLConverter {
if (docEnv == null || outputdir == null) {
return;
}
+ for (ModuleElement mdl : configuration.getSpecifiedModuleElements()) {
+ // If -nodeprecated option is set and the module is marked as deprecated,
+ // do not convert the module files to HTML.
+ if (!(configuration.nodeprecated && utils.isDeprecated(mdl)))
+ convertModule(mdl, outputdir);
+ }
for (PackageElement pkg : configuration.getSpecifiedPackageElements()) {
// If -nodeprecated option is set and the package is marked as deprecated,
// do not convert the package files to HTML.
@@ -160,6 +167,27 @@ public class SourceToHTMLConverter {
}
}
+ /**
+ * Convert the documented packages contained in the given module to an HTML representation.
+ *
+ * @param mdl the module to convert.
+ * @param outputdir the name of the directory to output to.
+ * @throws DocFileIOException if there is a problem generating an output file
+ * @throws SimpleDocletException if there is a problem reading a source file
+ */
+ public void convertModule(ModuleElement mdl, DocPath outputdir)
+ throws DocFileIOException, SimpleDocletException {
+ if (mdl == null) {
+ return;
+ }
+ for (Element elem : mdl.getEnclosedElements()) {
+ if (elem instanceof PackageElement && configuration.docEnv.isIncluded(elem)
+ && !(configuration.nodeprecated && utils.isDeprecated(elem))) {
+ convertPackage((PackageElement) elem, outputdir);
+ }
+ }
+ }
+
/**
* Convert the given Class to an HTML.
*
diff --git a/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java b/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java
index 4867183bead..e694b27ab34 100644
--- a/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java
+++ b/test/langtools/jdk/javadoc/doclet/testMetadata/TestMetadata.java
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8218998 8219946
+ * @bug 8218998 8219946 8219060
* @summary Add metadata to generated API documentation files
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -72,9 +72,7 @@ public class TestMetadata extends JavadocTester {
args.add("-d");
args.add(String.format("out-%s-%s", s, i));
args.add("-use");
- if (s != Source.MODULES) {
- args.add("-linksource"); // broken, with modules: JDK-8219060
- }
+ args.add("-linksource");
if (i == Index.SPLIT) {
args.add("-splitIndex");
}
diff --git a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
index d3d8263ad88..ece57ccacd0 100644
--- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
+++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java
@@ -27,7 +27,7 @@
* 8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218
* 8175823 8166306 8178043 8181622 8183511 8169819 8074407 8183037 8191464
8164407 8192007 8182765 8196200 8196201 8196202 8196202 8205593 8202462
- 8184205
+ 8184205 8219060
* @summary Test modules support in javadoc.
* @author bpatel
* @library ../../lib
@@ -423,6 +423,39 @@ public class TestModules extends JavadocTester {
checkLinkOffline();
}
+ /**
+ * Test -linksource option.
+ */
+ @Test
+ public void testLinkSource() {
+ javadoc("-d", "out-linksource",
+ "-use",
+ "-linksource",
+ "-Xdoclint:none",
+ "--module-source-path", testSrc,
+ "--module", "moduleA,moduleB");
+ checkExit(Exit.OK);
+ checkLinks();
+ checkLinkSource(false);
+ }
+
+ /**
+ * Test -linksource option combined with -private.
+ */
+ @Test
+ public void testLinkSourcePrivate() {
+ javadoc("-d", "out-linksource-private",
+ "-use",
+ "-private",
+ "-linksource",
+ "-Xdoclint:none",
+ "--module-source-path", testSrc,
+ "--module", "moduleA,moduleB");
+ checkExit(Exit.OK);
+ checkLinks();
+ checkLinkSource(true);
+ }
+
void checkDescription(boolean found) {
checkOutput("moduleA/module-summary.html", found,
"\n"
@@ -1239,7 +1272,38 @@ public class TestModules extends JavadocTester {
checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
"Link to java.base module
");
-}
+ }
+
+ void checkLinkSource(boolean includePrivate) {
+ checkOutput("moduleA/module-summary.html", !includePrivate,
+ "
Package | \n" + + "Description | \n
---|---|
testpkgmdlA | \n" + + "\n |
public class " + + "TestClassInModuleA\nextends java.lang.Object\n
@Documented\npublic @interface "