8205593: Javadoc -link makes broken links if module name matches package name
Reviewed-by: jjg
This commit is contained in:
parent
25295df059
commit
4b47d2c9e7
@ -208,12 +208,6 @@ public class HtmlConfiguration extends BaseConfiguration {
|
||||
*/
|
||||
public HtmlVersion htmlVersion = null;
|
||||
|
||||
/**
|
||||
* Flag to enable/disable use of module directories when generating docs for modules
|
||||
* Default: on (module directories are enabled).
|
||||
*/
|
||||
public boolean useModuleDirectories = true;
|
||||
|
||||
/**
|
||||
* Collected set of doclint options
|
||||
*/
|
||||
@ -840,13 +834,6 @@ public class HtmlConfiguration extends BaseConfiguration {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(resources, "--no-module-directories") {
|
||||
@Override
|
||||
public boolean process(String option, List<String> args) {
|
||||
useModuleDirectories = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
Set<Doclet.Option> oset = new TreeSet<>();
|
||||
|
@ -610,7 +610,7 @@ public class HtmlDocletWriter {
|
||||
return links.createLink(pathString(packageElement, DocPaths.PACKAGE_SUMMARY),
|
||||
label);
|
||||
} else {
|
||||
DocLink crossPkgLink = getCrossPackageLink(utils.getPackageName(packageElement));
|
||||
DocLink crossPkgLink = getCrossPackageLink(packageElement);
|
||||
if (crossPkgLink != null) {
|
||||
return links.createLink(crossPkgLink, label);
|
||||
} else {
|
||||
@ -693,11 +693,10 @@ public class HtmlDocletWriter {
|
||||
|
||||
/*************************************************************
|
||||
* Return a class cross link to external class documentation.
|
||||
* The name must be fully qualified to determine which package
|
||||
* the class is in. The -link option does not allow users to
|
||||
* The -link option does not allow users to
|
||||
* link to external classes in the "default" package.
|
||||
*
|
||||
* @param qualifiedClassName the qualified name of the external class.
|
||||
* @param classElement the class element
|
||||
* @param refMemName the name of the member being referenced. This should
|
||||
* be null or empty string if no member is being referenced.
|
||||
* @param label the label for the external link.
|
||||
@ -705,19 +704,15 @@ public class HtmlDocletWriter {
|
||||
* @param code true if the label should be code font.
|
||||
* @return the link
|
||||
*/
|
||||
public Content getCrossClassLink(String qualifiedClassName, String refMemName,
|
||||
public Content getCrossClassLink(TypeElement classElement, String refMemName,
|
||||
Content label, boolean strong, boolean code) {
|
||||
String className = "";
|
||||
String packageName = qualifiedClassName == null ? "" : qualifiedClassName;
|
||||
int periodIndex;
|
||||
while ((periodIndex = packageName.lastIndexOf('.')) != -1) {
|
||||
className = packageName.substring(periodIndex + 1, packageName.length()) +
|
||||
(className.length() > 0 ? "." + className : "");
|
||||
if (classElement != null) {
|
||||
String className = utils.getSimpleName(classElement);
|
||||
PackageElement packageElement = utils.containingPackage(classElement);
|
||||
Content defaultLabel = new StringContent(className);
|
||||
if (code)
|
||||
defaultLabel = HtmlTree.CODE(defaultLabel);
|
||||
packageName = packageName.substring(0, periodIndex);
|
||||
if (getCrossPackageLink(packageName) != null) {
|
||||
if (getCrossPackageLink(packageElement) != null) {
|
||||
/*
|
||||
The package exists in external documentation, so link to the external
|
||||
class (assuming that it exists). This is definitely a limitation of
|
||||
@ -725,13 +720,13 @@ public class HtmlDocletWriter {
|
||||
exists, but no way to determine if the external class exists. We just
|
||||
have to assume that it does.
|
||||
*/
|
||||
DocLink link = configuration.extern.getExternalLink(packageName, pathToRoot,
|
||||
DocLink link = configuration.extern.getExternalLink(packageElement, pathToRoot,
|
||||
className + ".html", refMemName);
|
||||
return links.createLink(link,
|
||||
(label == null) || label.isEmpty() ? defaultLabel : label,
|
||||
strong,
|
||||
resources.getText("doclet.Href_Class_Or_Interface_Title", packageName),
|
||||
"", true);
|
||||
resources.getText("doclet.Href_Class_Or_Interface_Title",
|
||||
utils.getPackageName(packageElement)), "", true);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -744,14 +739,14 @@ public class HtmlDocletWriter {
|
||||
return configuration.extern.isExternal(typeElement);
|
||||
}
|
||||
|
||||
public DocLink getCrossPackageLink(String pkgName) {
|
||||
return configuration.extern.getExternalLink(pkgName, pathToRoot,
|
||||
public DocLink getCrossPackageLink(PackageElement element) {
|
||||
return configuration.extern.getExternalLink(element, pathToRoot,
|
||||
DocPaths.PACKAGE_SUMMARY.getPath());
|
||||
}
|
||||
|
||||
public DocLink getCrossModuleLink(String mdleName) {
|
||||
return configuration.extern.getExternalLink(mdleName, pathToRoot,
|
||||
docPaths.moduleSummary(mdleName).getPath());
|
||||
public DocLink getCrossModuleLink(ModuleElement element) {
|
||||
return configuration.extern.getExternalLink(element, pathToRoot,
|
||||
docPaths.moduleSummary(utils.getModuleName(element)).getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1024,17 +1019,13 @@ public class HtmlDocletWriter {
|
||||
return getPackageLink(refPackage, label);
|
||||
} else {
|
||||
// @see is not referencing an included class, module or package. Check for cross links.
|
||||
Content classCrossLink;
|
||||
DocLink elementCrossLink = (configuration.extern.isModule(refClassName))
|
||||
? getCrossModuleLink(refClassName) : getCrossPackageLink(refClassName);
|
||||
? getCrossModuleLink(utils.elementUtils.getModuleElement(refClassName)) :
|
||||
(refPackage != null) ? getCrossPackageLink(refPackage) : null;
|
||||
if (elementCrossLink != null) {
|
||||
// Element cross link found
|
||||
return links.createLink(elementCrossLink,
|
||||
(label.isEmpty() ? text : label), true);
|
||||
} else if ((classCrossLink = getCrossClassLink(refClassName,
|
||||
refMemName, label, false, !isLinkPlain)) != null) {
|
||||
// Class cross link found (possibly to a member in the class)
|
||||
return classCrossLink;
|
||||
} else {
|
||||
// No cross link found so print warning
|
||||
messages.warning(ch.getDocTreePath(see),
|
||||
|
@ -111,7 +111,7 @@ public class LinkFactoryImpl extends LinkFactory {
|
||||
}
|
||||
} else {
|
||||
Content crossLink = m_writer.getCrossClassLink(
|
||||
typeElement.getQualifiedName().toString(), classLinkInfo.where,
|
||||
typeElement, classLinkInfo.where,
|
||||
label, classLinkInfo.isStrong, true);
|
||||
if (crossLink != null) {
|
||||
link.addContent(crossLink);
|
||||
|
@ -866,8 +866,7 @@ public class Navigation {
|
||||
contents.packageLabel)));
|
||||
} else {
|
||||
DocLink crossPkgLink = configuration.extern.getExternalLink(
|
||||
configuration.utils.getPackageName(packageElement), pathToRoot,
|
||||
DocPaths.PACKAGE_SUMMARY.getPath());
|
||||
packageElement, pathToRoot, DocPaths.PACKAGE_SUMMARY.getPath());
|
||||
if (crossPkgLink != null) {
|
||||
tree.addContent(HtmlTree.LI(links.createLink(crossPkgLink, contents.packageLabel)));
|
||||
} else {
|
||||
|
@ -295,6 +295,11 @@ public abstract class BaseConfiguration {
|
||||
// A list of pairs containing urls and package list
|
||||
private final List<Pair<String, String>> linkOfflineList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Flag to enable/disable use of module directories when generating docs for modules
|
||||
* Default: on (module directories are enabled).
|
||||
*/
|
||||
public boolean useModuleDirectories = true;
|
||||
|
||||
public boolean dumpOnError = false;
|
||||
|
||||
@ -740,6 +745,13 @@ public abstract class BaseConfiguration {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
new XOption(resources, "--no-module-directories") {
|
||||
@Override
|
||||
public boolean process(String option, List<String> args) {
|
||||
useModuleDirectories = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
Set<Doclet.Option> set = new TreeSet<>();
|
||||
set.addAll(Arrays.asList(options));
|
||||
|
@ -226,6 +226,10 @@ doclet.Enum_Constant=Enum Constant
|
||||
doclet.Description=Description
|
||||
doclet.ConstantField=Constant Field
|
||||
doclet.Value=Value
|
||||
doclet.linkMismatch_PackagedLinkedtoModule=The code being documented uses packages in the unnamed module, \
|
||||
but the packages defined in {0} are in named modules.
|
||||
doclet.linkMismatch_ModuleLinkedtoPackage=The code being documented uses modules but the packages defined \
|
||||
in {0} are in the unnamed module.
|
||||
|
||||
#Documentation for Enums
|
||||
doclet.enum_values_doc.fullbody=\
|
||||
|
@ -29,8 +29,10 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ModuleElement;
|
||||
import javax.lang.model.element.PackageElement;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DocumentationTool;
|
||||
@ -59,7 +61,8 @@ public class Extern {
|
||||
* Map element names onto Extern Item objects.
|
||||
* Lazily initialized.
|
||||
*/
|
||||
private Map<String, Item> elementToItemMap;
|
||||
private Map<String, Item> moduleItems = new HashMap<>();
|
||||
private Map<String, Map<String, Item>> packageItems = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The global configuration information for this run.
|
||||
@ -85,18 +88,13 @@ public class Extern {
|
||||
* The URL or the directory path at which the element documentation will be
|
||||
* avaliable.
|
||||
*/
|
||||
final String path;
|
||||
final DocPath path;
|
||||
|
||||
/**
|
||||
* If given path is directory path then true else if it is a URL then false.
|
||||
*/
|
||||
final boolean relative;
|
||||
|
||||
/**
|
||||
* If the item is a module then true else if it is a package then false.
|
||||
*/
|
||||
boolean isModule = false;
|
||||
|
||||
/**
|
||||
* Constructor to build a Extern Item object and map it with the element name.
|
||||
* If the same element name is found in the map, then the first mapped
|
||||
@ -106,19 +104,11 @@ public class Extern {
|
||||
* @param path URL or Directory path from where the "element-list"
|
||||
* file is picked.
|
||||
* @param relative True if path is URL, false if directory path.
|
||||
* @param isModule True if the item is a module. False if it is a package.
|
||||
*/
|
||||
Item(String elementName, String path, boolean relative, boolean isModule) {
|
||||
Item(String elementName, DocPath path, boolean relative) {
|
||||
this.elementName = elementName;
|
||||
this.path = path;
|
||||
this.relative = relative;
|
||||
this.isModule = isModule;
|
||||
if (elementToItemMap == null) {
|
||||
elementToItemMap = new HashMap<>();
|
||||
}
|
||||
if (!elementToItemMap.containsKey(elementName)) { // save the previous
|
||||
elementToItemMap.put(elementName, this); // mapped location
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,7 +116,7 @@ public class Extern {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return elementName + (relative? " -> " : " => ") + path;
|
||||
return elementName + (relative? " -> " : " => ") + path.getPath();
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,14 +131,15 @@ public class Extern {
|
||||
* @return true if the element is externally documented
|
||||
*/
|
||||
public boolean isExternal(Element element) {
|
||||
if (elementToItemMap == null) {
|
||||
if (packageItems.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
PackageElement pe = configuration.utils.containingPackage(element);
|
||||
if (pe.isUnnamed()) {
|
||||
return false;
|
||||
}
|
||||
return elementToItemMap.get(configuration.utils.getPackageName(pe)) != null;
|
||||
|
||||
return findElementItem(pe) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,25 +149,25 @@ public class Extern {
|
||||
* @return true if the element is a module
|
||||
*/
|
||||
public boolean isModule(String elementName) {
|
||||
Item elem = findElementItem(elementName);
|
||||
return (elem == null) ? false : elem.isModule;
|
||||
Item elem = moduleItems.get(elementName);
|
||||
return (elem == null) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a link to be an external link if appropriate.
|
||||
*
|
||||
* @param elemName The element name.
|
||||
* @param element The element .
|
||||
* @param relativepath The relative path.
|
||||
* @param filename The link to convert.
|
||||
* @return if external return converted link else return null
|
||||
*/
|
||||
public DocLink getExternalLink(String elemName, DocPath relativepath, String filename) {
|
||||
return getExternalLink(elemName, relativepath, filename, null);
|
||||
public DocLink getExternalLink(Element element, DocPath relativepath, String filename) {
|
||||
return getExternalLink(element, relativepath, filename, null);
|
||||
}
|
||||
|
||||
public DocLink getExternalLink(String elemName, DocPath relativepath, String filename,
|
||||
public DocLink getExternalLink(Element element, DocPath relativepath, String filename,
|
||||
String memberName) {
|
||||
Item fnd = findElementItem(elemName);
|
||||
Item fnd = findElementItem(element);
|
||||
if (fnd == null)
|
||||
return null;
|
||||
|
||||
@ -184,7 +175,7 @@ public class Extern {
|
||||
// to contain external URLs!
|
||||
DocPath p = fnd.relative ?
|
||||
relativepath.resolve(fnd.path).resolve(filename) :
|
||||
DocPath.create(fnd.path).resolve(filename);
|
||||
fnd.path.resolve(filename);
|
||||
return new DocLink(p, "is-external=true", memberName);
|
||||
}
|
||||
|
||||
@ -266,13 +257,20 @@ public class Extern {
|
||||
/**
|
||||
* Get the Extern Item object associated with this element name.
|
||||
*
|
||||
* @param elemName Element name.
|
||||
* @param element Element
|
||||
*/
|
||||
private Item findElementItem(String elemName) {
|
||||
if (elementToItemMap == null) {
|
||||
return null;
|
||||
private Item findElementItem(Element element) {
|
||||
Item item = null;
|
||||
if (element instanceof ModuleElement) {
|
||||
item = moduleItems.get(configuration.utils.getModuleName((ModuleElement)element));
|
||||
}
|
||||
return elementToItemMap.get(elemName);
|
||||
else if (element instanceof PackageElement) {
|
||||
PackageElement packageElement = (PackageElement)element;
|
||||
ModuleElement moduleElement = configuration.utils.containingModule(packageElement);
|
||||
Map<String, Item> pkgMap = packageItems.get(configuration.utils.getModuleName(moduleElement));
|
||||
item = (pkgMap != null) ? pkgMap.get(configuration.utils.getPackageName(packageElement)) : null;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -370,23 +368,34 @@ public class Extern {
|
||||
* @throws IOException if there is a problem reading or closing the stream
|
||||
*/
|
||||
private void readElementList(InputStream input, String path, boolean relative)
|
||||
throws IOException {
|
||||
throws Fault, IOException {
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) {
|
||||
in.lines().forEach((elemname) -> {
|
||||
String elemname = null;
|
||||
String moduleName = null;
|
||||
DocPath elempath = null;
|
||||
DocPath basePath = DocPath.create(path);
|
||||
while ((elemname = in.readLine()) != null) {
|
||||
if (elemname.length() > 0) {
|
||||
boolean module;
|
||||
String elempath;
|
||||
elempath = basePath;
|
||||
if (elemname.startsWith(DocletConstants.MODULE_PREFIX)) {
|
||||
elemname = elemname.replace(DocletConstants.MODULE_PREFIX, "");
|
||||
elempath = path;
|
||||
module = true;
|
||||
moduleName = elemname.replace(DocletConstants.MODULE_PREFIX, "");
|
||||
Item item = new Item(moduleName, elempath, relative);
|
||||
moduleItems.put(moduleName, item);
|
||||
} else {
|
||||
elempath = path + elemname.replace('.', '/') + '/';
|
||||
module = false;
|
||||
DocPath pkgPath = DocPath.create(elemname.replace('.', '/'));
|
||||
if (configuration.useModuleDirectories && moduleName != null) {
|
||||
elempath = elempath.resolve(DocPath.create(moduleName).resolve(pkgPath));
|
||||
} else {
|
||||
elempath = elempath.resolve(pkgPath);
|
||||
}
|
||||
checkLinkCompatibility(elemname, moduleName, path);
|
||||
Item item = new Item(elemname, elempath, relative);
|
||||
packageItems.computeIfAbsent(moduleName == null ?
|
||||
DocletConstants.DEFAULT_ELEMENT_NAME : moduleName, k -> new TreeMap<>())
|
||||
.put(elemname, item);
|
||||
}
|
||||
Item ignore = new Item(elemname, elempath, relative, module);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,4 +409,18 @@ public class Extern {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkLinkCompatibility(String packageName, String moduleName, String path) throws Fault {
|
||||
PackageElement pe = configuration.utils.elementUtils.getPackageElement(packageName);
|
||||
if (pe != null) {
|
||||
ModuleElement me = (ModuleElement)pe.getEnclosingElement();
|
||||
if (me == null || me.isUnnamed()) {
|
||||
if (moduleName != null)
|
||||
throw new Fault(configuration.getText("doclet.linkMismatch_PackagedLinkedtoModule",
|
||||
path), null);
|
||||
} else if (moduleName == null)
|
||||
throw new Fault(configuration.getText("doclet.linkMismatch_ModuleLinkedtoPackage",
|
||||
path), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4645058 4747738 4855054 8024756 8141492 8196202
|
||||
* @bug 4645058 4747738 4855054 8024756 8141492 8196202 8205593
|
||||
* @summary Javascript IE load error when linked by -linkoffline
|
||||
* Window title shouldn't change when loading left frames (javascript)
|
||||
* @author dkramer
|
||||
@ -43,6 +43,7 @@ public class JavascriptWinTitle extends JavadocTester {
|
||||
@Test
|
||||
void test() {
|
||||
javadoc("-d", "out",
|
||||
"-source", "8",
|
||||
"--frames",
|
||||
"-doctitle", "Document Title",
|
||||
"-windowtitle", "Window Title",
|
||||
|
@ -26,7 +26,7 @@
|
||||
* Cross link to inner class: {@link javax.swing.text.AbstractDocument.AttributeContext Link to AttributeContext innerclass} <br>
|
||||
* Cross link to class: {@link java.math.BigDecimal Link to external class BigDecimal}<br>
|
||||
* Cross link to member: {@link java.math.BigInteger#gcd(java.math.BigInteger) Link to external member gcd}<br>
|
||||
* Cross link to package: {@link javax.tools.SimpleJavaFileObject#URI Link to external member URI}<br>
|
||||
* Cross link to package: {@link javax.tools.SimpleJavaFileObject#uri Link to external member URI}<br>
|
||||
*/
|
||||
public class C {
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4652655 4857717 8025633 8026567 8071982 8164407 8182765
|
||||
* @bug 4652655 4857717 8025633 8026567 8071982 8164407 8182765 8205593
|
||||
* @summary This test verifies that class cross references work properly.
|
||||
* @author jamieh
|
||||
* @library ../lib
|
||||
@ -45,6 +45,7 @@ public class TestClassCrossReferences extends JavadocTester {
|
||||
@Test
|
||||
void test() {
|
||||
javadoc("-d", "out",
|
||||
"-source", "8",
|
||||
"-Xdoclint:none",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", uri, testSrc,
|
||||
@ -60,7 +61,7 @@ public class TestClassCrossReferences extends JavadocTester {
|
||||
+ "title=\"class or interface in java.math\" class=\"externalLink\"><code>Link to external class BigDecimal</code></a>",
|
||||
"<a href=\"" + uri + "java/math/BigInteger.html?is-external=true#gcd(java.math.BigInteger)\" "
|
||||
+ "title=\"class or interface in java.math\" class=\"externalLink\"><code>Link to external member gcd</code></a>",
|
||||
"<a href=\"" + uri + "javax/tools/SimpleJavaFileObject.html?is-external=true#URI\" "
|
||||
"<a href=\"" + uri + "javax/tools/SimpleJavaFileObject.html?is-external=true#uri\" "
|
||||
+ "title=\"class or interface in javax.tools\" class=\"externalLink\"><code>Link to external member URI</code></a>",
|
||||
"<dl>\n"
|
||||
+ "<dt><span class=\"overrideSpecifyLabel\">Overrides:</span></dt>\n"
|
||||
@ -68,9 +69,23 @@ public class TestClassCrossReferences extends JavadocTester {
|
||||
+ "</dl>");
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_error() {
|
||||
javadoc("-d", "out-error",
|
||||
"-Xdoclint:none",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", uri, testSrc,
|
||||
testSrc("C.java"));
|
||||
checkExit(Exit.ERROR);
|
||||
checkOutput(Output.OUT, true,
|
||||
"The code being documented uses modules but the packages defined"
|
||||
+ " in http://docs.oracle.com/javase/8/docs/api/ are in the unnamed module");
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_html4() {
|
||||
javadoc("-d", "out-html4",
|
||||
"-source", "8",
|
||||
"-html4",
|
||||
"-Xdoclint:none",
|
||||
"-sourcepath", testSrc,
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4369014 4851991 8164407
|
||||
* @bug 4369014 4851991 8164407 8205593
|
||||
* @summary Determine if the docRoot inline tag works properly.
|
||||
* If docRoot performs as documented, the test passes.
|
||||
* Make sure that the docRoot tag works with the -bottom option.
|
||||
@ -47,6 +47,7 @@ public class TestDocRootInlineTag extends JavadocTester {
|
||||
|
||||
javadoc("-bottom", "The value of @docRoot is \"{@docRoot}\"",
|
||||
"-d", "out",
|
||||
"-source", "8",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", uri, testSrc,
|
||||
testSrc("TestDocRootTag.java"), "pkg");
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4857717 8025633 8026567 8164407 8182765
|
||||
* @bug 4857717 8025633 8026567 8164407 8182765 8205593
|
||||
* @summary Test to make sure that externally overriden and implemented methods
|
||||
* are documented properly. The method should still include "implements" or
|
||||
* "overrides" documentation even though the method is external.
|
||||
@ -45,6 +45,7 @@ public class TestExternalOverridenMethod extends JavadocTester {
|
||||
@Test
|
||||
void test() {
|
||||
javadoc("-d", "out",
|
||||
"-source","8",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", uri, testSrc,
|
||||
"pkg");
|
||||
@ -67,6 +68,7 @@ public class TestExternalOverridenMethod extends JavadocTester {
|
||||
@Test
|
||||
void test_html4() {
|
||||
javadoc("-d", "out-html4",
|
||||
"-source", "8",
|
||||
"-html4",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", uri, testSrc,
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4663254 8016328 8025633 8026567 8081854 8182765
|
||||
* @bug 4663254 8016328 8025633 8026567 8081854 8182765 8205593
|
||||
* @summary Verify that spaces do not appear in hrefs and anchors.
|
||||
* @author jamieh
|
||||
* @library ../lib
|
||||
@ -43,6 +43,7 @@ public class TestHref extends JavadocTester {
|
||||
void test() {
|
||||
javadoc("-Xdoclint:none",
|
||||
"-d", "out",
|
||||
"-source", "8",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/", testSrc,
|
||||
"pkg");
|
||||
@ -85,6 +86,7 @@ public class TestHref extends JavadocTester {
|
||||
void test_html4() {
|
||||
javadoc("-Xdoclint:none",
|
||||
"-d", "out-html4",
|
||||
"-source", "8",
|
||||
"-html4",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/", testSrc,
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4720957 5020118 8026567 8038976 8184969 8164407 8182765
|
||||
* @bug 4720957 5020118 8026567 8038976 8184969 8164407 8182765 8205593
|
||||
* @summary Test to make sure that -link and -linkoffline link to
|
||||
* right files, and URLs with and without trailing slash are accepted.
|
||||
* @author jamieh
|
||||
@ -61,6 +61,7 @@ public class TestLinkOption extends JavadocTester {
|
||||
String out1 = "out1";
|
||||
String url = "http://acme.com/jdk/";
|
||||
javadoc("-d", out1,
|
||||
"-source", "8",
|
||||
"-classpath", mylib,
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", url, testSrc + "/jdk",
|
||||
@ -113,6 +114,7 @@ public class TestLinkOption extends JavadocTester {
|
||||
|
||||
String out1_html4 = "out1-html4";
|
||||
javadoc("-d", out1_html4,
|
||||
"-source", "8",
|
||||
"-html4",
|
||||
"-classpath", mylib,
|
||||
"-sourcepath", testSrc,
|
||||
|
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 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 8205593
|
||||
* @summary Javadoc -link makes broken links if module name matches package name
|
||||
* @library /tools/lib ../lib
|
||||
* @modules
|
||||
* jdk.javadoc/jdk.javadoc.internal.tool
|
||||
* jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* @build JavadocTester
|
||||
* @run main TestLinkOptionWithModule
|
||||
*/
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import builder.ClassBuilder;
|
||||
import builder.ClassBuilder.*;
|
||||
import toolbox.ModuleBuilder;
|
||||
import toolbox.ToolBox;
|
||||
|
||||
|
||||
public class TestLinkOptionWithModule extends JavadocTester {
|
||||
|
||||
final ToolBox tb;
|
||||
private final Path src;
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
TestLinkOptionWithModule tester = new TestLinkOptionWithModule();
|
||||
tester.runTests(m -> new Object[]{Paths.get(m.getName())});
|
||||
}
|
||||
|
||||
TestLinkOptionWithModule() throws Exception {
|
||||
tb = new ToolBox();
|
||||
src = Paths.get("src");
|
||||
initModulesAndPackages();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModuleLinkedToModule(Path base) throws Exception {
|
||||
Path out1 = base.resolve("out1a"), out2 = base.resolve("out1b");
|
||||
|
||||
javadoc("-d", out1.toString(),
|
||||
"--module-source-path", src.toString(),
|
||||
"--module", "com.ex1");
|
||||
|
||||
javadoc("-d", out2.toString(),
|
||||
"--module-source-path", src.toString(),
|
||||
"--module", "com.ex2",
|
||||
"-link", "../" + out1.getFileName());
|
||||
|
||||
checkExit(Exit.OK);
|
||||
checkOutput("com.ex2/com/ex2/B.html", true,
|
||||
"<a href=\"../../../../out1a/com.ex1/com/ex1/A.html?is-external=true\" "
|
||||
+ "title=\"class or interface in com.ex1\" class=\"externalLink\">A</a>");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPackageLinkedToPackage(Path base) throws Exception {
|
||||
Path out1 = base.resolve("out2a"), out2 = base.resolve("out2b");
|
||||
|
||||
javadoc("-d", out1.toString(),
|
||||
"-sourcepath", src.toString(),
|
||||
"-subpackages", "com.ex1");
|
||||
|
||||
javadoc("-d", out2.toString(),
|
||||
"-sourcepath", src.toString(),
|
||||
"-subpackages", "com.ex2",
|
||||
"-link", "../" + out1.getFileName());
|
||||
|
||||
checkExit(Exit.OK);
|
||||
checkOutput("com/ex2/B.html", true,
|
||||
"<a href=\"../../../out2a/com/ex1/A.html?is-external=true\" title=\"class or interface in com.ex1\" "
|
||||
+ "class=\"externalLink\">A</a>");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testModuleLinkedToPackage(Path base) throws Exception {
|
||||
Path out1 = base.resolve("out3a"), out2 = base.resolve("out3b");
|
||||
|
||||
javadoc("-d", out1.toString(),
|
||||
"-sourcepath", src.toString(),
|
||||
"-subpackages", "com.ex1");
|
||||
|
||||
javadoc("-d", out2.toString(),
|
||||
"--module-source-path", src.toString(),
|
||||
"--module", "com.ex2",
|
||||
"-link", "../" + out1.getFileName());
|
||||
|
||||
checkExit(Exit.ERROR);
|
||||
checkOutput(Output.OUT, true,
|
||||
"The code being documented uses modules but the packages defined "
|
||||
+ "in ../out3a/ are in the unnamed module");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPackageLinkedToModule(Path base) throws Exception {
|
||||
Path out1 = base.resolve("out4a"), out2 = base.resolve("out4b");
|
||||
|
||||
javadoc("-d", out1.toString(),
|
||||
"--module-source-path", src.toString(),
|
||||
"--module", "com.ex1");
|
||||
|
||||
javadoc("-d", out2.toString(),
|
||||
"-sourcepath", src.toString(),
|
||||
"-subpackages", "com.ex2",
|
||||
"-link", "../" + out1.getFileName());
|
||||
|
||||
checkExit(Exit.ERROR);
|
||||
checkOutput(Output.OUT, true,
|
||||
"The code being documented uses packages in the unnamed module, but the packages defined "
|
||||
+ "in ../out4a/ are in named modules");
|
||||
}
|
||||
|
||||
|
||||
void initModulesAndPackages() throws Exception{
|
||||
new ModuleBuilder(tb, "com.ex1")
|
||||
.exports("com.ex1")
|
||||
.classes("package com.ex1; public class A{}")
|
||||
.write(src);
|
||||
|
||||
new ModuleBuilder(tb, "com.ex2")
|
||||
.requires("com.ex1")
|
||||
.exports("com.ex2")
|
||||
.classes("package com.ex2; \n"
|
||||
+ "import com.ex1.A;\n"
|
||||
+ "public class B{\n"
|
||||
+ "public B(A obj){}\n"
|
||||
+ "}\n")
|
||||
.write(src);
|
||||
|
||||
new ClassBuilder(tb, "com.ex1.A")
|
||||
.setModifiers("public","class")
|
||||
.write(src);
|
||||
|
||||
new ClassBuilder(tb, "com.ex2.B")
|
||||
.addImports("com.ex1.A")
|
||||
.setModifiers("public","class")
|
||||
.addMembers(MethodBuilder.parse("public void foo(A a)"))
|
||||
.write(src);
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4739870
|
||||
* @bug 4739870 8205593
|
||||
* @summary Make sure that a new line may act as a separator between
|
||||
* link and label.
|
||||
* @author jamieh
|
||||
@ -43,6 +43,7 @@ public class TestNewLineInLink extends JavadocTester {
|
||||
@Test
|
||||
void test() {
|
||||
javadoc("-d", "out",
|
||||
"-source", "8",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", "http://www.java.sun.com/j2se/1.4/docs/api", testSrc("jdk"),
|
||||
"testNewLineInLink");
|
||||
|
@ -26,7 +26,7 @@
|
||||
* @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363
|
||||
* 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
|
||||
8164407 8192007 8182765 8196200 8196201 8196202 8196202 8205593
|
||||
* @summary Test modules support in javadoc.
|
||||
* @author bpatel
|
||||
* @library ../lib
|
||||
@ -1617,10 +1617,10 @@ public class TestModules extends JavadocTester {
|
||||
|
||||
void checkLinkOffline() {
|
||||
checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
|
||||
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java/lang/String.html?is-external=true\" "
|
||||
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/String.html?is-external=true\" "
|
||||
+ "title=\"class or interface in java.lang\" class=\"externalLink\"><code>Link to String Class</code></a>");
|
||||
checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
|
||||
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java/lang/package-summary.html?is-external=true\" "
|
||||
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/java/lang/package-summary.html?is-external=true\" "
|
||||
+ "class=\"externalLink\"><code>Link to java.lang package</code></a>");
|
||||
checkOutput("moduleB/testpkg3mdlB/package-summary.html", true,
|
||||
"<a href=\"https://docs.oracle.com/javase/9/docs/api/java.base/module-summary.html?is-external=true\" "
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4714257 8164407
|
||||
* @bug 4714257 8164407 8205593
|
||||
* @summary Test to make sure that the title attribute shows up in links.
|
||||
* @author jamieh
|
||||
* @library ../lib
|
||||
@ -43,6 +43,7 @@ public class TestTitleInHref extends JavadocTester {
|
||||
void test() {
|
||||
String uri = "http://java.sun.com/j2se/1.4/docs/api";
|
||||
javadoc("-d", "out",
|
||||
"-source", "8",
|
||||
"-sourcepath", testSrc,
|
||||
"-linkoffline", uri, testSrc,
|
||||
"pkg");
|
||||
|
Loading…
Reference in New Issue
Block a user