invokeConstructorWithArgs

open fun <T> invokeConstructorWithArgs(@NonNull clazz: Class<T>, args: Array<Any>): T

Attempts to find and invoke the constructor of class T matching the specified arguments

Return

The constructed Object

Parameters

clazz

T.class

args

The arguments to invoke the constructor with. arguments [ "hello", 12 ] would match constructor(String s, int i)

<T>

The class

Throws

No such constructor found

This constructor is inaccessible

An exception occurred while invoking this constructor

This class cannot be constructed (is abstract, interface, etc)