Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8250954: Avoid multiple warnings for external docs with mismatching m…
…odularity

Reviewed-by: jjg
  • Loading branch information
hns committed Aug 11, 2020
1 parent 1076f6f commit d7b6bc713172aca2cceb4d9c66ae8c96e11d94a9
Showing 1 changed file with 7 additions and 4 deletions.
@@ -384,6 +384,7 @@ private void readElementList(InputStream input, String path, boolean relative)
DocPath elempath;
String moduleName = null;
DocPath basePath = DocPath.create(path);
boolean issueWarning = true;
while ((elemname = in.readLine()) != null) {
if (elemname.length() > 0) {
elempath = basePath;
@@ -398,10 +399,11 @@ private void readElementList(InputStream input, String path, boolean relative)
} else {
elempath = elempath.resolve(pkgPath);
}
String actualModuleName = checkLinkCompatibility(elemname, moduleName, path);
String actualModuleName = checkLinkCompatibility(elemname, moduleName, path, issueWarning);
Item item = new Item(elemname, elempath, relative);
packageItems.computeIfAbsent(actualModuleName, k -> new TreeMap<>())
.putIfAbsent(elemname, item); // first-one-wins semantics
issueWarning = false;
}
}
}
@@ -416,22 +418,23 @@ private void readElementList(InputStream input, String path, boolean relative)
* @param packageName the package name
* @param moduleName the module name or null
* @param path the documentation path
* @param issueWarning whether to print a warning in case of modularity mismatch
* @return the module name to use according to actual modularity of the package
*/
private String checkLinkCompatibility(String packageName, String moduleName, String path) {
private String checkLinkCompatibility(String packageName, String moduleName, String path, boolean issueWarning) {
PackageElement pe = utils.elementUtils.getPackageElement(packageName);
if (pe != null) {
ModuleElement me = (ModuleElement)pe.getEnclosingElement();
if (me == null || me.isUnnamed()) {
if (moduleName != null) {
if (moduleName != null && issueWarning) {
configuration.getReporter().print(Kind.WARNING,
resources.getText("doclet.linkMismatch_PackagedLinkedtoModule", path));
}
// library is not modular, ignore module name even if documentation is modular
return DocletConstants.DEFAULT_ELEMENT_NAME;
} else if (moduleName == null) {
// suppress the warning message in the case of automatic modules
if (!isAutomaticModule(me)) {
if (!isAutomaticModule(me) && issueWarning) {
configuration.getReporter().print(Kind.WARNING,
resources.getText("doclet.linkMismatch_ModuleLinkedtoPackage", path));
}

0 comments on commit d7b6bc7

Please sign in to comment.