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

Annotation searches fail for non-public repeatable annotations #29301

Closed
sbrannen opened this issue Oct 11, 2022 · 0 comments
Closed

Annotation searches fail for non-public repeatable annotations #29301

sbrannen opened this issue Oct 11, 2022 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Oct 11, 2022

While working on #20279, I noticed that annotation searches for non-public repeatable annotations fail on JDK 17 with an error similar to the following.

Failed to introspect annotations on void org.springframework.core.annotation.NestedRepeatableAnnotationsTests$MultipleRepeatableAnnotationsTests.annotatedMethod():

java.lang.IllegalAccessError: failed to access class org.springframework.core.annotation.NestedRepeatableAnnotationsTests$A from class jdk.proxy2.$Proxy12 (org.springframework.core.annotation.NestedRepeatableAnnotationsTests$A is in unnamed module of loader 'app'; jdk.proxy2.$Proxy12 is in module jdk.proxy2 of loader 'app')

The reason is that we cannot invoke the value() method of the container annotation.

This means that we cannot "deduce" the container type of a repeatable annotation, and when that fails our annotation support then fails to find any matching repeatable annotations of the given type. An INFO message is logged like the one above, but the search algorithm otherwise silently continues without finding anything.

I also see the following on 5.3.x with JDK 8.

Failed to introspect annotations on void org.springframework.core.annotation.NestedRepeatableAnnotationsTests$MultipleRepeatableAnnotationsTests.annotatedMethod():

java.lang.IllegalAccessError: tried to access class org.springframework.core.annotation.NestedRepeatableAnnotationsTests$A from class com.sun.proxy.$Proxy12

So it is not specific JDK 17, although the error message is slightly different.

@sbrannen sbrannen added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Oct 11, 2022
@sbrannen sbrannen added this to the 5.3.24 milestone Oct 11, 2022
@sbrannen sbrannen self-assigned this Oct 11, 2022
@sbrannen sbrannen changed the title Annotation searches fail for non-public repeatable annotations on JDK 17 Annotation searches fail for non-public repeatable annotations Oct 11, 2022
sbrannen added a commit that referenced this issue Nov 8, 2022
As a follow up to 332b25b, this commit consistently avoids the use of
reflection for annotation attribute method invocations.

See gh-29301
Closes gh-29448
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant