Skip to content

AnnotationUtils fails to retrieve attribute values from non-public annotations [SPR-11104] #15730

Closed

Description

@spring-projects-issues

Sam Brannen opened SPR-11104 and commented

Status Quo

The getValue() methods in AnnotationUtils currently fail to retrieve the value of the desired annotation attribute if the annotation itself is not public (i.e., package private). In contrast, the getDefaultValue() methods work fine since they invoke Method#getDefaultValue(). Thus the problem lies with the fact that AnnotationUtils.getValue(Annotation, String) attempts to invoke the method, swallowing the exception on failure and silently returning null.

Deliverables

  1. Update AnnotationUtils.getValue(Annotation, String) so that it uses reflection to make the desired annotation attribute method accessible before invoking it to retrieve the value.

Affects: 3.0 GA

Issue Links:

Referenced from: commits b830d73

Activity

  1. spring-projects-issues commented on Nov 20, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Resolved as discussed in the comments for GitHub commit b830d73:

    Support non-public anno. attr. values in AnnoUtils

    Prior to this commit, the getValue(Annotation, String) method in
    AnnotationUtils failed to retrieve the value of the desired annotation
    attribute if the annotation itself was not public -- for example if the
    annotation was declared as package private.

    This commit addresses this issue by ensuring that getValue(Annotation,
    String) uses reflection to make the desired annotation attribute method
    accessible before attempting to invoke it to retrieve the value.

  2. added
    type: bug
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions