Please review a simple fix that JavaDoc fails when asked to just generate 
documentation for an aggegator module, or for any module that contains no 
classes or interfaces to be documented, such as a service-provider module.

The problem is the long-standing check for `no public or protected classes 
found to document`.  While that check does have an exception for "empty" 
modules, such modules are not taken into account when specified as a 
`module-info.java` file on the command line. (The workaround is to specify the 
source path and use the `--module` option.)

The fundamental part of the fix is in `ElementsTable.scanSpecifiedItems`, where 
code is added to scan any compilation units read from files specified on the 
command line, detect any module declarations, and add any corresponding module 
names to the list of `specifiedModuleElements`.

A secondary part of the fix is purely cosmetic. The misleadingly-named 
`classTrees` and `classTreeList` are renamed to `compilationUnits` and 
`compilationUnitList` to better reflect their broader use, including the 
possibility of containing a module compilation unit.

A new test is added, in two variants.

1. The first variant is a regular call of `JavadocTester.javadoc`. In this 
call, the source path has to be set explicitly, to avoid the default setting of 
the source path performed by the `javadoc` method.

2. The second variant used `toolbox.JavadocTask` to avoid setting the source 
path in any way, thus better mimicking the initial test case of `javadoc -d 
path/to/api path/to/src/module-info.java`

Both variants pass, but then trigger a downstream error of a circularity in the 
redirection in the generated `index.html` file. That issue is addressed 
separately, in [JDK-8322874](https://bugs.openjdk.org/browse/JDK-8322874)

-------------

Commit messages:
 - Fix comment intro
 - JDK-8322865: JavaDoc fails on aggregator modules

Changes: https://git.openjdk.org/jdk/pull/17272/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17272&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8322865
  Stats: 130 lines in 3 files changed: 119 ins; 1 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/17272.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17272/head:pull/17272

PR: https://git.openjdk.org/jdk/pull/17272

Reply via email to