findAnnotations

JVM
1.7
fun <reified T : Annotation> KAnnotatedElement.findAnnotations(): List<T>
(source)
fun <T : Annotation> KAnnotatedElement.findAnnotations(
    klass: KClass<T>
): List<T>

(source)

Returns all annotations of the given type on this element, including individually applied annotations as well as repeated annotations.

In case the annotation is repeated, instances are extracted from the container annotation class similarly to how it happens in Java reflection (java.lang.reflect.AnnotatedElement.getAnnotationsByType). This is supported both for Kotlin-repeatable (kotlin.annotation.Repeatable) and Java-repeatable (java.lang.annotation.Repeatable) annotation classes.