I'm developing a gradle plugin and it needs to reflect over some kotlin classes to generate some code but they are not visible in JRE with the same name and I don't know how to access them correctly.
I know that in this case kotlin.Any
becomes java.lang.Object
, but how do I detect that in runtime?
fun getClassFromKotlinName(kotlinName: String): Class<*>{ // Maybe return KClass<*> too if easier
return Class.forName(kotlinName)
}
fun main() {
println(getClassFromKotlinName("kotlin.Any"))
}
This causes:
Execution failed for task ':generateJvmCommonSources'.
> java.lang.ClassNotFoundException: kotlin.Any
How can I solve that?
Aucun commentaire:
Enregistrer un commentaire