I've been trying to use Springs @AliasFor
annotation in a Kotlin project but it seems that the annotation on the annotation parameter isn't visible at runtime (hence it's not picked up by Spring).
For example:
@RequestMapping(method = arrayOf(RequestMethod.POST))
annotation class PostMapping(
@get:AliasFor(annotation = RequestMapping::class, attribute = "value")
vararg val value: String = arrayOf())
And...
// Returns empty array instead of array with the @AliasFor annotation
PostMapping::class.java.methods[0].annotations
Is there something I'm missing?
That's a bug in Kotlin, which is not fixed at the moment: KT-11475.
Issue seems to has been fixed within scope of KT-25287 i.e. snippet from question should work for Kotlin 1.3+.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With