I'm trying to use Kotlin Reflection to generate JFrames from Classes with their members. I have created a couple Annotations, some of them are present at runtime and some are not.
Component Annotation:
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.RUNTIME)
annotation class Component(val constraints: String = "")
IsEnabled Annotation:
@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.RUNTIME)
annotation class IsEnabled(val value: Boolean = true)
I'm using both of the Annotations like this:
class DisabledTest {
@Component
@IsEnabled(false)
val btn = JButton("Should be Disabled")
}
If I run the following code:
DisabledTest::class.declaredMembers.forEach {
println(it.name + ": " + it.annotations.map { a -> a.annotationClass.simpleName })
}
The only output I get is this:
btn: [Component]
What is happening to the @IsEnabled
Annotation because the Retention is set to AnnotationRetention.RUNTIME
?