-
Notifications
You must be signed in to change notification settings - Fork 38k
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
MergedAnnotation meta-data support #22909
Merged
Merged
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
Extract the inner classes from package-info into their own files to prevent local build problems and to make them easier to find.
Add a `getTypeHierarchy()` method to `MergedAnnotation` that can be used to return the full type hierarchy information. This method is specifically designed to be used in combination with `MergedAnnotationPredicates.unique`. This update also allows us to delete the `parentAndType` method from `AnnotatedElementUtils`. Closes spring-projectsgh-22908
Rename `from` to `of` for the `MergedAnnotation` factory methods that work with Maps. The previous name was a little confusing, especially when an annotation source parameter was specified. The new method name helps to make it clearer when the user is explicitly defining the attributes of the annotation, as opposed to picking them up from the source.
Update TypeMappedAnnotation so that Strings can be used to represent Class attribute values. This will allow ASM annotation readers to present a `MergedAnnotation` instance without necessarily having the actual class values on the classpath. When the underlying value is a String, any calls to `getValue(name, String.class)` or `asMap(Adapt.CLASS_TO_STRING)` will simply return the original String. Calls that need the actual Class result (such as `getClass`) will use `Class.forName` and may throw a `ClassNotFoundException` at that point. This commit also allows an empty Object[] to be used to represent any empty primitive array. See spring-projectsgh-22884
Add a factory method to `MergedAnnotation` that allows an instance to be created for an explicit collection of root annotations. This method will allow ASM based readers to expose a `MergedAnnotation` instance that has root annotations loaded from bytecode, and meta-annotations loaded using reflection. See spring-projectsgh-22884
Update ASM based metadata readers so that only RetentionPolicy.RUNTIME annotations are exposed. This aligned behavior with the reflection based implementation. Closes spring-projectsgh-22886
Update `StandardAnnotationMetadata` and `AnnotationMetadataReadingVisitor` so that `java.lang.annotation` annotations are consistently skipped. Closes spring-projectsgh-22885
Update `StandardAnnotationMetadata` to use `ReflectionUtils` when obtaining declared methods. This update is primarily so that the common method cache can be used. Closes spring-projectsgh-22907
Add some additional tests to provide more coverage of class and method meta-data support. See spring-projectsgh-22884
Extract and pull-up some common method implementations and make them default methods of the interface. See spring-projectsgh-22884
Add `AnnotatedTypeMetaData.getAnnotations()` that can be used to access annotation details using the `MergedAnnotations` interface. Where possible, the existing annotation methods have been migrated to call `getAnnotation()`, rather than needing their own implementation. The existing ASM based meta-data implementations have not been updated since they will be deprecated and replaced in a subsequent commit. See spring-projectsgh-22884
Replace the existing ASM based readers with new implementations that also support MergedAnnotations. The meta-data classes themselves are now immutable, and constructed via separate reader classes. The `SimpleMetadataReader` class has been updated to return the new classes, however the old ones remain since some of them are public and might be being used directly. Closes spring-projectsgh-22884
Deprecate the public `StandardMetadata` constructors to make it clearer that these classes should not be instantiated directly. A new `AnnotationMetadata.introspect` factory method has been added which can now be used to obtain instances. This change will allow use to make the constructors package private and drop the `nestedAnnotationsAsMap` parameter in a future release. Closes spring-projectsgh-22906
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged or decided on
label
May 6, 2019
jhoeller
added
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
and removed
status: waiting-for-triage
An issue we've not yet triaged or decided on
labels
May 6, 2019
jhoeller
added a commit
that referenced
this pull request
May 7, 2019
Includes fix for typo in visitor class names. See gh-22909
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: enhancement
A general enhancement
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.
This PR is primarily for #22884 but it also covers a few more issues. Since it's quite a large set of changes it feels better to have a PR that we can review, rather than just merging.
I've run a full Spring Framework and Spring Boot build locally with these changes applied without any obvious issues being found.