[ https://issues.apache.org/jira/browse/MCOMPILER-481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17480228#comment-17480228 ]
Simone Bordet edited comment on MCOMPILER-481 at 1/21/22, 6:47 PM: ------------------------------------------------------------------- There was a reply in the compiler-dev thread. IIUC, when the {{compiler.bug.service}} module is imported as a dependency, it does not import (because it's a {{requires static}}) the {{jetty-util-ajax}} jar. So when compiling the module {{compiler.bug.app,}} the "app" module sees the {{JSON}} class because of {{--add-reads compiler.bug.app=ALL-UNNAMED}}, but the "service" module still does not see it because it's not in the module-path and neither there is an {{--add-reads}} for the "service" module. So it seems a legit Maven Compiler Plugin issue/ feature that needs to be supported. In light of this information, is my algorithm or [~rfscholte]'s algorithm the right solution? was (Author: sbordet): There was a reply in the compiler-dev thread. IIUC, when the {{compiler.bug.service}} module is imported as a dependency, it does not import (because it's a {{requires static}}) the {{jetty-util-ajax}} jar. So when compiling the module {{compiler.bug.app,}} the "app" module sees the {{JSON}} class because of {{--add-reads compiler.bug.app=ALL-UNNAMED }}, but the "service" module still does not see it because it's not in the module-path and neither there is an {{--add-reads}} for the "service" module. So it seems a legit Maven Compiler Plugin issue/ feature that needs to be supported. In light of this information, is my algorithm or [~rfscholte]'s algorithm the right solution? > JPMS Regression: cannot access <class> (requires static module not include > anymore) > ----------------------------------------------------------------------------------- > > 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 > Assignee: Olivier Lamy > Priority: Major > Fix For: 3.9.1 > > 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)