3

I'm trying to javadoc code that contains a module-info.java that requires org.apache.logging.log4j;.

I've included the jar from Maven Central that matches the coordinates "org.apache.logging.log4j:log4j-api:2.11.0 (which is a multi-release jar) on the module path.

javac compiles the code fine, but the following simplified javadoc command outputs an error:

javadoc --module-path ./log4j-api-2.11.0.jar -d ~/Desktop ./src/main/java/module-info.java

Error:

error: module not found: org.apache.logging.log4j requires org.apache.logging.log4j;

When I manually repackaged log4j-api-2.11.0.jar as a non-multi-release jar, the javadoc worked (the simplified command above outputs an error about No public or protected classes found to document, but my real command works, and that error shows that the simplified command has progressed past the module not found error).

Does javadoc (from Oracle JDK 10.0.2+13) not support multi-release jars on the module-path?

Or is there something wrong with log4j-api-2.11.0.jar that can be fixed while still maintaining it as a multi-release jar?

Naman
  • 27,789
  • 26
  • 218
  • 353
XDR
  • 4,070
  • 3
  • 30
  • 54
  • A little confusion, what is your real command versus simplified command in the question? Would be even better to see the real command along with the javac command used to compile the code. – Naman Jul 26 '18 at 01:15
  • It had more Java source files & additional (non-multi-release) jars on the module path. All the modules from the other jars were properly found by javadoc. – XDR Jul 26 '18 at 01:17
  • I guess the actual question must include, **How does one generate javadoc for `module-info.java`?**, I fail to understand how does one solve *No public or protected classes found to document* for the module descriptor as well. And that's what I would search further for if there exists a solution. – Naman Jul 26 '18 at 05:13
  • The second problem goes away when I actually include other source files in the javadoc arguments. I just didn’t want to write a really long command line on SO, so I left them out. Someone from log4j confirmed that javadoc doesn’t work with their jar, so they’ve filed a bug report with Oracle https://issues.apache.org/jira/plugins/servlet/mobile#issue/LOG4J2-2393/comment/16556420 – XDR Jul 26 '18 at 05:20
  • 1
    Maybe Oracle will point out some flaw in the log4j multi-release jar, but, given that it works with javac, it’s more likely that javadoc is just buggy. – XDR Jul 26 '18 at 05:24
  • Yeah, was giving it a try with default IDE (IntelliJ) Javadoc generation and seems like there is definitely something incorrect with `javadoc` when the `module-info` resides within the *META-INF/*...from the link, the current solution would be to fall back to **log4j-api-2.10.0.jar** which is also a multi-release jar though. Hopefully you are not using anything specific to the release 2.11.0 in that case though. – Naman Jul 26 '18 at 05:25
  • I don’t need to generate javadocs myself. I’m modifying the Gradle experimental-jigsaw plugin to work more correctly for additional tasks, source sets, etc. I got this error when testing. I just wanted to ensure that my command-line options were not at fault, or possibly easily fix the error so I could help log4j improve their jar. This error isn’t a blocker for me (as long as it wasn’t my code’s fault); it just prevents me from testing javadoc on certain inputs. – XDR Jul 26 '18 at 05:35

2 Answers2

1

This is a a bug in the Javadoc tool and has been reported to Oracle. See https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8208269.

rgoers
  • 8,696
  • 1
  • 22
  • 24
  • The bug has been fixed, but only in Java 12. So at the time of writing it still doesn't work in the latest LTS release. – Frettman Jun 26 '19 at 13:27
0

As pointed out by you in the comments, this seems to be an issue with javadoc tool when the module-info.class resides in the META-INF/versions/9 .

Looking at the 2.11.0 release notes, the core doesn't have much implementation changes, and one can make use of the org.apache.logging.log4j:log4j-api:2.10.0 to stay on the multi-release jar of log4j-api and get it working with javadoc tool to generate the documents.

I can confirm the above works both with IDE(IntelliJ) and command line.

Nicolai Parlog
  • 47,972
  • 24
  • 125
  • 255
Naman
  • 27,789
  • 26
  • 218
  • 353