package test.annotations import kotlin.* import kotlin.test.assertTrue import org.junit.Test as test import java.lang.annotation.* Retention(RetentionPolicy.RUNTIME) annotation class MyAnno MyAnno Deprecated class AnnotatedClass class AnnotationTest { test fun annotationType() { val annotations = javaClass().getAnnotations()!! var foundMyAnno = false var foundDeprecated = false for (annotation in annotations) { val clazz = annotation!!.annotationType() when { clazz == javaClass() -> foundMyAnno = true clazz == javaClass() -> foundDeprecated = true else -> {} } } assertTrue(foundMyAnno) assertTrue(foundDeprecated) } }