-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Describe the bug
FastLoader will fail in a way that loading the MainDispatcherFactory will appear missing despite being on the classpath.
Kotlin 1.9.20-rc
Compose 1.5.10-beta02
Java 20
Coroutines 1.7.3
Provide a Reproducer
With fast loader on:
fun main() {
val factories = ServiceLoader.load(
MainDispatcherFactory::class.java,
MainDispatcherFactory::class.java.classLoader
).iterator().asSequence().toList()
println(factories)
val dispatcher = factories.maxByOrNull { it.loadPriority }?.tryCreateDispatcher(factories)
println(dispatcher)
println(Dispatchers.Main)
runBlocking(Dispatchers.Main) {
}
}
Log:
> Task :application:desktopApp:run
[kotlinx.coroutines.swing.SwingDispatcherFactory@f6c48ac]
Swing
Dispatchers.Main[missing]
Exception in thread "main" java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' and ensure it has the same version as 'kotlinx-coroutines-core'
at kotlinx.coroutines.internal.MainDispatchersKt.throwMissingMainDispatcherException(MainDispatchers.kt:81)
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.missing(MainDispatchers.kt:112)
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.isDispatchNeeded(MainDispatchers.kt:96)
at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:319)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:110)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:58)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at co.....AppKt.main(App.kt:54)
at co.....AppKt.main(App.kt)
You set System.setProperty("kotlinx.coroutines.fast.service.loader", "false")
> Task :application:desktopApp:run
[kotlinx.coroutines.swing.SwingDispatcherFactory@f6c48ac]
Dispatchers.Main
Dispatchers.Main
alexzhirkevich and yuriykulikovAlbRoehm