# How to annotate getters

**URL:** <https://discuss.kotlinlang.org/t/how-to-annotate-getters/566>\
**Category:** Uncategorized\
**Created:** [June 12, 2014, 3:19pm UTC](https://discuss.kotlinlang.org/t/how-to-annotate-getters/566 "2014-06-12T15:19:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kocka](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kocka](https://discuss.kotlinlang.org/u/kocka)\
**Post date:** [June 12, 2014, 3:19pm UTC](https://discuss.kotlinlang.org/t/how-to-annotate-getters/566/1 "2014-06-12T15:19:14Z")

</div>

Hi,

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?

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [June 12, 2014, 8:37pm UTC](https://discuss.kotlinlang.org/t/how-to-annotate-getters/566/2 "2014-06-12T20:37:07Z")

</div>

You literally annotate the getter:

```kotlin
val foo: Int = 1
  [ann] get
```

---

<div class="post-metadata">

**Author:** ![kocka](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kocka](https://discuss.kotlinlang.org/u/kocka)\
**Post date:** [June 12, 2014, 11:01pm UTC](https://discuss.kotlinlang.org/t/how-to-annotate-getters/566/3 "2014-06-12T23:01:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [June 13, 2014, 4:36am UTC](https://discuss.kotlinlang.org/t/how-to-annotate-getters/566/4 "2014-06-13T04:36:48Z")

</div>

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