[ 
https://issues.apache.org/jira/browse/MJAVADOC-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17757065#comment-17757065
 ] 

Henning Schmiedehausen commented on MJAVADOC-769:
-------------------------------------------------

having spent some more time debugging this, this is what happens:

- the code depends on com.google.inject.Provider, which in turn extends 
javax.inject.Provider
- the google class is in a jar (guice-5.1.0.jar) which has an 
Automatic-Module-Name entry
- the javax class is in a jar that does not.

The plugin now pulls the guice jar onto the module path and patches the main 
module with the javax.inject jar

But the javadoc plugin tries to resolve the class hierarchy of the included 
provider, which is the google guice provider (on the module path) and then the 
javax provider (patched into the main module, BUT NOT into guice). and the 
javadoc tool can not resolve the javax.inject class as parent for guice because 
it is not visible in that module.

The solution is IMHO straightforward: instead of treating jars with a module 
source of MANIFEST the same way as jars with a module source of 
MODULEDESCRIPTOR and different from module source FILENAME, they should be 
treated the same was as module source FILENAME (iaw patched into the main 
module).

> javadoc plugin can not deal with optional dependencies when building java 9+ 
> javadocs
> -------------------------------------------------------------------------------------
>
>                 Key: MJAVADOC-769
>                 URL: https://issues.apache.org/jira/browse/MJAVADOC-769
>             Project: Maven Javadoc Plugin
>          Issue Type: Bug
>          Components: javadoc
>    Affects Versions: 3.5.0
>            Reporter: Henning Schmiedehausen
>            Priority: Major
>
> clone this repository: https://github.com/hgschmie/mjavadoc769
> This builds an artifact, a tests artifact and a javadoc jar. 
> When building this for Java 9+ compatibility (javadoc generate a list of 
> modules) and using modules with Automatic-Module-Name enabled, the javadoc 
> plugin can not access the optional dependencies:
> {code}
> ERROR] Exit code: 1
> [ERROR] 
> /Users/henning/scratch/mjavadoc769/src/main/java/mavenbugs/mjavadoc769/InternalImportBindingBuilder.java:88:
>  error: cannot access Provider
> [ERROR]     static final class InternalBindingProvider<T> implements 
> Provider<T> {
> [ERROR]                  ^
> [ERROR]   class file for javax.inject.Provider not found
> [ERROR] 1 error
> [ERROR] Command line was: 
> /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/javadoc 
> -J-Xmx1024m @options @packages
> {code}
> Note that all other plugins (compiler, surefire) work fine. Just the javadoc 
> plugin does not.
> {code}
> --add-modules
> ALL-MODULE-PATH
> --module-path
> '/Users/henning/.m2/repository/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar:/Users/henning/.m2/repository/jakarta/inject/jakarta.inject-api/2.0.1.MR/jakarta.inject-api-2.0.1.MR.jar:/Users/henning/.m2/repository/com/google/inject/guice/5.1.0/guice-5.1.0.jar:/Users/henning/.m2/repository/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar:/Users/henning/.m2/repository/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar:/Users/henning/scratch/mjavadoc769/target/mjavadoc769-1.0-SNAPSHOT.jar'
> --patch-module
> mavenbugs.mjavadoc769='/Users/henning/scratch/mjavadoc769/src/main/java:/Users/henning/scratch/mjavadoc769/target/generated-sources/annotations:/Users/henning/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/henning/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/Users/henning/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/henning/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/henning/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:/Users/henning/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar'
> -encoding
> 'UTF-8'
> -public
> -quiet
> --release
> 11
> -bottom
> 'Copyright &#169; 2023. All rights reserved.'
> -charset
> 'UTF-8'
> -d
> '/Users/henning/scratch/mjavadoc769/target/apidocs'
> -docencoding
> 'UTF-8'
> -Xdoclint:none
> -doctitle
> 'mjavadoc769 1.0-SNAPSHOT API'
> -linkoffline
> 'https://docs.oracle.com/en/java/javase/11/docs/api' 
> '/Users/henning/scratch/mjavadoc769/target/javadoc-bundle-options'
> -nohelp
> -use
> -version
> -windowtitle
> 'mjavadoc769 1.0-SNAPSHOT API'
> {code}
> The javadoc plugin decides that the "javax.inject-1.jar" is added to the 
> classpath even though it is an optional dependency of the main module. 
> Contrary to this, the jakarta.inject-api-2.0.1.MR.jar is added to the module 
> path.
> The reason for this may be that the jakarta module contains a module-info 
> (hidden in META-INF/versions/9/) while the javax.inject jar does not.
> However, the checker-qual 
> (org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar) dependency 
> is put on the module path even though it does not contain a module-info file. 
> However, it contains an {{Automatic-Module-Name}} entry in META-INF/MANIFEST.
> It seems that the javadoc plugin treats automatic dependencies with entry in 
> the manifest different from automatic dependencies determined by filename. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to