-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
Sam Brannen opened SPR-13338 and commented
Status Quo
The Javadoc for the synthesizeAnnotation(Map<String, Object>, Class<A>, AnnotatedElement) method in AnnotationUtils states the following:
Synthesize an annotation from the supplied map of annotation attributes by wrapping the map in a dynamic proxy that implements an annotation of the specified
annotationTypeand transparently enforces attribute alias semantics for annotation attributes that are annotated with@AliasFor.The supplied map must contain a key-value pair for every attribute defined in the supplied
annotationTypethat is not aliased or does not have a default value.Note that
AnnotationAttributesis a specialized type of Map that is an ideal candidate for this method'sattributesargument.
Note that the Javadoc says that key-value pairs must be present, but it does not say that there are any limitations on the types of values that are permitted. The Javadoc also explicitly states that AnnotationAttributes is an ideal candidate for synthesis.
However, if the map of annotation attributes was created manually (with nested maps instead of annotations) or with one of the getAnnotationAttributes(..) variants with nestedAnnotationsAsMap set to true, an exception is thrown during synthesis since a map or array or maps is not compatible with an annotation or array of annotations, respectively.
Deliverables
- Ensure that a nested map or nested array of maps is properly synthesized into an annotation or array of annotations when synthesizing the enclosing map into an annotation.
Affects: 4.2 GA
Referenced from: commits f17173f