File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
spring-beans/src/main/java/org/springframework/beans Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -320,33 +320,33 @@ else if (!method.isBridge() && targetMethod.getParameterCount() == numParams) {
320
320
321
321
/**
322
322
* Return the primary constructor of the provided class (single or default constructor
323
- * for Java classes and primary constructor for Kotlin classes) if any.
323
+ * for Java classes and primary constructor for Kotlin classes), if any.
324
324
* @param clazz the {@link Class} of the Kotlin class
325
- * @see <a href="http://kotlinlang.org/docs/reference/classes.html#constructors">http://kotlinlang.org/docs/reference/classes.html#constructors</a>
326
325
* @since 5.0
326
+ * @see <a href="http://kotlinlang.org/docs/reference/classes.html#constructors">Kotlin docs</a>
327
327
*/
328
328
@ SuppressWarnings ("unchecked" )
329
329
@ Nullable
330
330
public static <T > Constructor <T > findPrimaryConstructor (Class <T > clazz ) {
331
331
Assert .notNull (clazz , "Class must not be null" );
332
332
Constructor <T > ctor = null ;
333
333
if (kotlinPresent && isKotlinClass (clazz )) {
334
- ctor = KotlinDelegate .findPrimaryConstructor (clazz );
334
+ return KotlinDelegate .findPrimaryConstructor (clazz );
335
335
}
336
336
else {
337
- Constructor <T >[] ctors = (Constructor <T >[])clazz .getConstructors ();
337
+ Constructor <T >[] ctors = (Constructor <T >[]) clazz .getConstructors ();
338
338
if (ctors .length == 1 ) {
339
- ctor = ctors [0 ];
339
+ return ctors [0 ];
340
340
}
341
341
else {
342
342
try {
343
- ctor = clazz .getDeclaredConstructor ();
343
+ return clazz .getDeclaredConstructor ();
344
344
}
345
- catch (NoSuchMethodException e ) {
345
+ catch (NoSuchMethodException ex ) {
346
+ return null ;
346
347
}
347
348
}
348
349
}
349
- return ctor ;
350
350
}
351
351
352
352
/**
You can’t perform that action at this time.
0 commit comments