Skip to content

Discover tests in a fork when a toolchain JDK is used - #3444

Merged
olamy merged 2 commits into
apache:masterfrom
olamy:fix/master/2151-toolchain-fork-discovery
Aug 25, 2026
Merged

olamy merged 2 commits into
apache:masterfrom
olamy:fix/master/2151-toolchain-fork-discovery

Conversation

@olamy

@olamy olamy commented Aug 24, 2026

Copy link
Copy Markdown
Member

When forking has to list the tests first (forkCount > 1 or
reuseForks=false), Surefire did it in Maven's JVM. If the tests were
built for a newer JDK, that failed with UnsupportedClassVersionError.

Now the listing runs in a short-lived fork using the toolchain JDK, so
no test class is loaded in Maven's JVM. The extra fork only starts when
the test JVM differs from Maven's.

Fixes #2151

Signed-off-by: Olivier Lamy olamy@apache.org

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean install).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

When forking has to list the tests first (forkCount > 1 or
reuseForks=false), Surefire did it in Maven's JVM. If the tests were
built for a newer JDK, that failed with UnsupportedClassVersionError.

Now the listing runs in a short-lived fork using the toolchain JDK, so
no test class is loaded in Maven's JVM. The extra fork only starts when
the test JVM differs from Maven's.

Fixes apache#2151

Signed-off-by: Olivier Lamy <olamy@apache.org>
@olamy olamy added the bug Something isn't working label Aug 24, 2026
@olamy olamy self-assigned this Aug 24, 2026
Signed-off-by: Olivier Lamy <olamy@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SUREFIRE-1459] mvn+java7 and POM with toolchains targeting java8 fail in surefire plugin

1 participant