-
-
Notifications
You must be signed in to change notification settings - Fork 135
Kotlin support internals
The process of understanding a .class
file originally contained Kotlin code depends strongly on the @kotlin.Metadata annotation. This annotation is written by the Kotlin compiler into every .class
file. It provides information about all language features which do not have a Java or bytecode analog. Example of such features are Kotlin properties, objects, data classes, and others. This information is stored in a protobuff serialized way and is used by Kotlin's internal runtime classes supporting reflection, type reification and other Kotlin features.
We use the @kotlin.Metadata annotation for several purposes: knowing a get/set method was originally a Kotlin property and knowing if a nested class was originally a companion object in Kotlin. Having the information from the annotation also enables supporting specific syntactic sugars for using Kotlin in NativeScript apps.
Reading this annotation is done using the kotlinx-metadata-jvm library by JetBrains.