How to get annotations from a property

hi, I use annotations to attach type info to property and I thought below code should work, but it didn’t.

annotation class embeddable(val entityType: KClass<*>)

data class Foo(val id: String, @embeddable(Bar::class) val bars: List<Bar>)
data class Bar(val id: String)

fun main() {
    val foo = Foo("f1", listOf(Bar("b1"), Bar("b2")))
    foo::class.memberProperties.forEach { println("${}:${it.annotations}") }

It prints


Do I miss anything?

As its name suggests, annotations with AnnotationRetention.SOURCE retention are available in the source code only and are removed when compiling. Use AnnotationRetention.RUNTIME instead.

Aha, thanks @broot