I’m having an issue with the following. I wan to g...
# ksp
a
I’m having an issue with the following. I wan to get a Java generated class from my annotation. I pass Int, for instance, it works, but not the class that I would like to get to generate my file. Is this feasible, to get UserPreferences class?
Copy code
@Target(AnnotationTarget.CLASS)
annotation class WithProto(val value: Array<KClass<*>>)
@WithProto(value = [UserPreferences::class, Int::class])
I based my example on this https://kotlinlang.org/docs/annotations.html#constructors, Or would it be possible somehow cast the the kstype to an actual object?
j
if you want to get a class, maybe you can just try to use reflection? But from what you described,
UserPreferences
is generated, which means it is in source rather than in classpath, therefore reflection won’t work.
if you have a
Builder
class declared inside
UserPreferences
class, you should be able to get
UserPreferences
class from
parent
of
Builder
a
Ah! That’s interesting. I tried that and got
null
. Have to check what I missed. Thanks a lot