Support final @Configuration(proxyBeanMethods = false) classes

Closes gh-22869
This commit is contained in:
Sebastien Deleuze
2019-05-02 10:13:59 +02:00
parent a2a6bc3d47
commit fc8d5c068c
2 changed files with 70 additions and 7 deletions

View File

@@ -211,15 +211,16 @@ final class ConfigurationClass {
}
public void validate(ProblemReporter problemReporter) {
// A configuration class may not be final (CGLIB limitation)
if (getMetadata().isAnnotated(Configuration.class.getName())) {
if (getMetadata().isFinal()) {
// A configuration class may not be final (CGLIB limitation) unless it declares proxyBeanMethods=false
String annotationName = Configuration.class.getName();
if (this.metadata.isAnnotated(annotationName) &&
(Boolean) this.metadata.getAnnotationAttributes(annotationName).get("proxyBeanMethods")) {
if (this.metadata.isFinal()) {
problemReporter.error(new FinalConfigurationProblem());
}
}
for (BeanMethod beanMethod : this.beanMethods) {
beanMethod.validate(problemReporter);
for (BeanMethod beanMethod : this.beanMethods) {
beanMethod.validate(problemReporter);
}
}
}