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

JavaDoc of AnnotatedTypeMetadata.getAllAnnotationAttributes is misleading. [SPR-12473] #17079

Closed
spring-projects-issues opened this issue Nov 26, 2014 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Christoph Strobl opened SPR-12473 and commented

Given the following structure one would assume that getAllAnnotationAttributes gets all values for someType which would be Object.class and String.class but only the attributes of the meta annotation get evaluated which is different to what getAnnotationAttributes does.

public class StandardAnnotationMetadataUnitTests {

	@Test
	@SuppressWarnings("rawtypes")
	public void standardAnnotationMetadataGetAllAnnotationAttributesShouldContainAttributesReturnedByGetAnnotationAttributes() {

		StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class);
		assertThat((Class) metadata.getAnnotationAttributes(MetaAnnotation.class.getName()).get("someType"),
				Is.<Class> is(String.class));
		assertThat((List<Object>) metadata.getAllAnnotationAttributes(MetaAnnotation.class.getName())
				.get("someType"), IsIterableContainingInAnyOrder.<Object> containsInAnyOrder(String.class, Object.class));
	}

	@ConcreteAnnotation
	static class Config {

	}

	@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
	@Retention(RetentionPolicy.RUNTIME)
	@Documented
	@Inherited
	public static @interface MetaAnnotation {

		Class<?> someType() default Object.class;
	}

	@Target({ ElementType.TYPE })
	@Retention(RetentionPolicy.RUNTIME)
	@Documented
	@Inherited
	@MetaAnnotation
	public static @interface ConcreteAnnotation {

		Class<?> someType() default String.class;
	}

}

Affects: 4.0.8, 4.1.2

Referenced from: commits 5ac8680, f44217a

Backported to: 4.0.9

@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1.3 milestone Jan 11, 2019
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) status: backported An issue that has been backported to maintenance branches type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants