Hi there, Regarding <https://youtrack.jetbrains.co...
# kontributors
a
Hi there, Regarding KT-39144, I’m considering investigating how to extend Kotlin/Native’s C interop support to the JVM by leveraging the new Java 22 Foreign Function & Memory API (FFM). Before diving deeper, I’d appreciate guidance on the best way to contribute: 1. Should I start with a draft PR to prototype the integration and gather feedback? 2. Or would a KEEP proposal be more appropriate to align on design goals first?
j
I would start with a prototype, not a KEEP
I'm also not sure you actually need a KEEP, since you're not changing the language in any way. Just providing a new, optional build tool
Also sign me up as a first tester!
👍 1
d
cc @svyatoslav.scherbina
s
Hi.
I would start with a prototype, not a KEEP
Agree.
Regarding KT-39144, I’m considering investigating how to extend Kotlin/Native’s C interop support to the JVM by leveraging the new Java 22 Foreign Function & Memory API (FFM).
You might want to know that the cinterop tool already supports JVM internally, to some extent. See this entry point: https://github.com/JetBrains/kotlin/blob/bcd9f89b30af3c4fff48ea65c02ae2e8ece0a2ce/[…]nerator/src/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt It doesn't use FFM. Plain old JNI was enough.
a
Thank's for the feedback, I’ll dig into it. Regarding JNI vs FFM, major downside of FFM is that it forces users to adopt Java 22+, which could be a blocking point for many. That said, from a long-term perspective, even though Java contributors tend to be quite conservative, I’ve heard from oral discussions with a few of them that JNI usage might become increasingly cumbersome over time with feature flag to add and may be other restrictions. They also started to remove some API from Unsafe, that purely purely speculative but JNI could follow the same fate at some point.
s
JNI usage might become increasingly cumbersome over time with feature flag to add
Last time I checked, you also need to add flags for the restricted parts of FFM. Which you likely need for cinterop.
f
There's already a prototype aimed to unify FFI experience across different targets: https://github.com/whyoleg/ffi-kotlin
o
Hey! I'm the author of ffi-kotlin, and I would love to collaborate on the initiative (in my free time 😄). Feel free to DM me here in Slack if you want kodee naughty