<@U0BA343QR> You can study "CPS" section of the de...
# coroutines
e
@yoavst You can study "CPS" section of the design document. It explains how suspending functions are represented in JVM and that gives an answer on how to invoke them from Java: https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md#continuation-passing-style TL;DR -- that is now going to be very convenient. A better solution is to write a wrapper (in Kotlin). There are many possible styles in writing such a wrapper. Probably, the most flexible and Java-ish kind of a wrapper for Java interop is a function that returns a
CompletableFuture
. Assuming that you have the following suspending function:
Copy code
suspend fun doSomething(params: Params): Result
You can use
kotlinx-coroutines-jdk8
module of
kotlinx.coroutines
project to write:
Copy code
fun doSomethingAsync(params: Params): CompletableFuture<Result> = 
    future { doSomething(params) }
and then use
doSomethingAsync
from Java.