ADDITIONAL SYSTEM INFORMATION :
Windows 10, Java 11.0.2 and Java 12
A DESCRIPTION OF THE PROBLEM :
On generating JavaDoc for Java modules that require a dependency bundled as multi-release archive, such as slf4j-api, the generation of the JavaDoc fails due to "error: module not found: org.slf4j"
A lookup of the internal of the slf4j-api library via
jar -tf mods\slf4j-api-1.8.0-beta4.jar
reveals the following content of the org.slf4j archive:
META-INF/
META-INF/MANIFEST.MF
META-INF/versions/
META-INF/versions/9/
org/
org/slf4j/
org/slf4j/event/
org/slf4j/helpers/
org/slf4j/spi/
META-INF/versions/9/module-info.class
org/slf4j/event/EventConstants.class
org/slf4j/event/EventRecodingLogger.class
org/slf4j/event/Level.class
org/slf4j/event/LoggingEvent.class
org/slf4j/event/SubstituteLoggingEvent.class
org/slf4j/helpers/BasicMarker.class
org/slf4j/helpers/BasicMarkerFactory.class
org/slf4j/helpers/BasicMDCAdapter$1.class
org/slf4j/helpers/BasicMDCAdapter.class
org/slf4j/helpers/FormattingTuple.class
org/slf4j/helpers/MarkerIgnoringBase.class
org/slf4j/helpers/MessageFormatter.class
org/slf4j/helpers/NamedLoggerBase.class
org/slf4j/helpers/NOPLogger.class
org/slf4j/helpers/NOPLoggerFactory.class
org/slf4j/helpers/NOPMDCAdapter.class
org/slf4j/helpers/NOPServiceProvider.class
org/slf4j/helpers/SubstituteLogger.class
org/slf4j/helpers/SubstituteLoggerFactory.class
org/slf4j/helpers/SubstituteServiceProvider.class
org/slf4j/helpers/Util$1.class
org/slf4j/helpers/Util$ClassContextSecurityManager.class
org/slf4j/helpers/Util.class
org/slf4j/ILoggerFactory.class
org/slf4j/IMarkerFactory.class
org/slf4j/Logger.class
org/slf4j/LoggerFactory.class
org/slf4j/LoggerFactoryFriend.class
org/slf4j/Marker.class
org/slf4j/MarkerFactory.class
org/slf4j/MDC$1.class
org/slf4j/MDC$MDCCloseable.class
org/slf4j/MDC.class
org/slf4j/spi/LocationAwareLogger.class
org/slf4j/spi/LoggerFactoryBinder.class
org/slf4j/spi/MarkerFactoryBinder.class
org/slf4j/spi/MDCAdapter.class
org/slf4j/spi/SLF4JServiceProvider.class
META-INF/maven/
META-INF/maven/org.slf4j/
META-INF/maven/org.slf4j/slf4j-api/
META-INF/maven/org.slf4j/slf4j-api/pom.xml
META-INF/maven/org.slf4j/slf4j-api/pom.properties
Via
java --module-path mods --describe-module org.slf4j
I also see the module configuration of that library:
exports org.slf4j
exports org.slf4j.event
exports org.slf4j.helpers
exports org.slf4j.spi
requires java.base mandated
uses org.slf4j.spi.SLF4JServiceProvider
which is identical to what I get if I enter
jar -f mods\slf4j-api-1.8.0-beta4.jar --describe-module --release 9
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Have a module configuration such as:
module javadoc.test {
requires java.base;
requires org.slf4j;
exports com.acme;
}
and attempt to generate Javadocs for that module via the following commands:
# Generate the initial directory structure
mkdir src\main\java
mkdir mods
# Copy slf4j-api-1.8.0-beta4.jar to mods
# Compile the classes
javac --module-path mods -d target/classes src/main/java/com/acme/Test.java src/main/java/com/acme/package-info.java src/main/java/module-info.java
# Make a Java module-archive
jar --create --module-path mods --file mods/acme-test-1.0-SNAPSHOT.jar --main-class=com.acme.Test -C target/classes .
# Create the JavaDoc
javadoc --source-path src/main/java --module-path mods -d apidoc -package src/main/java/com/acme/Test.java src/main/java/com/acme/package-info.java src/main/java/module-info.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JavaDoc is generated successfully (as if the "requires org.slf4j;" line is commented out in the given example)
ACTUAL -
Loading source file src\main\java\com\acme\Test.java...
Loading source file src\main\java\com\acme\package-info.java...
Loading source file src\main\java\module-info.java...
src\main\java\module-info.java:3: error: module not found: org.slf4j
requires org.slf4j;
^
1 error
---------- BEGIN SOURCE ----------
------------------------------------------
--- src/main/java/module-info.java
------------------------------------------
module com.acme.test {
requires java.base;
requires org.slf4j;
}
------------------------------------------
--- src/main/java/com/acme/package-info.java
------------------------------------------
/**
* Base classes used to initialize the application.
*/
package com.acme;
------------------------------------------
--- src/main/java/com/acme/Test.java
------------------------------------------
package com.acme;
/**
* Test class to reproduce the Javadoc generation issue
*/
public class Test {
/**
* Application initialization method
*
* @param args application startup parameters
*/
public static void main(String... args) {
System.out.println("Hello World!");
}
}
---------- END SOURCE ----------
FREQUENCY : always