1d5d6b5b72
Preface: Kotlin 1.3 will be able to read metadata of .class files produced by Kotlin 1.4 (see KT-25972). Also, to simplify implementation and to improve diagnostic messages, we're going to advance JVM metadata version to 1.4.0 in Kotlin 1.4, and would like to keep it in sync with the compiler version thereafter. This presents a problem: in an unlikely event that before releasing 1.4, we find out that the metadata-reading implementation in 1.3 was incorrect, we'd like to be able to fix the bug in that implementation and _forbid_ 1.3 from reading metadata of 1.4. But prior to this commit the only way to do this was to advance the metadata version, in this case to 1.5, and that breaks the metadata/compiler version equivalence we'd like to keep. The solution is to add another boolean flag to the class file, called "strict metadata version semantics", which signifies that if this class file has metadata version 1.X, then it can only be read by the compilers of versions 1.X and greater. This flag effectively disables the smooth migration scenario proposed in KT-25972 (as does increasing metadata version by 2), and will be used only in hopeless situations as in the case described above.
68 lines
2.8 KiB
Kotlin
68 lines
2.8 KiB
Kotlin
/*
|
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
|
* that can be found in the license/LICENSE.txt file.
|
|
*/
|
|
|
|
package kotlin
|
|
|
|
/**
|
|
* 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 names on purpose: these names appear in the generated class files, and we'd like to reduce their size.
|
|
*/
|
|
@Retention(AnnotationRetention.RUNTIME)
|
|
@Target(AnnotationTarget.CLASS)
|
|
@SinceKotlin("1.3")
|
|
public annotation class Metadata(
|
|
/**
|
|
* A kind of the metadata this annotation encodes. Kotlin compiler recognizes the following kinds (see KotlinClassHeader.Kind):
|
|
*
|
|
* 1 Class
|
|
* 2 File
|
|
* 3 Synthetic class
|
|
* 4 Multi-file class facade
|
|
* 5 Multi-file class part
|
|
*
|
|
* The class file with a kind not listed here is treated as a non-Kotlin file.
|
|
*/
|
|
val k: Int = 1,
|
|
/**
|
|
* The version of the metadata provided in the arguments of this annotation.
|
|
*/
|
|
val mv: IntArray = [],
|
|
/**
|
|
* The version of the bytecode interface (naming conventions, signatures) of the class file annotated with this annotation.
|
|
*/
|
|
val bv: IntArray = [],
|
|
/**
|
|
* Metadata in a custom format. The format may be different (or even absent) for different kinds.
|
|
*/
|
|
val d1: Array<String> = [],
|
|
/**
|
|
* An addition to [d1]: 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 d2: Array<String> = [],
|
|
/**
|
|
* An extra string. For a multi-file part class, internal name of the facade class.
|
|
*/
|
|
val xs: String = "",
|
|
/**
|
|
* 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.
|
|
*/
|
|
@SinceKotlin("1.2")
|
|
val pn: String = "",
|
|
/**
|
|
* An extra int. Bits of this number represent the following flags:
|
|
*
|
|
* * 0 - this is a multi-file class facade or part, compiled with `-Xmultifile-parts-inherit`.
|
|
* * 1 - this class file is compiled by a pre-release version of Kotlin and is not visible to release versions.
|
|
* * 2 - this class file is a compiled Kotlin script source file (.kts).
|
|
* * 3 - the metadata of this class file is not supposed to be read by the compiler, whose major.minor version is less than
|
|
* the major.minor version of this metadata ([mv]).
|
|
*/
|
|
@SinceKotlin("1.1")
|
|
val xi: Int = 0
|
|
)
|