TL;DR make it pluggable
There are some consideration to do.
@JvmAsync
affects annotated method
@JvmAsync
affects all suspending methods in a class
@JvmAsync
affects all suspending methods in an interface
I want to apply @JvmAsync
to all public suspending method in the project if build target isn’t Android
and so on…
All above consideration are valids
On other side the effective Future implementation choice may become highly questionable, use CompletableFuture
in Java 8 may be accettable but is unapplicable in Android.
Moreover a similar annotation @JsAsync
should be considered.
Finally provide for free a cross-language compatibility for coroutine (like @ScalaCoroutine) can sound good.
Probably the best choice is no choice at all: realize a pluggable system to implement easly all of those. (kapt?)
You can provide some plugins for JVM CompletableFuture
and JS Promise
.
Extra consideration: @JvmOverloads may became another plug-in.