Search code examples
kotlinkotlin-multiplatform

Why is kotlin.jvm package accessible in commonMain for Kotlin multi-platform project?


I see that for a multi-platform Kotlin project, you can access Kotlin.jvm package in the commonMain.

For example, I could use (without any compilation error) kotlin.jvm.Synchronized

commonMain is shared by all platforms, does this mean for iOS platform kotlin.jvm.Synchronized would work fine? If yes, then why is it under a jvm package?


Solution

  • It would do nothing on iOS, but it allows you to add that annotation in common code without needing to do something complex with expect/actual. It would obviously be pointless in Kotlin/JS (single-threaded).