Skip to content

Use bundled Jupiter version for JUnit platform console standalone JARs#2960

Merged
trancexpress merged 1 commit intoeclipse-jdt:masterfrom
wenytang-ms:fix/findAnnotations-fat-jar-fallback
Apr 29, 2026
Merged

Use bundled Jupiter version for JUnit platform console standalone JARs#2960
trancexpress merged 1 commit intoeclipse-jdt:masterfrom
wenytang-ms:fix/findAnnotations-fat-jar-fallback

Conversation

@wenytang-ms
Copy link
Copy Markdown
Contributor

@wenytang-ms wenytang-ms commented Apr 23, 2026

Summary

Fix JUnit 5/6 detection for junit-platform-console-standalone JARs whose manifest exposes different Platform and Jupiter engine versions.

Problem

junit-platform-console-standalone-1.13.4.jar contains JUnit Jupiter 5.13.4, but its manifest Specification-Version represents the JUnit Platform version (1.13.4), not the bundled Jupiter engine version.

CoreTestSearchEngine.hasJUnit5TestAnnotation() uses the resolved annotation type to inspect the containing JAR version. For standalone console JARs, reading Specification-Version causes the detected major version to be 1, so the JAR is not recognized as JUnit 5.

This can prevent a plain Eclipse Java project using junit-platform-console-standalone-1.13.4.jar from launching JUnit 5 tests correctly.

Fix

When the containing JAR is junit-platform-console-standalone-*, prefer the manifest attribute:

Engine-Version-junit-jupiter

and fall back to:

Specification-Version

for the existing non-standalone cases.

This keeps the existing annotation lookup and access-restriction behavior unchanged.

Behavior Matrix

Scenario Before After
Direct junit-jupiter-api-*.jar on classpath Works Works
junit-platform-console-standalone-1.13.4.jar with Jupiter 5.13.4 Detected as Platform 1.x, not JUnit 5 Detected as JUnit 5
junit-platform-console-standalone-6.0.3.jar Detected as JUnit 6 Detected as JUnit 6
PDE forbidden/transitive JUnit dependency case from #2830/#2903 Access restrictions preserved Access restrictions preserved

Tests

Added JUnitStandaloneDetectionTest covering:

  • junit-platform-console-standalone-1.13.4.jar: Specification-Version=1.13.4, Engine-Version-junit-jupiter=5.13.4
  • junit-platform-console-standalone-6.0.3.jar: Specification-Version=6.0.3, Engine-Version-junit-jupiter=6.0.3

Related

@wenytang-ms
Copy link
Copy Markdown
Contributor Author

This patch intentionally handles the known JUnit Platform Console Standalone layout,
where Specification-Version represents the Platform version while
Engine-Version-junit-jupiter represents the bundled Jupiter version.

@wenytang-ms
Copy link
Copy Markdown
Contributor Author

@trancexpress please help review this PR.

@iloveeclipse
Copy link
Copy Markdown
Member

@wenytang-ms : to be clear, are you using latest 4.40 nightly build or are you using some older released Eclipse version? Latest nightly build is here: https://download.eclipse.org/eclipse/downloads/drops4/I20260426-1800/.

@wenytang-ms
Copy link
Copy Markdown
Contributor Author

@wenytang-ms : to be clear, are you using latest 4.40 nightly build or are you using some older released Eclipse version? Latest nightly build is here: https://download.eclipse.org/eclipse/downloads/drops4/I20260426-1800/.

@iloveeclipse yes, I can repro such issue.
image
image

@wenytang-ms wenytang-ms changed the title Fix findAnnotations() for standalone/fat Multi-Release JARs Use bundled Jupiter version for JUnit platform console standalone JARs Apr 28, 2026
@trancexpress
Copy link
Copy Markdown
Contributor

trancexpress commented Apr 28, 2026

@wenytang-ms the PR looks great, please remove the merge commits and squash the remaining commits. Please also reword the commit message to reflect the current fix.

I tried to do this, but when setting the PR you've disabled editing by committers:

 ! [remote rejected]       findAnnotations-fat-jar-fallback -> findAnnotations-fat-jar-fallback (permission denied)

If you have future PRs, please amend and rebase for small changes like this. Generally only project branches have multiple commits. Normal PRs generally have 1 commit for the change and maybe the bot-generated bundle version bumps.

@wenytang-ms wenytang-ms force-pushed the fix/findAnnotations-fat-jar-fallback branch from 08ead52 to 2e369cc Compare April 28, 2026 07:39
@wenytang-ms
Copy link
Copy Markdown
Contributor Author

@wenytang-ms the PR looks great, please remove the merge commits and squash the remaining commits. Please also reword the commit message to reflect the current fix.

I tried to do this, but when setting the PR you've disabled editing by committers:

 ! [remote rejected]       findAnnotations-fat-jar-fallback -> findAnnotations-fat-jar-fallback (permission denied)

If you have future PRs, please amend and rebase for small changes like this. Generally only project branches have multiple commits. Normal PRs generally have 1 commit for the change and maybe the bot-generated bundle version bumps.

@trancexpress done

@trancexpress
Copy link
Copy Markdown
Contributor

@wenytang-ms commit message is still outdated.

@wenytang-ms wenytang-ms force-pushed the fix/findAnnotations-fat-jar-fallback branch from 2e369cc to 0d12702 Compare April 29, 2026 01:17
JUnit Platform Console Standalone jars expose the platform version in
Specification-Version, while the bundled Jupiter engine version is stored
in Engine-Version-junit-jupiter. Prefer that Jupiter engine version for
junit-platform-console-standalone jars so JUnit 5 and JUnit 6 detection
uses the version of the test engine rather than the platform artifact.

Fall back to Specification-Version for the existing non-standalone cases
and leave annotation lookup/access restriction behavior unchanged.

Fixes: eclipse-jdt#2959
@wenytang-ms wenytang-ms force-pushed the fix/findAnnotations-fat-jar-fallback branch from 0d12702 to 1ef01cb Compare April 29, 2026 01:23
@wenytang-ms
Copy link
Copy Markdown
Contributor Author

@wenytang-ms commit message is still outdated.

@trancexpress done

@trancexpress trancexpress merged commit 17f8fa5 into eclipse-jdt:master Apr 29, 2026
13 checks passed
@trancexpress
Copy link
Copy Markdown
Contributor

Thank you for the report and fix @wenytang-ms !

@wenytang-ms wenytang-ms deleted the fix/findAnnotations-fat-jar-fallback branch April 29, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CoreTestSearchEngine.findAnnotations() fails to find @Testable in standalone/fat Multi-Release JARs

3 participants