kotlinx.coroutines
kotlinx.coroutines copied to clipboard
`kotlinx.coroutines.debug`'s `module-info.java` is incorrect preventing any project using JPMS to use debug probes
Any usage of the kotlinx.coroutines.debug package, for example import kotlinx.coroutines.debug.DebugProbes results in:
[JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE] Symbol is declared in module 'kotlinx.coroutines.debug' which does not export package 'kotlinx.coroutines.debug'
The split package between kotlinx.coroutines.core and kotlinx.coroutines.debug of package kotlinx.coroutines.debug must be solved and cannot be hacked around by commenting its exports statement in kotlinx.coroutines.debug's module-info.java 😢.
To continue the investigation, using custom module loading code, we merged kotlin.stdlib, kotlinx.coroutines.core and kotlinx.coroutines.debug modules at runtime:
kotlinx.coroutines.coreandkotlinx.coroutines.debugto mitigate the package splitkotlin.stdlibto mitigate the circular dependency betweenkotlinx.coroutines.debugandkotlin.stdlibafter bytebuddy injection at runtimekotlin.stdlib--- (due to injected code) -->kotlinx.coroutines.debug->kotlinx.stdlib
That provided us with a few more information about what is wrong with the current module-info.java:
- some statements are missing (probably coming from the shadowing of bytebuddy):
requires com.sun.jna;
exports kotlinx.coroutines.repackaged.net.bytebuddy.agent to com.sun.jna;
- these redundant (bytebuddy being shadowed in the same module)
requirescrashes at runtime:
requires net.bytebuddy.agent;
requires net.bytebuddy;
- when used in production, the current declaration and structure of
kotlinx-coroutines-debugjar forces users to bring in jars to their runtime module path to fulfill:
requires org.junit.jupiter.api;
requires org.junit.platform.commons;
JUnit is not something one would want in production runtime module path 😅...
I did not find any suitable workaround to unblock ourselves. The only solution I see is to:
- fix the split package of
kotlinx.coroutines.debugpackage inkotlinx.coroutines.coreandkotlinx.coroutines.debug(providing an additional jar forkotlinx-coroutines-debugwith probably a new name likekotlinx-coroutines-debug2😄) - fix
module-info.javaissues pointed in point 1 and 2 - extract junit related utilities currently present in
kotlinx.coroutines.debug.junit4andkotlinx.coroutines.debug.junit5packages into additional jars (e.g.kotlinx-coroutines-debug-junit4andkotlinx-coroutines-debug-junit5), and removerequiresstatements of point 3
Related https://github.com/Kotlin/kotlinx.coroutines/issues/3633