[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2024-06-08 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17853400#comment-17853400
 ] 

ASF GitHub Bot commented on SUREFIRE-1909:
--

michael-o commented on PR #461:
URL: https://github.com/apache/maven-surefire/pull/461#issuecomment-2156098250

   Code has been merged and issue fixed.




> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Assignee: Tibor Digana
>Priority: Major
> Fix For: 2.22.3, 3.0.0-M6
>
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2024-06-08 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17853399#comment-17853399
 ] 

ASF GitHub Bot commented on SUREFIRE-1909:
--

michael-o closed pull request #461: [SUREFIRE-1909] Replace --add-exports with 
--add-opens
URL: https://github.com/apache/maven-surefire/pull/461




> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Assignee: Tibor Digana
>Priority: Major
> Fix For: 2.22.3, 3.0.0-M6
>
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-17 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17494200#comment-17494200
 ] 

Tibor Digana commented on SUREFIRE-1909:


https://gitbox.apache.org/repos/asf?p=maven-surefire.git;a=commit;h=deee5171afe7da953ad4af8e93050b2c7963dc1f

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Assignee: Tibor Digana
>Priority: Major
> Fix For: 2.22.3, 3.0.0-M6
>
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-08 Thread Nils Renaud (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17489041#comment-17489041
 ] 

Nils Renaud commented on SUREFIRE-1909:
---

I've created a PR for a drop in replacement of {{--add-exports}} in favor of 
{{--add-opens}} just to be sure nothing breaks on the CI.

I will try to add this as an optional configuration later on.

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-08 Thread Christian Stein (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17488968#comment-17488968
 ] 

Christian Stein commented on SUREFIRE-1909:
---

Users, project authors, testers and dev folks ... should be in control what 
happens at [test-]compile and [test-]runtime.

So, as I see it, changing from `--add-exports` to `--add-opens` might help in 
this case; but also break other use-cases where `--add-exports` was the desired 
flag. Perhaps, make it configurable?

(Note: I wrote about an article on how to tackle this "command-line tools vs 
build tools vs IDE issues" here: 
[https://sormuras.github.io/blog/2018-09-11-testing-in-the-modular-world] – it 
also includes an alternative test plugin that keeps you in control.)

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-08 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17488956#comment-17488956
 ] 

Tibor Digana commented on SUREFIRE-1909:


[~nilsR] 

 If you are talking about package visibility, you are probably talking about 
your files module-info.java.
But what [~c...@newsclub.de] was talking about was different thing. He was 
talking about this args file content and it is no PMD harmful if we add opens 
of your packages to Surefire packages instead of add-exports:


{noformat}
[DEBUG] args file content:
--module-path
"workspace/surefire-jpms-bug/target/classes"
--class-path
".m2/repository/org/apache/maven/surefire/surefire-booter/3.0.0-M5/surefire-booter-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/surefire-api/3.0.0-M5/surefire-api-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/surefire-logger-api/3.0.0-M5/surefire-logger-api-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/surefire-shared-utils/3.0.0-M4/surefire-shared-utils-3.0.0-M4.jar:.m2/repository/org/apache/maven/surefire/surefire-extensions-spi/3.0.0-M5/surefire-extensions-spi-3.0.0-M5.jar:workspace/surefire-jpms-bug/target/test-classes:.m2/repository/org/junit/jupiter/junit-jupiter/5.7.1/junit-jupiter-5.7.1.jar:.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.1/junit-jupiter-api-5.7.1.jar:.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar:.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:.m2/repository/org/junit/platform/junit-platform-commons/1.7.1/junit-platform-commons-1.7.1.jar:.m2/repository/org/junit/jupiter/junit-jupiter-params/5.7.1/junit-jupiter-params-5.7.1.jar:.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.1/junit-jupiter-engine-5.7.1.jar:.m2/repository/org/junit/platform/junit-platform-engine/1.7.1/junit-platform-engine-1.7.1.jar:.m2/repository/org/apache/maven/surefire/surefire-junit-platform/3.0.0-M5/surefire-junit-platform-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/common-java5/3.0.0-M5/common-java5-3.0.0-M5.jar:.m2/repository/org/junit/platform/junit-platform-launcher/1.7.1/junit-platform-launcher-1.7.1.jar"
--patch-module
surefire.jpms.bug="workspace/surefire-jpms-bug/target/test-classes"
--add-exports
surefire.jpms.bug/surefire.test=ALL-UNNAMED
--add-modules
surefire.jpms.bug
--add-reads
surefire.jpms.bug=ALL-UNNAMED
org.apache.maven.surefire.booter.ForkedBooter
{noformat}

If is use as followinf {{java @args}}.

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-08 Thread Robert Scholte (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17488935#comment-17488935
 ] 

