Repository navigation
Fix IllegalAccessError when the main module requires JUnit (#3532) - #3538
Conversation
When the main module-info requires JUnit, JUnit goes on the module path while the launcher, the engines and the provider stay on the class path, so the fork failed before running any test. Signed-off-by: Olivier Lamy <olamy@apache.org>
Signed-off-by: Olivier Lamy <olamy@apache.org>
There was a problem hiding this comment.
π’ Approval recommended
Static review found no blocking issues, with focused unit and integration coverage present; tests were not executed.
No open issues π
What changed in this PR
Fixes fork startup when the main module requires JUnit, allowing module-path JUnit libraries to work with classpath engines and providers.
Changes:
- Generates module exports and test-package opens from resolved module descriptors.
- Combines these arguments with provider arguments without modifying provider-owned lists.
- Adds unit coverage and JUnit 5/6 integration fixtures.
| File | Description |
|---|---|
| surefire-its/βsrc/βtest/βresources/βsurefire-3532-main-module-requires-junit/βsrc/βtest/βjava/βissue3532/βTimeoutTest.java | Covers separate-thread timeout execution. |
| surefire-its/βsrc/βtest/βresources/βsurefire-3532-main-module-requires-junit/βsrc/βtest/βjava/βissue3532/βinternal/βInternalTest.java | Covers tests in an internal package. |
| surefire-its/βsrc/βtest/βresources/βsurefire-3532-main-module-requires-junit/βsrc/βtest/βjava/βissue3532/βChecksTest.java | Covers package-private test access. |
| surefire-its/βsrc/βtest/βresources/βsurefire-3532-main-module-requires-junit/βsrc/βmain/βjava/βmodule-info.java | Declares the main moduleβs JUnit requirement. |
| surefire-its/βsrc/βtest/βresources/βsurefire-3532-main-module-requires-junit/βsrc/βmain/βjava/βissue3532/βChecks.java | Provides a JUnit-dependent main-code helper. |
| surefire-its/βsrc/βtest/βresources/βsurefire-3532-main-module-requires-junit/βpom.xml | Configures the modular regression fixture. |
| surefire-its/βsrc/βtest/βjava/βorg/βapache/βmaven/βsurefire/βits/βjiras/βSurefire3532MainModuleRequiresJUnitIT.java | Checks JUnit 5/6 execution and warning-free arguments. |
| maven-surefire-common/βsrc/βtest/βjava/βorg/βapache/βmaven/βplugin/βsurefire/βModulePathJpmsArgumentsTest.java | Tests argument generation and edge cases. |
| maven-surefire-common/βsrc/βtest/βjava/βorg/βapache/βmaven/βplugin/βsurefire/βAbstractSurefireMojoJava7PlusTest.java | Checks startup integration and immutable provider lists. |
| maven-surefire-common/βsrc/βmain/βjava/βorg/βapache/βmaven/βplugin/βsurefire/βModulePathJpmsArguments.java | Generates module access arguments. |
| maven-surefire-common/βsrc/βmain/βjava/βorg/βapache/βmaven/βplugin/βsurefire/βAbstractSurefireMojo.java | Adds generated arguments to modular fork configuration. |
Review effort: Balanced
|
For information, this pull request and #3523 seems to add heuristic rules. When we will start the work for adding Java module support in the Maven 4 way, we may need to disable all those heuristic rules (they will be used only for compatibility with Maven 3 way). Therefore, if there is some way to group heuristic rules in a place that we can easily identity and enable/disable when needed, that may be helpful. For example, in the Maven 4 way, whether to put a dependency on the class-path or module-path should not be decided by the plugin anymore. It should be decided by Maven core and depends, among other, of the dependency type (e.g. |
Looks like a very good idea. Thanks |
When the main module-info requires JUnit, JUnit goes on the module path
while the launcher, the engines and the provider stay on the class path,
so the fork failed before running any test.
Signed-off-by: Olivier Lamy olamy@apache.org
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
check one of the following: