apache / apache/maven-surefire

[SUREFIRE-1765] target/test-classes should not be added to classpath when tests run on modulepath using patch-module

Open
#3,088 12 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Tom De Wolf](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=tomdw)** opened **[SUREFIRE-1765](https://issues.apache.org/jira/browse/SUREFIRE-1765?redirect=false)** and commented

When running junit tests using the maven-surefire-plugin the target/test-classes are added as first entry in the classpath.

However, when testing a explicit java module with a module-info.java the test-classes are already part of the module path using --patch-module. So they should not be on the classpath?

In some scenario's this can give unwanted side-effects, i.e. that the same classes are on the modulepath and classpath, possibly with a module-info.class in both locations (cfr https://bugs.openjdk.java.net/browse/JDK-8241770).

So it seems that it is best that target/test-classes is only added to the classpath when it is not put on the module-path.

---

**Affects:** 2.22.1, 2.22.2

**Attachments:**
- [reproduce-xxxAnnotation-jdk-bug.zip](https://issues.apache.org/jira/secure/attachment/12998223/reproduce-xxxAnnotation-jdk-bug.zip) (_7.41 kB_)

2 votes, 8 watchers

Contributor guide

Open the contributing guide

Research direction

Start with the attached reproduce-xxxAnnotation-jdk-bug.zip and the maven-surefire-plugin handling of explicit modules, --patch-module, and target/test-classes. Done means target/test-classes is omitted from the classpath when it is already placed on the module path, with a regression test covering the duplicate module-info.class scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.