masteramyx
12/27/2022, 5:56 PMmasteramyx
12/27/2022, 5:57 PMimport kotlin.concurrent.thread
import kotlinx.coroutines.*
// OutOfMemory Error
//fun main() {
// repeat(100_000){
// thread {
// Thread.sleep(1000L)
// print(".")
// }
// }
//}
fun main(args: Array<String>) {
runBlocking {
repeat(100_000) {
launch {
delay(1000L)
print(".")
}
}
}
}
2.
In the same folder as file, I have kotlinx-coroutines-core-1.6.4.jar
3.
Compile Command
kotlinc File.kt -cp kotlinx-coroutines-core-1.6.4.jar -include-runtime -d File.jar
4.
Error output:
File.kt:15:5: error: unresolved reference: runBlocking
runBlocking {
^
File.kt:17:13: error: unresolved reference: launch
launch {
^
File.kt:18:17: error: unresolved reference: delay
delay(1000L)
^
Shouldn't -cp
expose those class files for the import?leandro
12/27/2022, 7:19 PMkotlinx-coroutines-core-1.6.4.jar
on both the compile as well as the runtime classpath? from your third point it seems that it isn’t?!Joffrey
12/28/2022, 4:15 PMmasteramyx
12/28/2022, 4:51 PMJoffrey
12/28/2022, 4:57 PM-cp
argument might be required to appear before the File.kt
argument, but maybe that's not the case.leandro
12/28/2022, 5:00 PMSidney Beekhoven
12/29/2022, 12:09 PMkotlinx-coroutines-core-jvm-1.6.4.jar
)masteramyx
12/29/2022, 2:37 PMkotlinc-native
Sidney Beekhoven
12/31/2022, 12:17 PMkotlinx-coroutines-core-macosarm64
masteramyx
01/03/2023, 3:06 PMkotlinx-coroutines-core
dependency is used for then.
Is this library mainly for common code in Multiplatform projects? Only to be used in commonMain
?
And if I had additional android platform coroutine requirements, I would need to include the dependencies like kotlinx-coroutines-core-jvm
in the android
layer?Joffrey
01/03/2023, 3:46 PMkotlinx-coroutines-core
dependency. Gradle knows how to read metadata and fetch the relevant artifacts on the relevant platforms. However, if you decide to call the compiler by hand yourself, you'll have to deal with the subtleties like thisJoffrey
01/03/2023, 3:49 PMkotlinx-coroutines-core
in commonMain
in a multiplatform project, you don't have to also add the -jvm
variant in android/JVM source set dependencies.