Not sure if this is the best channel to ask, but d...
# compiler
n
Not sure if this is the best channel to ask, but do Kotlin lambdas not exist as a runtime interface? For example,
Class.forName("kotlin.Function0")
fails. And is there a way to have them exist? Maybe some compiler flag? I want to call the invoke function from JNI.
d
kotlin.Function
and
kotlin.coroutines.SuspendFunction
are not exists at runtime On JVM they are mapped to
kotlin.jvm.functions.FunctionN
n
I see, thanks. I wasn’t able to make it work for suspend functions, finally I found out it’s mapped to
kotlin.jvm.functions.Function(N+1)
. For the continuation I guess
Btw it would be nice if these things were handled by
org.jetbrains.kotlin.resolve.jvm.JvmClassName
. For lambdas but also more common things like kotlin/String, kotlin/Any (should be java/lang) which are hardly useful
d
What do you mean? java.lang mappings exist only during compilation on jvm. In js and native there are actual kotlin. classes
n
I mean, as a plugin author, I am using
JvmClassName
to get a JVM friendly name, with
/
,
$
and so on. I was saying that it would be nice if
JvmClassName
also did the string conversion between impossible types like kotlin/Any => java/lang/Object and more delicate ones like suspend functions
d
Well,
JvmClassName
is an internal utility which does what it does If you want to map kotlin classes to java runtime you can use `KotlinTypeMapper`/`IrTypeMapper`
u
You can also use
JavaToKotlinClassMap
just for the class name mapping logic
n
Looks promising, thanks!