You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tibor Digana (Jira)" <ji...@apache.org> on 2019/12/08 12:46:00 UTC

[jira] [Closed] (SUREFIRE-1667) Crash with JPMS "requires static"

     [ https://issues.apache.org/jira/browse/SUREFIRE-1667?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tibor Digana closed SUREFIRE-1667.
----------------------------------
      Assignee: Tibor Digana
    Resolution: Duplicate

> Crash with JPMS "requires static"
> ---------------------------------
>
>                 Key: SUREFIRE-1667
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1667
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 3.0.0-M3
>            Reporter: Simone Bordet
>            Assignee: Tibor Digana
>            Priority: Major
>         Attachments: surefire-jpms-issue.tgz
>
>
> The attached project has JPMS modules where:
> {{moduleA}} requires {{moduleB}}
> {{moduleB}} requires static {{moduleC}}.
> Furthermore, {{moduleA}} tests require {{moduleC}}.
> Running the attached project ends up with the following test failure:
> {code}
> [ERROR] test(org.cometd.a.ATest) Time elapsed: 0.01 s <<< ERROR!
> java.lang.NoClassDefFoundError: org/cometd/c/C
>  at moduleA@1.0.0-SNAPSHOT/org.cometd.a.ATest.test(ATest.java:15)
> {code}
> The reason is that {{plexus-java}} creates a wrong module-path and class-path because it does not take into account the {{static}} modified in the JPMS directive {{requires static <module>}}.
> For the attached project, running {{moduleA}} tests generates this (simplified):
> {code}
> --module-path
> moduleA/target/classes:
> moduleB-1.0.0-SNAPSHOT.jar:
> moduleC-1.0.0-SNAPSHOT.jar
> --class-path
> surefire-booter-3.0.0-M3.jar:
> surefire-api-3.0.0-M3.jar:
> surefire-logger-api-3.0.0-M3.jar:
> junit-4.12.jar:
> hamcrest-core-1.3.jar:
> surefire-junit4-3.0.0-M3.jar:
> common-java5-3.0.0-M3.jar:
> common-junit3-3.0.0-M3.jar:
> common-junit4-3.0.0-M3.jar"
> --patch-module
> moduleA=moduleA/target/test-classes
> --add-exports
> moduleA/org.cometd.a=ALL-UNNAMED
> --add-modules
> moduleA
> --add-reads
> moduleA=ALL-UNNAMED
> {code}
> However, {{moduleC}} should be in the class-path, not in the module-path, as it is only required for testing.
> It is in the module-path because it is pulled in as a transitive dependency from {{moduleB}}, without taking into account that it is a {{requires static}}.
> Correct behavior should be IMHO that {{moduleC}} is not in the module-path but rather in the class-path, respecting the semantic of JPMS {{requires static}}.
> The workaround is to configure the Maven Surefire Plugin with {{--add-module moduleC}}, but that is incorrect.
> The relevant {{plexus-languages/plexus-java}} code that builds the module-path and the class-path is in {{LocationManager.resolvePaths()}}. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)