8246705: javadoc gives "misleading" and incomplete warning message

Reviewed-by: hannesw
This commit is contained in:
Jonathan Gibbons 2020-06-09 19:50:30 -07:00
parent 56abdc178e
commit 0652a7883d
4 changed files with 17 additions and 11 deletions
src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool
test/langtools/jdk/javadoc/tool/modules

@ -566,7 +566,10 @@ public class ElementsTable {
continue;
if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
if (!haveModuleSources(dep)) {
messager.printWarning(dep, "main.module_not_found", dep.getSimpleName());
if (!warnedNoSources.contains(dep)) {
messager.printWarning(dep, "main.module_source_not_found", dep.getQualifiedName());
warnedNoSources.add(dep);
}
}
result.add(dep);
} else if (isMandated(mdle, rd) && haveModuleSources(dep)) {
@ -580,9 +583,11 @@ public class ElementsTable {
return toolEnv.elements.getOrigin(mdle, rd) == MANDATED;
}
Set<ModuleElement> warnedNoSources = new HashSet<>();
Map<ModuleSymbol, Boolean> haveModuleSourcesCache = new HashMap<>();
private boolean haveModuleSources(ModuleElement mdle) throws ToolException {
ModuleSymbol msym = (ModuleSymbol)mdle;
ModuleSymbol msym = (ModuleSymbol) mdle;
if (msym.sourceLocation != null) {
return true;
}
@ -620,7 +625,7 @@ public class ElementsTable {
if (expandAll) {
// add non-public requires if needed
result.addAll(getModuleRequires(mdle, !expandAll));
result.addAll(getModuleRequires(mdle, false));
}
}

@ -269,7 +269,8 @@ main.unnecessary_arg_provided=option {0} does not require an argument
main.only_one_argument_with_equals=cannot use ''='' syntax for options that require multiple arguments
main.invalid_flag=invalid flag: {0}
main.No_modules_packages_or_classes_specified=No modules, packages or classes specified.
main.module_not_found=module {0} not found.\n
main.module_not_found=module {0} not found
main.module_source_not_found=source files for module {0} not found
main.cannot_use_sourcepath_for_modules=cannot use source path for multiple modules {0}
main.module_not_found_on_sourcepath=module {0} not found on source path
main.sourcepath_does_not_contain_module=source path does not contain module {0}

@ -23,7 +23,7 @@
/*
* @test
* @bug 8176481
* @bug 8176481 8246705
* @summary Tests behavior of the tool, when modules are present as
* binaries.
* @modules
@ -60,7 +60,7 @@ public class MissingSourceModules extends ModuleTestBase {
execNegativeTask("--module-path", modulePath.toString(),
"--module", "ma");
assertMessagePresent("module ma not found.");
assertMessagePresent("module ma not found");
}
@Test
@ -77,11 +77,11 @@ public class MissingSourceModules extends ModuleTestBase {
Path mPath = Paths.get(modulePath.toString(), "ma");
execNegativeTask("--source-path", mPath.toString(),
"--module", "ma");
assertMessagePresent("module ma not found.");
assertMessagePresent("module ma not found on source path");
execNegativeTask("--class-path", mPath.toString(),
"--module", "ma");
assertMessagePresent("module ma not found.");
assertMessagePresent("module ma not found");
}
@Test
@ -106,7 +106,7 @@ public class MissingSourceModules extends ModuleTestBase {
"--module-source-path", src.toString(),
"--expand-requires", "all",
"--module", "ma");
assertMessagePresent("module mb not found.");
assertMessagePresent("source files for module mb not found");
}
@Test
@ -131,6 +131,6 @@ public class MissingSourceModules extends ModuleTestBase {
"--module-source-path", src.toString(),
"--expand-requires", "transitive",
"--module", "ma");
assertMessagePresent("module mb not found.");
assertMessagePresent("source files for module mb not found");
}
}

@ -534,7 +534,7 @@ public class Modules extends ModuleTestBase {
"--module", "MIA",
"--expand-requires", "all");
assertMessagePresent("javadoc: error - module MIA not found.");
assertMessagePresent("javadoc: error - module MIA not found");
}
@Test