A use-site target selects the generated bytecode element that receives an annotation when one Kotlin declaration produces several Java declarations. Kotlin properties can correspond to a field, getter, setter, setter parameter, and sometimes a constructor parameter, so the annotation may need an explicit destination. section 12.1.2
Renaming a property's Java accessors
class CertificateManager { @get:JvmName("obtainCertificate") @set:JvmName("putCertificate") var certificate: String = "-----BEGIN PRIVATE KEY-----" } The target appears between @ and the annotation name: get applies @JvmName to the getter, while set applies it to the setter. Java code can then call obtainCertificate() and putCertificate() instead of the generated accessor names. section 12.1.2
Common use-site targets include:
- property: the Kotlin property itself. section 12.1.2
- field: the field generated for a property. section 12.1.2
- get and set: the property's getter and setter. section 12.1.2
- param and setparam: a constructor parameter or property setter parameter. section 12.1.2
- receiver, delegate, and file: an extension receiver, delegated-property field, or class containing top-level declarations. section 12.1.2
Figure 12.2 The use-site target (like get or set) is placed between the @ sign and the annotation name, and is separated from the name with a colon.
Use-site syntax places a target such as get or set between the at-sign and annotation name, separated by a colon. section 12.1.2
