TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
@Retention meta-annotation determines the lifecycle of a custom annotation, specifically dictating whether the annotation is discarded during compilation, stored in the compiled binary, or made accessible to the reflection API during program execution.
In Kotlin, retention policies are defined by the AnnotationRetention enum, which provides three distinct levels of visibility:
AnnotationRetention.SOURCE: The annotation exists only in the.ktsource files. It is stripped out by the compiler and is entirely absent from the resulting.classfiles.AnnotationRetention.BINARY: The annotation is preserved in the compiled.classfiles but is not loaded into the JVM at runtime. It cannot be accessed via reflection. This is analogous to Java’sRetentionPolicy.CLASS.AnnotationRetention.RUNTIME: The annotation is preserved in the compiled.classfiles and is loaded into the JVM, making it fully queryable at runtime using the Kotlin reflection API.
@Retention meta-annotation, Kotlin implicitly applies AnnotationRetention.RUNTIME as the default behavior.
Master Kotlin with Deep Grasping Methodology!Learn More





