mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
[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]
This commit is contained in:
parent
a2d328ae3a
commit
d82c50804f
|
@ -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…
Reference in New Issue
Block a user