Skip to content

Avoid scanning anonymous classes#3150

Merged
mpkorstanje merged 7 commits intomainfrom
avoid_scanning_anonymous_classes
Jan 26, 2026
Merged

Avoid scanning anonymous classes#3150
mpkorstanje merged 7 commits intomainfrom
avoid_scanning_anonymous_classes

Conversation

@jkronegg
Copy link
Copy Markdown
Contributor

🤔 What's changed?

When scanning classes, we avoid scanning anonymous classes, because they cannot contain cucumber steps and hooks.

⚡️ What's your motivation?

Contributes to #3141.

Anonymous classes are non-public classes so their methods will not be scanned by the MethodScanner, but the class will still be loaded. By avoiding scanning the anonymous classes earlier in the ClasspathScanner, we avoid loading the class. Well, the class may be loaded by other part of the application, but at least this will not be Cucumber's fault.

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

N/A

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

@jkronegg jkronegg requested a review from mpkorstanje January 24, 2026 22:44
@mpkorstanje mpkorstanje merged commit 3f27ff4 into main Jan 26, 2026
6 checks passed
@mpkorstanje mpkorstanje deleted the avoid_scanning_anonymous_classes branch January 26, 2026 22:27
mpkorstanje added a commit that referenced this pull request Jan 28, 2026
mpkorstanje added a commit that referenced this pull request Jan 29, 2026
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.

2 participants