Robert Scholte commented on SUREFIRE-1909:
--

[~sor] is the test+jpms expert

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-08 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17488922#comment-17488922
 ] 

Tibor Digana commented on SUREFIRE-1909:


[~rfscholte]
Can you please make an advice or confirm the change from 
{noformat}
--add-exports
{noformat}
to
{noformat}
--add-opens
{noformat}
 as it is mentioned in the 
[comment|https://issues.apache.org/jira/browse/SUREFIRE-1909?focusedCommentId=17366928=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17366928]?

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-08 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17488918#comment-17488918
 ] 

Tibor Digana commented on SUREFIRE-1909:


[~c...@newsclub.de] 
[~nilsR] 
Feel free to provide a PR on Github.
We already have some integration tests, so we should see the result of the 
tests on GH.
The change is relatively easy, you can see the target for your change in the 
class {{ModularClasspathForkConfiguration}}.

 

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2022-02-08 Thread Nils Renaud (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17488891#comment-17488891
 ] 

Nils Renaud commented on SUREFIRE-1909:
---

Hi there,



I'm currently having the same issue as [~c...@newsclub.de] trying to modularise 
my existing application.

Currently all proposed solutions are not good enough to my requirements : 
 - ["official surefire 
solution"|https://maven.apache.org/surefire/maven-surefire-plugin/examples/jpms.html]
 to have unit tests in a dedicated JPMS module requiring the {{my.module.main}} 
module
 -- I can't test "{{{}package private"{}}} methods or classes. {+}I don't want 
to change my code visibility to be able to test it{+}.


 - A variation of this solution could be to set package private classes/methods 
as public and to move them to a package "{{{}exported ... to 
my.module.test{}}}" :
 -- Still +this is really painful with a big codebase+ and introduce a link to 
maintain between main and test modules.


 - To update all Junit test methods visibility to "public" : 
 -- As stated by [~c...@newsclub.de] +this is considered as violation by PMD+ 
and some other static analysis tools. I tend to agree with them and would like 
to follow JUnit 5 standard (plus it's an easy trap, I felt into !)

So I really feel the need to have that handled by the Surefire plugin, have you 
started a PR somewhere [~c...@newsclub.de] ?

Is there any current work on this topic since July 2021 ?

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-07-31 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17391030#comment-17391030
 ] 

Tibor Digana commented on SUREFIRE-1909:


[~c...@newsclub.de]
I am not against to give it a try with "add-opens".
If you would open a pullrequest on Surefire project at GitHub, we will clearly 
see if all the unit and integration tests pass on GH CI.

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-07-30 Thread Jira


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17390844#comment-17390844
 ] 

Christian Kohlschütter commented on SUREFIRE-1909:
--

Ah, maybe that's the misunderstanding: I'm fine with my tests being on the 
classpath / in the unnamed module. I understand in some scenarios, you may want 
to modularize your tests, too (then you'd have to move them to a separate test 
package, though). This is not what I want. I want the test classes in the same 
package as the code under test (like it was practice before JPMS, and which is 
still supported in Eclipse when only the code under src/main/java has a 
module-info.java).

This works out of the box, as long as I keep all methods public. And this 
enabled by the existing {{--add-exports}} statemen in 
ModularClasspathForkConfiguration.java.

My proposed solution would be to change that {{--add-exports}} to 
{{--add-opens}}. "add-opens" is like add-exports plus access to package-level 
protected types and methods, which seems to be a good default when no 
module-info.java was specified for the test code under src/test/java.

Again, it solves the problem at least for me, and I don't see any downsides. 
What am I missing?

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-07-30 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17390481#comment-17390481
 ] 

Tibor Digana commented on SUREFIRE-1909:


[~c...@newsclub.de]
There are two modules.
It is not true that you have one module. Form the JPMS perspective there are 
two, namely, {{src/main/java}} and {{src/test/java}}.
So if you need to maintain tests as a jpms module, you should have module info 
in tests as well. If you do not then the test dependencies would appear in the 
classpath. If you want to have them in module path, you have to write 
module-info.java in src/test/java. We cannot have one module descriptor because 
these two modules are isolated, they must be two and they are different, cannot 
be mixed in one module descriptor. For instance the compiler is using module 
descriptor in src/main/java. I guess the compiler would do similar with module 
descriptor in src/test/java.

I can imaging that we would add a new configuration parameter where you would 
be able to specify file path pointing to your custom module descriptor where 
you can merge both in one. I think you do not have comfort either with this.

We cannot read your brain and we do not know when and what user wants to use 
"add-export" and when not. Therefore you are managing the modulepaths.

If you have a help and a solution for us, I am all the hear.

Maybe we would need to have {{--module-path}} 
"workspace/surefire-jpms-bug/target/classes" + 
"workspace/surefire-jpms-bug/target/test-classes".

