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

Fix @Bean meta-annotation detection when using ASM [SPR-10488] #15121

spring-projects-issues opened this issue Apr 25, 2013 · 1 comment
in: core status: backported type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Apr 25, 2013

Didier Villevalois opened SPR-10488 and commented

When using @Bean as meta-annotation, Configuration class enhancement correctly takes the meta-annotated methods, but ConfigurationClassParser does not correctly registers @Bean methods.

This comes from MethodMetadataReadingVisitor.visitAnnotation() :

public AnnotationVisitor visitAnnotation(final String desc, boolean visible) {
	String className = Type.getType(desc).getClassName();
	methodMetadataMap.add(className, this);
	return new AnnotationAttributesReadingVisitor(className, this.attributeMap, null, this.classLoader);

Here a null metaAnnotationMap argument is passed to AnnotationAttributesReadingvisitor. I guess more things should be added to methodMetadataMap.

As a result, in ConfigurationClassParser:247 :

// process individual @Bean methods
Set<MethodMetadata> beanMethods = metadata.getAnnotatedMethods(Bean.class.getName());
for (MethodMetadata methodMetadata : beanMethods) {
	configClass.addBeanMethod(new BeanMethod(methodMetadata, configClass));

getAnnotatedMethods() does not return methods meta-annotated with @Bean.

Do you need a test case ? Or is this easy enough to reproduce ?

Affects: 3.2.2

Backported to: 3.2.7

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 16, 2013

Juergen Hoeller commented

This works when registering configuration classes by Class reference, e.g. through register(Class...) calls on AnnotationConfigApplicationContext. However, I've just reproduced that it does not work when specified through class names only, e.g. from XML bean definitions or as a result of classpath scanning, when ASM is being used. I'll make sure that the ASM mode of processing catches up with regular Class-based processing there.


@spring-projects-issues spring-projects-issues added type: bug status: backported in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.0.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core status: backported type: bug
None yet

No branches or pull requests

2 participants