I've got a question for everybody who's interested...
# getting-started
s
I've got a question for everybody who's interested I wanted to put a Java annotation which can only be targeted to
ElementType.TYPE
and
ElementType.FIELD
on the field in a Kotlin interface. My annotation is set up like this in java:
Copy code
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD})
public @interface MyAnnoation {
}
To only put
@MyAnnotation
on the field within the interface and not on get/set functions, I thus use the annotation use-site target (as described in https://kotlinlang.org/docs/reference/annotations.html) to set the annotation like this:
Copy code
interface SomeInterface {
  @field:MyAnnotation val fieldX: TypeX
  val fieldY: TypeY
}
thinking this should work. I however still get the compile exception:
Error:(18, 5) Kotlin: This annotation is not applicable to target 'member property without backing field or delegate' and use site target '@field'
What's your guess, am I doing something wrong in my annotation or something in the way I try to set the annotation in the interface?