JVM Job().join()

Hello. Please tell me why I am testing multiplatform kotlin code in IntelliJ using
fun SomeFun():Job = CoroutineScope(Dispatchers.Default).launch(){
// do something/…
}
SomeFun().join()
and get the expected result. The execution is waiting to be completed.
But, as soon as I built the application into artifacts and used the
compiled file as a library in JVM , I have a call SomeFun().join(…) requires Continuation as
an input parameter. What I should do? If I use
fun SomeFun():Promise = CoroutineScope(Dispatchers.Default).async(){
// do something/…
}
then in JVM just do the call SomeFun().await() is not available.
Although in the test of the project everything works.

join() is a suspend function, so you can’t invoke it easily from Java. You can either return a CompletableFuture using scope.future { } (you need kotlinx-coroutines-jdk8 library for it) or you can use runBlocking() if blocking a caller thread makes sense in your case.