Skip to content

Conversation

dnestoro
Copy link
Collaborator

@dnestoro dnestoro commented Jul 24, 2025

Now that we are not duplicating JUnit dependencies, we could end up in a situation where:

  • user didn't provide some dependency (for example org.junit.jupiter:junit-jupiter-params)
  • JupiterConfigProvider wants to register annotations (and their parameters) for reflection from that dependency
  • we will get NoClassDefFoundError

Solution: group annotations by the dependency that introduces them, and print a warning if the dependency is not available.

Fixes: #747

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 24, 2025
@dnestoro dnestoro force-pushed the dnestoro/register-only-available-junit-annotations branch from 55c8c3e to 97cced1 Compare July 24, 2025 15:09
@dnestoro dnestoro requested a review from melix July 24, 2025 15:14
@dnestoro dnestoro self-assigned this Jul 24, 2025
AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, FieldSource.class, JupiterConfigProvider::handleFieldSource);
} catch (NoClassDefFoundError e) {
System.out.println("[junit-platform-native] Cannot register @FieldSource annotation from org.junit.jupiter.params." +
" Please verify that you have this dependency (with version greater than JUnit 5.13) if you want to use this annotation.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm, I'm not sure we want to print that out. It will be annoying for users who do NOT want this.

Copy link
Collaborator Author

@dnestoro dnestoro Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we should use debug()? Could we see the failure at runtime because we didn't register those annotations for reflection (and users won't see why we didn't register them)?

@dnestoro dnestoro force-pushed the dnestoro/register-only-available-junit-annotations branch from 05c0723 to db6c391 Compare August 19, 2025 09:12
@dnestoro dnestoro requested a review from melix August 19, 2025 09:14
@dnestoro dnestoro merged commit c50139a into master Aug 19, 2025
323 checks passed
@dnestoro dnestoro deleted the dnestoro/register-only-available-junit-annotations branch August 19, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JupiterConfigProvider fails with ClassNotFoundExecption
2 participants