From d82c50804f04068275ee41d4f1c7e4365f3027df Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 25 Apr 2013 16:51:11 +0100 Subject: [PATCH] [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] --- .../org/springframework/bootstrap/BeanDefinitionLoader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-bootstrap/src/main/java/org/springframework/bootstrap/BeanDefinitionLoader.java b/spring-bootstrap/src/main/java/org/springframework/bootstrap/BeanDefinitionLoader.java index 0305c1763df..53f66aa3ecf 100644 --- a/spring-bootstrap/src/main/java/org/springframework/bootstrap/BeanDefinitionLoader.java +++ b/spring-bootstrap/src/main/java/org/springframework/bootstrap/BeanDefinitionLoader.java @@ -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;