Call class' constructor by reflection with Kotlin
You have to use the spread operator when invoking the newInstance()
method. And the signature of createEntity()
is wrong. I would recommend define it like that.
private fun <T> createEntity(constructor: Constructor<T>, vararg args: Any) : T { return constructor.newInstance(*args)}