I am trying to add support for kotest for a test intelligence tool. To do so, I need to be able to add the Ignored annotation to classes dynamically using a Java agent, but the annotation seems to not be visible to Kotlin.
The annotation is visible when using Java reflection. If I call MySpec::class.java.declaredAnnotations, I can see the annotation that I added. If I however, such as kotest, call MySpec::class.annotations, it is not visible.
If I add any unrelated annotation to MySpec, the annotation does show up, and suddenly my dynamic annotation also becomes visible.
What do I need to do to add an annotation to a Kotlin class and make it visible? What prevents Kotlin reflection to see the annotation that is clearly present on the class file?