Callables
We refer to functions and properties as callables. When appropriately annotated, callables can be invoked from either side of the JNI interface (frontend or backend), execute your code on the other side and return some value.
Functions
For a function to be available on the JVM side, it must be annotated with the @Knee
annotation.
We support top-level functions and functions nested in @KneeClass
declarations, as you can learn in classes.
Upward functions (called from K/N, implemented on the JVM) are also available through interfaces.
kotlin// Kotlin/Native
@Knee fun topLevelFunction(): Int {
return 42
}
// Kotlin/JVM
check(topLevelFunction() == 42)
Properties
For a property to be available on the JVM side, it must be annotated with the @Knee
annotation.
We support top-level properties and properties nested in @KneeClass
declarations, as you can learn in classes.
Upward properties (called from K/N, implemented on the JVM) are also available through interfaces.
Both var
and val
properties are supported.
kotlin// Kotlin/Native
@Knee val immutableProp: Int = 42
@Knee var mutableProp: Int = 0
// Kotlin/JVM
mutableProp = immutableProp
check(mutableProp == immutableProp)
On this page
More
- Free Doc Hosting
- Newsletter