Metadata

JVM
1.3
@Target([AnnotationTarget.CLASS]) annotation class Metadata
(source)

This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size.

Constructors

JVM
1.0

<init>

This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size.

Metadata(
    kind: Int = 1,
    metadataVersion: IntArray = [],
    bytecodeVersion: IntArray = [1, 0, 3],
    data1: Array<String> = [],
    data2: Array<String> = [],
    extraString: String = "",
    packageName: String = "",
    extraInt: Int = 0)

Properties

JVM
1.0

bytecodeVersion

The version of the bytecode interface (naming conventions, signatures) of the class file annotated with this annotation.

val bytecodeVersion: IntArray
JVM
1.0

data1

Metadata in a custom format. The format may be different (or even absent) for different kinds.

val data1: Array<String>
JVM
1.0

data2

An addition to data1: array of strings which occur in metadata, written in plain text so that strings already present in the constant pool are reused. These strings may be then indexed in the metadata by an integer index in this array.

val data2: Array<String>
JVM
1.1

extraInt

An extra int. Bits of this number represent the following flags:

val extraInt: Int
JVM
1.0

extraString

An extra string. For a multi-file part class, internal name of the facade class.

val extraString: String
JVM
1.0

kind

A kind of the metadata this annotation encodes. Kotlin compiler recognizes the following kinds (see KotlinClassHeader.Kind):

val kind: Int
JVM
1.0

metadataVersion

The version of the metadata provided in the arguments of this annotation.

val metadataVersion: IntArray
JVM
1.2

packageName

Fully qualified name of the package this class is located in, from Kotlin's point of view, or empty string if this name does not differ from the JVM's package FQ name. These names can be different in case the JvmPackageName annotation is used. Note that this information is also stored in the corresponding module's .kotlin_module file.

val packageName: String

Extension Properties

JVM
1.0

annotationClass

Returns a KClass instance corresponding to the annotation type of this annotation.

val <T : Annotation> T.annotationClass: KClass<out T>