Vivek Modi
03/23/2022, 11:34 AM@Retention(AnnotationRetention.BINARY)
What is Retention
, AnnotationRetention
and BINARY
?zsmb
03/23/2022, 11:50 AM@Retention
annotation controls whether usages an annotation are preserved when the code is compiled from source to binary. This matters if you want to keep the information about something being annotated available for runtime (for example, to read the annotation information using reflection).
AnnotationRetention
is a simple enum that contains the available retention options. See the docs which list the available options (source, binary, runtime) and explain what they mean:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.annotation/-annotation-retention/Vivek Modi
03/23/2022, 11:53 AMAnnotation is stored in binary output, but invisible for reflection
Vivek Modi
03/23/2022, 11:53 AMzsmb
03/23/2022, 11:57 AMVivek Modi
03/23/2022, 11:59 AM