https://kotlinlang.org logo
Title
j

jameskleeh

01/21/2022, 8:45 PM
Hey folks I’m having issues with annotations on annotation members
Basically there is an annotation written in Java with
@Target({ElementType.METHOD})
Intellij complains I can’t put the annotation on the property
So I have to put it on the getter with
@getter:AliasFor
, however then the annotation is not present on the property itself any longer
So basically my question is how can I get the annotation to be present in KSP on the property itself
e

evant

01/21/2022, 9:39 PM
It should be on property.getter if you do that
👍 2
j

jameskleeh

01/22/2022, 7:02 AM
Yeah it is, but that isn’t ideal. I would like to change it so the annotation is present on the property itself
I don’t know what Java ElementType target combined with any or no use site target would allow for that
Unfortunately it seems if the annotation is written in Java I have to handle that behavior differently than if the annotation is written in Kotlin
There doesn’t seem to be any Java ElementType target that allows for the annotation to target the property
p

philglass

01/22/2022, 8:44 AM
There isn't - properties aren't a concept that exist in Java. You have to use something Java understands (i.e. method/field/parameter) or convert the annotation to Kotlin.