How to annotate getters



If I have a property defined, the annotation that I placed on the property will be actually an annotation placed on the backing field. Some frameworks (for example JAXB) goes confused if it finds an annotated field and a getter and it will take as if the same property was declared twice and fail with error. In such cases it is useful to place the annotation on the getter. How can I do this in kotlin?


You literally annotate the getter:

val foo: Int = 1   [ann] get


Ah the brackets make it work on getters. Since the brackets are optional elsewhere, I stoped using them. Is it possible to make it work without []? I believe users would find it convinient.


Hard to tell right away, but probably yes, it is possible