Skip to content

getDeclaredAnnotation can't find Nullable #22663

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

Closed
dmitry-s opened this issue Mar 25, 2019 · 2 comments
Closed

getDeclaredAnnotation can't find Nullable #22663

dmitry-s opened this issue Mar 25, 2019 · 2 comments
Assignees
Labels
type: regression A bug that is also a regression
Milestone

Comments

@dmitry-s
Copy link

dmitry-s commented Mar 25, 2019

Affects: 5.2.0.BUILD-SNAPSHOT


After changes introduced in #22586, AnnotationsScanner.getDeclaredAnnotation(source, annotationType) method can't find org.springframework.lang.Nullable anymore because it gets filtered out by this filter:

static final AnnotationFilter PLAIN = packages("java.lang",
			"org.springframework.lang");

from org.springframework.core.annotation.AnnotationFilter

Is that intentional? If so, what should be used instead?

Jus to clarify, we use AnnotatedElementUtils.findMergedAnnotation, but internally it relies on AnnotationsScanner.getDeclaredAnnotation

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 25, 2019
@jhoeller
Copy link
Contributor

We don't consider the lang annotations as searchable there. Since such annotations are usually declared locally and never use attribute aliases, why do you need to use a merged annotation search to begin with? Why not simply look it up through regular JDK getAnnotation calls? Are you possibly not repeating the nullability declarations on interface implementations and subclasses?

@jhoeller jhoeller self-assigned this Mar 25, 2019
@jhoeller jhoeller added type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 26, 2019
@jhoeller jhoeller added this to the 5.2 M1 milestone Mar 26, 2019
@jhoeller
Copy link
Contributor

I'm in the process of restoring some basic detection of lang annotations so that AnnotatedElementUtils.findMergedAnnotation and co can be used for simple direct annotation lookups as well (again). We had that before, mostly as an optimization for locally declared annotations, and should be able to restore that... even if the new MergedAnnotation API does not consider such annotations as searchable within its algorithm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants