You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Simone Bordet (Jira)" <ji...@apache.org> on 2022/01/17 21:59:00 UTC

[jira] [Comment Edited] (MCOMPILER-481) JPMS Regression: cannot access

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

Simone Bordet edited comment on MCOMPILER-481 at 1/17/22, 9:58 PM:
-------------------------------------------------------------------

The setup is that module "app" depends on module "service".

Module "service" has an interface and a default implementation that depends optionally (requires static) on the JSON class (present in the jetty-util-ajax-10.0.7.jar).

Module "app" wants to perform some test, so it has to bind to an implementation (only for the tests – the source still depends only on the interface declared in module "service").

I would have expected that putting jetty-util-ajax-10.0.7.jar in the classpath with --patch-module and --add-reads compiler.bug.app=ALL-UNNAMED would be enough, but apparently it is not, so this may well be a javac compiler bug?

The only alternative I see is to keep track of requires static dependencies, and if a Maven module declares them as a dependency in the POM, then it gets added to the module-path?

[~rfscholte], [~olamy], [~sor] any idea?

Thanks!


was (Author: sbordet):
The setup is that module "app" depends on module "service".

Module "service" has an interface and a default implementation that depends optionally (requires static) on the JSON class (present in the jetty-util-ajax-10.0.7.jar).

Model "app" wants to perform some test, so it has to bind to an implementation (only for the tests – the source still depends only on the interface declared in module "service").

I would have expected that putting jetty-util-ajax-10.0.7.jar in the classpath with --patch-module and --add-reads compiler.bug.app=ALL-UNNAMED would be enough, but apparently it is not, so this may well be a javac compiler bug?

The only alternative I see is to keep track of requires static dependencies, and if a Maven module declares them as a dependency in the POM, then it gets added to the module-path?

[~rfscholte], [~olamy], [~sor] any idea?

Thanks!

> JPMS Regression: cannot access <class>
> --------------------------------------
>
>                 Key: MCOMPILER-481
>                 URL: https://issues.apache.org/jira/browse/MCOMPILER-481
>             Project: Maven Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 3.9.0
>            Reporter: Simone Bordet
>            Priority: Major
>         Attachments: compiler-bug.tar.gz
>
>
> Version 3.8.1 is not affected.
> The problem lies in how the module-path is constructed by the maven-compiler-plugin – not sure what changes from 3.8.1 caused this.
> In 3.8.1:
> {code:java}
> -d
>   /home/simon/tmp/compiler-bug/app/target/test-classes
> -classpath
>   /home/simon/tmp/compiler-bug/app/target/test-classes
>   /home/simon/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.8.2/junit-jupiter-api-5.8.2.jar
>   /home/simon/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
>   /home/simon/.m2/repository/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2.jar
>   /home/simon/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar
>   
> --module-path
>   /home/simon/tmp/compiler-bug/app/target/classes
>   /home/simon/.m2/repository/org/example/compiler-bug-service/1.0-SNAPSHOT/compiler-bug-service-1.0-SNAPSHOT.jar
>   /home/simon/.m2/repository/org/eclipse/jetty/jetty-util-ajax/10.0.7/jetty-util-ajax-10.0.7.jar
>   /home/simon/.m2/repository/org/eclipse/jetty/jetty-util/10.0.7/jetty-util-10.0.7.jar
>   /home/simon/.m2/repository/org/slf4j/slf4j-api/2.0.0-alpha5/slf4j-api-2.0.0-alpha5.jar
>   
> -sourcepath
>   /home/simon/tmp/compiler-bug/app/src/test/java
>   /home/simon/tmp/compiler-bug/app/target/generated-test-sources/test-annotations
>   
> -s
>   /home/simon/tmp/compiler-bug/app/target/generated-test-sources/test-annotations
> -g
> -nowarn
> --release
>   11
> -encoding
>   UTF-8
> --patch-module
>   compiler.bug.app=/home/simon/tmp/compiler-bug/app/target/classes
>   /home/simon/tmp/compiler-bug/app/src/test/java
>   /home/simon/tmp/compiler-bug/app/target/generated-test-sources/test-annotations
>   
> --add-reads
>   compiler.bug.app=ALL-UNNAMED {code}
> In 3.9.0:
> {code:java}
> -d
>   /home/simon/tmp/compiler-bug/app/target/test-classes
> -classpath
>   /home/simon/tmp/compiler-bug/app/target/test-classes
>   /home/simon/.m2/repository/org/eclipse/jetty/jetty-util-ajax/10.0.7/jetty-util-ajax-10.0.7.jar
>   /home/simon/.m2/repository/org/eclipse/jetty/jetty-util/10.0.7/jetty-util-10.0.7.jar
>   /home/simon/.m2/repository/org/slf4j/slf4j-api/2.0.0-alpha5/slf4j-api-2.0.0-alpha5.jar
>   /home/simon/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.8.2/junit-jupiter-api-5.8.2.jar
>   /home/simon/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar
>   /home/simon/.m2/repository/org/junit/platform/junit-platform-commons/1.8.2/junit-platform-commons-1.8.2.jar
>   /home/simon/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar
>   
> --module-path
>   /home/simon/tmp/compiler-bug/app/target/classes
>   /home/simon/.m2/repository/org/example/compiler-bug-service/1.0-SNAPSHOT/compiler-bug-service-1.0-SNAPSHOT.jar
>   
> -sourcepath
>   /home/simon/tmp/compiler-bug/app/src/test/java
>   /home/simon/tmp/compiler-bug/app/target/generated-test-sources/test-annotations
>   
> -s
>   /home/simon/tmp/compiler-bug/app/target/generated-test-sources/test-annotations
> -g
> -nowarn
> --release
>   11
> -encoding
>   UTF-8
> --patch-module
>   compiler.bug.app=/home/simon/tmp/compiler-bug/app/target/classes
>   /home/simon/tmp/compiler-bug/app/src/test/java
>   /home/simon/tmp/compiler-bug/app/target/generated-test-sources/test-annotations
>   
> --add-reads
>   compiler.bug.app=ALL-UNNAMED {code}
> Running with 3.9.0 yields:
> {code:java}
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.9.0:testCompile (default-testCompile) on project compiler-bug-app: Compilation failure
> [ERROR] /home/simon/tmp/compiler-bug/app/src/test/java/org/test/app/MainTest.java:[12,38] cannot access org.eclipse.jetty.util.ajax.JSON
> [ERROR]   class file for org.eclipse.jetty.util.ajax.JSON not found {code}
> Class {{JSON}} is in {{{}jetty-util-10.0.7.jar{}}}.
> In 3.9.0 this jar is missing from the module-path, causing the error.
> Attached you can find a reproducer: switch the maven-compiler-plugin version from 3.8.1 (works) to 3.9.0 (does not work) in the main POM.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)