Improve support of Kotlin beans w/ primary and default ctors

This commit add the default constructor if available as
fallback after to the primary constructor.

Issue: SPR-16012
This commit is contained in:
Sebastien Deleuze
2017-09-27 11:10:22 +02:00
parent ec5969c578
commit fb09a75c82
2 changed files with 38 additions and 1 deletions

View File

@@ -367,7 +367,9 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
candidateConstructors = new Constructor<?>[] {rawCandidates[0]};
}
else if (kotlinPrimaryConstructor != null) {
candidateConstructors = new Constructor<?>[] {kotlinPrimaryConstructor};
candidateConstructors = (defaultConstructor != null ?
new Constructor<?>[] {kotlinPrimaryConstructor, defaultConstructor} :
new Constructor<?>[] {kotlinPrimaryConstructor});
}
else {
candidateConstructors = new Constructor<?>[0];