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

Closed
spring-projects-issues opened this issue Apr 25, 2013 · 1 comment
Closed
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: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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() :

@Override
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

@spring-projects-issues
Copy link
Collaborator Author

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.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: core Issues in core modules (aop, beans, core, context, expression) 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
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants