Kotlin Annotation Reflection


#1

I’m trying to add all properties of an annotation instance to a list like this:

if (configuration != null) {
        val fields = configuration.javaClass.kotlin.memberProperties
        fields.forEach {
            if(it.visibility == KVisibility.PUBLIC) {
                properties.add(Pair<Any, Any?>(it.name, it.get(configuration)))
            }
        }
    }

yet i cannot retrieve the actual value of the annotation property. There is no accessor and no backing field present. I also search through java fields, but can’t seem to find a straight forward way to simply retrieve all property values.

How would one go about that?