Fix BeanUtils#instantiateClass w/ Kotlin + noarg constructor
Issue: SPR-15851
This commit is contained in:
@@ -734,12 +734,11 @@ public abstract class BeanUtils {
|
||||
* Instantiate a Kotlin class using the provided constructor.
|
||||
* @param ctor the constructor of the Kotlin class to instantiate
|
||||
* @param args the constructor arguments to apply (use null for unspecified parameter if needed)
|
||||
* @throws BeanInstantiationException if no primary constructor can be found
|
||||
*/
|
||||
public static <T> T instantiateClass(Constructor<T> ctor, Object... args) {
|
||||
public static <T> T instantiateClass(Constructor<T> ctor, Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||
KFunction<T> kotlinConstructor = ReflectJvmMapping.getKotlinFunction(ctor);
|
||||
if (kotlinConstructor == null) {
|
||||
throw new BeanInstantiationException(ctor.getDeclaringClass(), "No corresponding Kotlin constructor found");
|
||||
return ctor.newInstance(args);
|
||||
}
|
||||
List<KParameter> parameters = kotlinConstructor.getParameters();
|
||||
Map<KParameter, Object> argParameters = new HashMap<>(parameters.size());
|
||||
|
||||
Reference in New Issue
Block a user