Browse Source

[bs-73] Tweak algorithm for detecting anonymous classes

Apparently an anonymous class in Groovy is no anonymous in the compiled code,
so we need another heuristic.  We now check for non-existence of public
constructors (if there are none then there's no point regsistering that
class with an application context).

[#48718891]
pull/1/head
Dave Syer 13 years ago
parent
commit
d82c50804f
  1. 3
      spring-bootstrap/src/main/java/org/springframework/bootstrap/BeanDefinitionLoader.java

3
spring-bootstrap/src/main/java/org/springframework/bootstrap/BeanDefinitionLoader.java

@ -156,7 +156,8 @@ class BeanDefinitionLoader { @@ -156,7 +156,8 @@ class BeanDefinitionLoader {
private boolean isComponent(Class<?> type) {
// Nested anonymous classes are not eligible for registration, nor are groovy
// closures
if (type.isAnonymousClass() || type.getName().contains("$_closure")) {
if (type.isAnonymousClass() || type.getName().contains("$_closure")
|| type.getConstructors() == null || type.getConstructors().length == 0) {
return false;
}
return true;

Loading…
Cancel
Save