Skip to content
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

Improved documentation for MethodParameter#getAnnotatedElement #30397

Closed
chrylis opened this issue Apr 28, 2023 · 1 comment
Closed

Improved documentation for MethodParameter#getAnnotatedElement #30397

chrylis opened this issue Apr 28, 2023 · 1 comment
Assignees
Labels
type: documentation A documentation task
Milestone

Comments

@chrylis
Copy link

chrylis commented Apr 28, 2023

Affects: 5.3.27

The Javadoc for MethodParameter#getAnnotatedElement() reads Return the wrapped annotated element. Presumably for legacy reasons (since Parameter was added only in Java 8), this method returns the Method object for the method on which the MethodParameter resides rather than the Parameter object representing the parameter itself. This behavior is surprising; I expected the Parameter to be returned. Instead, to do this it seems I use #getParameter()

Since this API is widely used, altering the behavior is probably impractical. Instead, I suggest replacing the Javadoc on #getAnnotatedElement() to read:

Return the method or constructor on which this parameter resides. For the {@link AnnotatedElement} for this parameter itself, use {@link #getParameter()}.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 28, 2023
@snicoll
Copy link
Member

snicoll commented Oct 5, 2023

The Javadoc reads as follow:

Return the wrapped annotated element.
Note: This method exposes the annotations declared on the method/constructor itself (i.e. at the method/constructor level, not at the parameter level).
Returns: the Method or Constructor as AnnotatedElement

The note makes it pretty obvious what it does already, but the reference to #getParameter is helpful indeed.

@snicoll snicoll added type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 5, 2023
@snicoll snicoll self-assigned this Oct 5, 2023
@snicoll snicoll added this to the 6.0.13 milestone Oct 5, 2023
@snicoll snicoll closed this as completed in 19fd815 Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

3 participants