findAnnotations

JVM
1.5
@ExperimentalStdlibApi fun <reified T : Annotation> KAnnotatedElement.findAnnotations(): List<T>
(source)
@ExperimentalStdlibApi 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.