https://kotlinlang.org logo
#reflect
Title
# reflect
j

janvladimirmostert

09/09/2017, 10:04 AM
I'm trying to invoke a function, but I 'm getting
Copy code
java.lang.IllegalArgumentException: Callable expects 4 arguments, but 3 were provided.
This is the place where I'm doing the call:
Copy code
annotation.listeners.forEach { listener: KClass<*> ->
					listener.functions.forEach { function: KFunction<*> ->
						if (function.name == "before") {
							function.call(annotation.action, request, response)
						}
					}
				}
And this is the method on the interface that's being called:
Copy code
interface ControllerListener {
	fun before(action: String, request: RestRequest, response: RestResponse)
	fun after(action: String, request: RestRequest, response: RestResponse)
}
What should the fourth paramater be?
i

ilya.gorbunov

09/09/2017, 10:29 AM
an instance of that interface
it should be the first argument.
j

janvladimirmostert

09/09/2017, 10:39 AM
ah, yes, that makes sense, thanks Ilya!
8 Views