Copilot commented on code in PR #3523:
URL: https://github.com/apache/maven-surefire/pull/3523#discussion_r4306808795
##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##########
@@ -3178,7 +3178,10 @@ public void addProviderProperties() throws
MojoExecutionException {
@Override
public List<String[]> getJpmsArguments(@Nonnull ProviderRequirements
forkRequirements) {
boolean hasTestDescriptor = forkRequirements.isModularPath() &&
forkRequirements.hasTestModuleDescriptor();
- return hasTestDescriptor ? getJpmsArgs() : Collections.emptyList();
+ // Provider dependencies stay on the classpath, so only open
Commons when it is a test module.
+ boolean junitPlatformCommonsOnModulePath =
+
testClasspath.getTestDependencies().containsKey(PROVIDER_DEP_GID +
":junit-platform-commons");
+ return hasTestDescriptor && junitPlatformCommonsOnModulePath ?
getJpmsArgs() : Collections.emptyList();
Review Comment:
Commons supplied through `additionalClasspathElements` or
`additionalClasspathDependencies` is missing from `getTestDependencies()`.
However, `TestClassPath.toClasspath()` includes those additional elements, and
`newStartupConfigWithModularPath()` puts them on the module path when a test
descriptor exists. This guard therefore removes the previously emitted opens
even when Commons is a named module, which can cause `IllegalAccessError` when
classpath-loaded Platform code accesses its qualified-exported packages. Check
Commons' presence on the effective module path, including additional elements,
and add a regression test for this configuration.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]