Hi! We have a problem that we can’t use kotlin.ref...
# ksp
d
Hi! We have a problem that we can’t use kotlin.reflect inside our processors. When the processor calls some jvm specific reflect function (like isOpen, or javaGetter) an exception is thrown. Here’s the explanation why it happens, despite kotlin.reflect being among processor dependencies (as
implementation(kotlin("reflect"))
, and also if it’s specified as ksp dependency as
ksp(kotlin("reflect")
in the generated module. Kotlin stdlib works with the reflection in a special way. There is
kotlin.jvm.internal.Reflection
class which in its static section tries to do
Class.forName("kotlin.reflect.jvm.internal.ReflectionFactoryImpl")
If it doesn’t succeed then all later reflection calls will not work and will throw exception. The class being loaded is not in stdlib, but in reflect. At this stage (static section) the current classpath contains only what KSP has put there during configuring KspAATask, namely the 5 jars listed in KspAATask.kt starting from line 143 (as of tag 2.1.0-1.0.29). Even coroutines jar is there. However, reflect is not. Could reflect.jar be placed there as well, given its special treatment by stdlib? Thanks!
If the idea itself is ok, I could make a PR