title: How to call Kotlin suspending coroutine function from Java 7
body: <p>I'm trying to call Kotlin function from Java 7. I'm using coroutines and this called function is suspending, for example:</p>
  
  <pre><code>suspend fun suspendingFunction(): Boolean {
      return async { longRunningFunction() }.await()
  }
  
  suspend fun longRunningFunction() : Boolean {
      delay(400)
      return true
  }
  </code></pre>
  
  <p>I was using coroutines in version 0.25.3 and I could emulate simple Java callback style by passing <code>Continuation&lt;U&gt;</code> instance as an argument to suspending function, e.g.</p>
  
  <pre class="lang-java prettyprint-override"><code>CoroutinesKt.suspendingFunction(new Continuation&lt;Boolean&gt;() {
      @Override
      public CoroutineContext getContext() {
          return EmptyCoroutineContext.INSTANCE;
      }
  
      @Override
      public void resume(Boolean value) {
          doSomethingWithResult(value);
      }
  
      @Override
      public void resumeWithException(@NotNull Throwable throwable) {
          handleException(throwable);
      }
  });
  </code></pre>
  
  <p>However, after updating to fully stable 1.0.1 release, I think it's no longer possible. Let's say updated version of suspending function looks like that:</p>
  
  <pre><code>suspend fun suspendingFunction(): Boolean {
      return GlobalScope.async { longRunningFunction() }.await()
  }
  </code></pre>
  
  <p><code>Continuation&lt;U&gt;</code> now uses <code>Result</code> class, which seems to be unusable from Java (which makes sense as it is inline class). I was trying to use some subclass of <code>Continuation</code> from coroutines but they are all internal or private.</p>
  
  <p>I know that usually it is <a href="https://stackoverflow.com/questions/52869672/call-kotlin-suspend-function-in-java-class">advised to transform coroutine to <code>CompletableFuture</code></a>, but I'm on Android, which means Java 7 only. Simple <code>Future</code> on the other hand is too dumb as I don't want to check periodically if function is finished - I just want to be called when it is finished. And I would really like to avoid adding new libraries or many additional classes/methods. </p>
  
  <p><strong>Is there any simple way to call suspending function directly from Java 7?</strong> </p>
  
  <p>As Kotlin tries to be very interoperable with Java I would imagine there would be some easy way to do that, but I'm yet to find it.</p>