title: How to run suspend method via reflection?
body: <p>There is an coroutine block that can runs suspend functions.</p>
  
  <p>But I call the function by <code>invoke</code> via reflection. This is java style invocation, apparently a simple call will not work.
  Are there ways to run reflected method asynchronously? How to await this method?</p>
  
  <pre><code>import kotlin.coroutines.experimental.*
  
  class TestClass(val InString: String) {
      suspend fun printString() {
          println(InString)
      }
  }
  
  fun launch(context: CoroutineContext, block: suspend () -&gt; Unit) =
          block.startCoroutine(StandaloneCoroutine(context))
  
  private class StandaloneCoroutine(override val context: CoroutineContext): Continuation&lt;Unit&gt; {
      override fun resume(value: Unit) {}
  
      override fun resumeWithException(exception: Throwable) {
          val currentThread = Thread.currentThread()
          currentThread.uncaughtExceptionHandler.uncaughtException(currentThread, exception)
      }
  }
  
  fun main(args: Array&lt;String&gt;) {
      launch(EmptyCoroutineContext) {
          val a = TestClass("TestString");
  
          for (method in a.javaClass.methods) {
              if (method.name == "printString")
                  method.invoke(a)  // Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments 
  
          }
      }
  }
  </code></pre>