I've got a question about interop between Kotlin a...
# multiplatform
a
I've got a question about interop between Kotlin and Java, which live in different gradle modules. In the shared module I've got:
Copy code
import kotlin.jvm.JvmStatic

data class ExampleThingy(
    val items: List<ItemThingy>,
) {
    companion object {
        @JvmStatic
        val EXAMPLE = ExampleThingy(
            items = listOf(
                ItemThingy("1"),
                ItemThingy("2"),
            )
        )
    }
}

data class ItemThingy(
    val id: String
)
In the java module, which imports the shared module, I have the following code:
Copy code
var exampleList = ExampleThingy.getEXAMPLE().getItems();
var thingy = new ExampleThingy(exampleList);
This compiles without warnings, but the IDE shows an error:
Unknown class: 'java.util.List<com.example.demo_kmp_java.ItemThingy>'
There I can't get any IDE assistance in the Java Code. Why does this happen and can I fix it? Sadly I have to work with the strict rule of "no Kotlin in the backend, not even a single file", but of course my backend needs to access stuff from my shared module.
Now I've been stripping my example code from everything that is not relevant and the error disappeared again. So this is probably an IDE bug 😞
The bug only surfaces in K2 mode.
My workaround: When working in Java, I disable K2 and whenever I work in Kotlin, I enable it.
🥲 1