-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply method predicate before searching type hierarchy #3500
Merged
sbrannen
merged 1 commit into
junit-team:main
from
sbrannen:issues/3498-apply-predicate-before-searching-hierarchy
Oct 30, 2023
Merged
Apply method predicate before searching type hierarchy #3500
sbrannen
merged 1 commit into
junit-team:main
from
sbrannen:issues/3498-apply-predicate-before-searching-hierarchy
Oct 30, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
hjohn
reviewed
Oct 9, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This comment was marked as off-topic.
This comment was marked as off-topic.
sbrannen
added a commit
to sbrannen/junit5
that referenced
this pull request
Oct 30, 2023
Prior to this commit, findMethods() and streamMethods() in ReflectionSupport as well as findAnnotatedMethods() in AnnotationSupport first searched for all methods in the type hierarchy and then applied the user-supplied predicate (or "is annotated?" predicate) afterwards. This resulted in methods in subclasses incorrectly "shadowing" package-private methods in superclasses (in a different package) even if the predicate would otherwise exclude the method in such a subclass. For example, given a superclass that declares a package-private static @BeforeAll "before()" method and a subclass (in a different package) that declares a @BeforeEach "before()" method, when JUnit Jupiter looked up @BeforeAll methods for the subclass, the @BeforeAll "before()" method in the superclass was not found because the @BeforeEach "before()" method shadowed it based solely on the method signature, ignoring the type of annotation sought. To address that, this commit modifies the internal search algorithms in ReflectionUtils so that method predicates are applied while searching the hierarchy for methods. Closes junit-team#3498 Closes junit-team#3500
Prior to this commit, findMethods() and streamMethods() in ReflectionSupport as well as findAnnotatedMethods() in AnnotationSupport first searched for all methods in the type hierarchy and then applied the user-supplied predicate (or "is annotated?" predicate) afterwards. This resulted in methods in subclasses incorrectly "shadowing" package-private methods in superclasses (in a different package) even if the predicate would otherwise exclude the method in such a subclass. For example, given a superclass that declares a package-private static @BeforeAll "before()" method and a subclass (in a different package) that declares a @BeforeEach "before()" method, when JUnit Jupiter looked up @BeforeAll methods for the subclass, the @BeforeAll "before()" method in the superclass was not found because the @BeforeEach "before()" method shadowed it based solely on the method signature, ignoring the type of annotation sought. To address that, this commit modifies the internal search algorithms in ReflectionUtils so that method predicates are applied while searching the hierarchy for methods. Closes junit-team#3498 Closes junit-team#3500
sbrannen
force-pushed
the
issues/3498-apply-predicate-before-searching-hierarchy
branch
from
October 30, 2023 18:22
4732d12
to
64ed21a
Compare
sbrannen
added a commit
that referenced
this pull request
Oct 30, 2023
Prior to this commit, findMethods() and streamMethods() in ReflectionSupport as well as findAnnotatedMethods() in AnnotationSupport first searched for all methods in the type hierarchy and then applied the user-supplied predicate (or "is annotated?" predicate) afterwards. This resulted in methods in subclasses incorrectly "shadowing" package-private methods in superclasses (in a different package) even if the predicate would otherwise exclude the method in such a subclass. For example, given a superclass that declares a package-private static @BeforeAll "before()" method and a subclass (in a different package) that declares a @BeforeEach "before()" method, when JUnit Jupiter looked up @BeforeAll methods for the subclass, the @BeforeAll "before()" method in the superclass was not found because the @BeforeEach "before()" method shadowed it based solely on the method signature, ignoring the type of annotation sought. To address that, this commit modifies the internal search algorithms in ReflectionUtils so that method predicates are applied while searching the hierarchy for methods. Closes #3498 Closes #3500
sbrannen
added a commit
that referenced
this pull request
Jan 15, 2024
sbrannen
added a commit
that referenced
this pull request
Jan 15, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@BeforeAll
method in super class skipped when it has same name as a@BeforeEach
method in subclass #3498