lundi 4 décembre 2017

Calling method in generic class through reflection

I am attempting to setup a function taking in a generic class that in turn calls a method within that class through reflection. Below code compiles, however when I run it I get this error:

java.lang.IllegalArgumentException: Callable expects 2 arguments, but 1 were provided.

Why does Kotlin claim there should be 2 arguments, when the method only takes one? What should the arguments be?

class myClass {
  fun setData(data: List<myData>) {
  //Do stuff
  }
}

fun <T: Any>ProcessStuff(
  @Autowired
  d : T,
) {
  val myClass  = d.let { it::class }

  var f3 = myClass.memberFunctions.find { it.name == "setData"}!!
  val r = (it.value as Deferred<List<myData>>).await()
  f3.call (r)
}





Aucun commentaire:

Enregistrer un commentaire