Hey, there! Does anybody knows why property `annot...
# reflect
i
Hey, there! Does anybody knows why property
annotations
for
KClass
returns empty array?
Hmmm, btw i just tried to call
ActionBarContainer::class.java.annotations
and it returns empty array too
g
on which context do you call it? on runtime? If so, it’s expected, RestrictTo has CLASS Retention policy, so it doesn’t exist on runtime, only in bytecode
i
I am not sure ( I'll tried to create a
Generator
, which runs by launch
fun main
and works with android sdk classes by reflection, but after many fails with
kts
scripts and pure java library i've created android library (to access android View classes with reflection) I launch my Generator by click
play
in AS interface. Assume it may be a runtime. Depends on how this
main
launches
g
yes, it’s on runtime, so you do not work with bytecode So you cannot get RestrictTo annotation, it’s not a part of runtime, it exist only in sources and bytecode
i
maybe you know what (and how) i should do to reach that annotation? I assume that i must create pure java library and find a way to access android sdk classes? Or there
ClassLoader
can help to save my life?
g
No, you have to read it from .class file (or .dex if it Android)