Let me know your solution.

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-07-29 Thread Jira


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17390254#comment-17390254
 ] 

Christian Kohlschütter commented on SUREFIRE-1909:
--

As far as I understand, Jigsaw mandates that there can only be _one_ 
module-info.java per package (which makes sense). Unsurprisingly, IDEs like 
Eclipse concur and refuse adding a secondary file there.

I understand the document you refer to suggests that tests are to be moved to 
their own test package; this may be non-desirable for a variety of reasons. 
And, as far as it seems, surefire is totally fine keeping the tests in the same 
package (that's because --{{add-exports}} is added), as is Junit 5 in Eclipse. 
Just the combination of Junit 5 with Surefire doesn't work.

Can you reproduce using the attached project?

 

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-07-23 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17385980#comment-17385980
 ] 

Tibor Digana commented on SUREFIRE-1909:


I would like to see your "add-opens" with the remaining part, but the most 
important is the question why you used module-info.java in src/main/java and 
you did not write a new module-info.java in src/test/java. Pls read our 
documentation which describes everything you need 
https://maven.apache.org/surefire/maven-surefire-plugin/examples/jpms.html

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-07-22 Thread Jira


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17385840#comment-17385840
 ] 

Christian Kohlschütter commented on SUREFIRE-1909:
--

[~tibordigana] ping

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
> Attachments: surefire-jpms-bug.tar.gz
>
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports-}}" VM parameter that 
> surefire adds automatically to "{{-}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
> This bug is particularly bad because PMD now specifically complains about 
> junit5 classes marked as public instead of package-private; see 
> [https://pmd.github.io/2021/05/29/PMD-6.35.0/]



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


[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-06-21 Thread Jira


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17366928#comment-17366928
 ] 

Christian Kohlschütter commented on SUREFIRE-1909:
--

Hi Tibor, I've attached a project that exposes the bug. Just run with "mvn 
test".

As I said above, changing "add-exports" to "add-opens" in that class fixes it.

Here's the relevant output from "mvn -X test"

 
{code:java}
[DEBUG] Determined Maven Process ID 15092
[DEBUG] Fork Channel [1] connection string 'pipe://1' for the implementation 
class org.apache.maven.plugin.surefire.extensions.LegacyForkChannel
[DEBUG] boot classpath: 
.m2/repository/org/apache/maven/surefire/surefire-booter/3.0.0-M5/surefire-booter-3.0.0-M5.jar
 
.m2/repository/org/apache/maven/surefire/surefire-api/3.0.0-M5/surefire-api-3.0.0-M5.jar
 
.m2/repository/org/apache/maven/surefire/surefire-logger-api/3.0.0-M5/surefire-logger-api-3.0.0-M5.jar
 
.m2/repository/org/apache/maven/surefire/surefire-shared-utils/3.0.0-M4/surefire-shared-utils-3.0.0-M4.jar
 
.m2/repository/org/apache/maven/surefire/surefire-extensions-spi/3.0.0-M5/surefire-extensions-spi-3.0.0-M5.jar
 workspace/surefire-jpms-bug/target/test-classes 
.m2/repository/org/junit/jupiter/junit-jupiter/5.7.1/junit-jupiter-5.7.1.jar 
.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.1/junit-jupiter-api-5.7.1.jar
 .m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar 
.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar 
.m2/repository/org/junit/platform/junit-platform-commons/1.7.1/junit-platform-commons-1.7.1.jar
 
.m2/repository/org/junit/jupiter/junit-jupiter-params/5.7.1/junit-jupiter-params-5.7.1.jar
 
.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.1/junit-jupiter-engine-5.7.1.jar
 
.m2/repository/org/junit/platform/junit-platform-engine/1.7.1/junit-platform-engine-1.7.1.jar
 
.m2/repository/org/apache/maven/surefire/surefire-junit-platform/3.0.0-M5/surefire-junit-platform-3.0.0-M5.jar
 
.m2/repository/org/apache/maven/surefire/common-java5/3.0.0-M5/common-java5-3.0.0-M5.jar
 
.m2/repository/org/junit/platform/junit-platform-launcher/1.7.1/junit-platform-launcher-1.7.1.jar
[DEBUG] boot(compact) classpath: surefire-booter-3.0.0-M5.jar 
surefire-api-3.0.0-M5.jar surefire-logger-api-3.0.0-M5.jar 
surefire-shared-utils-3.0.0-M4.jar surefire-extensions-spi-3.0.0-M5.jar 
test-classes junit-jupiter-5.7.1.jar junit-jupiter-api-5.7.1.jar 
apiguardian-api-1.1.0.jar opentest4j-1.2.0.jar junit-platform-commons-1.7.1.jar 
junit-jupiter-params-5.7.1.jar junit-jupiter-engine-5.7.1.jar 
junit-platform-engine-1.7.1.jar surefire-junit-platform-3.0.0-M5.jar 
common-java5-3.0.0-M5.jar junit-platform-launcher-1.7.1.jar
[DEBUG] Path to args file: 
workspace/surefire-jpms-bug/target/surefire/surefireargs12553641456609995297
[DEBUG] args file content:
--module-path
"workspace/surefire-jpms-bug/target/classes"
--class-path
".m2/repository/org/apache/maven/surefire/surefire-booter/3.0.0-M5/surefire-booter-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/surefire-api/3.0.0-M5/surefire-api-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/surefire-logger-api/3.0.0-M5/surefire-logger-api-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/surefire-shared-utils/3.0.0-M4/surefire-shared-utils-3.0.0-M4.jar:.m2/repository/org/apache/maven/surefire/surefire-extensions-spi/3.0.0-M5/surefire-extensions-spi-3.0.0-M5.jar:workspace/surefire-jpms-bug/target/test-classes:.m2/repository/org/junit/jupiter/junit-jupiter/5.7.1/junit-jupiter-5.7.1.jar:.m2/repository/org/junit/jupiter/junit-jupiter-api/5.7.1/junit-jupiter-api-5.7.1.jar:.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar:.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:.m2/repository/org/junit/platform/junit-platform-commons/1.7.1/junit-platform-commons-1.7.1.jar:.m2/repository/org/junit/jupiter/junit-jupiter-params/5.7.1/junit-jupiter-params-5.7.1.jar:.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.7.1/junit-jupiter-engine-5.7.1.jar:.m2/repository/org/junit/platform/junit-platform-engine/1.7.1/junit-platform-engine-1.7.1.jar:.m2/repository/org/apache/maven/surefire/surefire-junit-platform/3.0.0-M5/surefire-junit-platform-3.0.0-M5.jar:.m2/repository/org/apache/maven/surefire/common-java5/3.0.0-M5/common-java5-3.0.0-M5.jar:.m2/repository/org/junit/platform/junit-platform-launcher/1.7.1/junit-platform-launcher-1.7.1.jar"
--patch-module
surefire.jpms.bug="workspace/surefire-jpms-bug/target/test-classes"
--add-exports
surefire.jpms.bug/surefire.test=ALL-UNNAMED
--add-modules
surefire.jpms.bug
--add-reads
surefire.jpms.bug=ALL-UNNAMED
org.apache.maven.surefire.booter.ForkedBooter
[DEBUG] Forking command line: /bin/sh -c cd workspace/surefire-jpms-bug && 
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java 

[jira] [Commented] (SUREFIRE-1909) Support JUnit 5 reflection access by changing add-exports to add-opens

2021-04-22 Thread Tibor Digana (Jira)


[ 
https://issues.apache.org/jira/browse/SUREFIRE-1909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17327229#comment-17327229
 ] 

Tibor Digana commented on SUREFIRE-1909:


[~c...@newsclub.de]
{{ModularClasspathForkConfiguration.java}} is in the module 
{{maven-surefire-common}} and therefore it has nothing to do with the formed 
JVM.
You have to show us how the CLI would look like if you want to help us. Check 
it out with debug logs {{mvn -X test}} and you will see JMPS options we use in 
the @file of the CLI.

> Support JUnit 5 reflection access by changing add-exports to add-opens
> --
>
> Key: SUREFIRE-1909
> URL: https://issues.apache.org/jira/browse/SUREFIRE-1909
> Project: Maven Surefire
>  Issue Type: Bug
>  Components: JUnit 5.x support
>Affects Versions: 3.0.0-M5
>Reporter: Christian Kohlschütter
>Priority: Major
>
> Testing JUnit 5 classes of a JPMS-enabled project with Surefire may fail if a 
> test class (or, for example, an abstract test base class) is not declared 
> "public". I'm seeing the following error:
>  
> {code:java}
> java.lang.reflect.InaccessibleObjectException: Unable to make public static 
> void some.package.SomeClass.setupClass() throws java.io.IOException 
> accessible: module some.module does not "opens some.package" to unnamed 
> module @754ba872{code}
> This could be fixed by adding the recommended "{{opens some.package}}" to the 
> project's module-info.java, however that is undesirable since it changes the 
> project's behavior beyond just unit testing. Adding a secondary "test-only" 
> module-info.java is also counterproductive since not all IDEs support this, 
> and these two files would have to be kept in sync, which is non-trivial.
> An easy fix would be to change the "{{--add-exports}}" VM parameter that 
> surefire adds automatically to "{{--}}{{add-opens}}" in 
> {{maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ModularClasspathForkConfiguration.java}}
>  



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