953b461c53
From now on, the old JVM backend will report an error by default when compiling against class files produced by the JVM IR backend. This is needed because we're not yet sure that the ABI generated by JVM IR is fully correct and do not want to land in a 2-dimensional compatibility situation where we'll need to consider twice more scenarios when introducing any breaking change in the language. This is generally OK since the JVM IR backend is still going to be experimental in 1.4. However, for purposes of users which _do_ need to compile something with the old backend against JVM IR, we provide two new compiler flags: * -Xallow-jvm-ir-dependencies -- allows to suppress the error when compiling with the old backend against JVM IR. * -Xir-binary-with-stable-api -- allows to mark the generated binaries as stable, when compiling anything with JVM IR, so that dependent modules will compile even with the old backend automatically. In this case, the author usually does not care for the generated ABI, or s/he ensures that it's consistent with the one expected by the old compiler with some external tools. Internally, this is implemented by storing two new flags in kotlin.Metadata: one tells if the class file was compiled with the JVM IR, and another tells if the class file is stable (in case it's compiled with JVM IR). Implementation is similar to the diagnostic reported by the pre-release dependency checker.
79 lines
3.4 KiB
Kotlin
79 lines
3.4 KiB
Kotlin
/*
|
|
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
* 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 JVM names on purpose: these names appear in all 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.
|
|
*/
|
|
@get:JvmName("k")
|
|
val kind: Int = 1,
|
|
/**
|
|
* The version of the metadata provided in the arguments of this annotation.
|
|
*/
|
|
@get:JvmName("mv")
|
|
val metadataVersion: IntArray = [],
|
|
/**
|
|
* The version of the bytecode interface (naming conventions, signatures) of the class file annotated with this annotation.
|
|
*/
|
|
@get:JvmName("bv")
|
|
val bytecodeVersion: IntArray = [],
|
|
/**
|
|
* Metadata in a custom format. The format may be different (or even absent) for different kinds.
|
|
*/
|
|
@get:JvmName("d1")
|
|
val data1: Array<String> = [],
|
|
/**
|
|
* 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.
|
|
*/
|
|
@get:JvmName("d2")
|
|
val data2: Array<String> = [],
|
|
/**
|
|
* An extra string. For a multi-file part class, internal name of the facade class.
|
|
*/
|
|
@get:JvmName("xs")
|
|
val extraString: 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")
|
|
@get:JvmName("pn")
|
|
val packageName: 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 ([metadataVersion]).
|
|
* * 4 - this class file is compiled with the new Kotlin compiler backend introduced in Kotlin 1.4.
|
|
* * 5 - if the class file is compiled with the new Kotlin compiler backend, the metadata has been verified by the author and
|
|
* no metadata incompatibility diagnostic should be reported at the call site.
|
|
*/
|
|
@SinceKotlin("1.1")
|
|
@get:JvmName("xi")
|
|
val extraInt: Int = 0
|
|
)
|