Started playing with kapt, but cannot get Kotlin R...
# reflect
m
Started playing with kapt, but cannot get Kotlin Reflection from
RoundEnvironment
. Got
TypeElement
but don’t have any idea how to make KClass out of that. Any ideas?
d
You can't,
KClass
is a runtime representation. But during kapt the code is still being compiled, there is no runtime. What you can do is extract the
@kotlin.Metadata
annotation from the classes and then use
kotlinx-metadata-jvm
to parse the Kotlin-specific information. Its not as easy to use as just
KClass
, but if you absolutely need some Kotlin-specific information out of the class you can use it. https://github.com/JetBrains/kotlin/tree/master/libraries/kotlinx-metadata/jvm
m
Thanks