Remove KotlinCompilerVersion.IS_PRE_RELEASE
Now, milestones of major Kotlin releases (e.g. 1.6.0-M1) will NOT generate prerelease binaries anymore. The reason for that is it's proven to be quite a complicated process to turn on IR_PRE_RELEASE after the release is branched, perform double bootstrap and fix tests, and then do it again in reverse just before release. With the new release cadence, we don't have that much time to do it and verify that everything works as intended. Note that this only removes the "global" prerelease flag. Compiler will still generate prerelease binaries if a non-stable language version is used. For example, Kotlin 1.6.0-M1 with `-language-version 1.7` will generate prerelease binaries.
This commit is contained in:
+16
-91
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.jvm.compiler
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
@@ -20,9 +19,6 @@ import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
import org.jetbrains.kotlin.cli.transformMetadataInClassFile
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion.TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
|
||||
@@ -38,7 +34,6 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparatorAdaptor.validateAndCompareDescriptorWithFile
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.org.objectweb.asm.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.ClassNode
|
||||
import java.io.ByteArrayInputStream
|
||||
@@ -115,29 +110,29 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
usageDestination: File,
|
||||
vararg additionalOptions: String
|
||||
) {
|
||||
// Compiles the library with the "pre-release" flag, then compiles a usage of this library in the release mode
|
||||
// Compiles the library with some non-stable language version, then compiles a usage of this library with stable LV.
|
||||
// If there's no non-stable language version yet, the test does nothing.
|
||||
val someNonStableVersion = LanguageVersion.values().firstOrNull { it > LanguageVersion.LATEST_STABLE } ?: return
|
||||
|
||||
val result = withPreRelease(true) {
|
||||
val libraryOptions = listOf(
|
||||
"-language-version", someNonStableVersion.versionString,
|
||||
// Suppress the "language version X is experimental..." warning.
|
||||
"-Xsuppress-version-warnings"
|
||||
)
|
||||
|
||||
val result =
|
||||
when (compiler) {
|
||||
is K2JSCompiler -> compileJsLibrary(libraryName)
|
||||
is K2JVMCompiler -> compileLibrary(libraryName)
|
||||
is K2JSCompiler -> compileJsLibrary(libraryName, additionalOptions = libraryOptions)
|
||||
is K2JVMCompiler -> compileLibrary(libraryName, additionalOptions = libraryOptions)
|
||||
else -> throw UnsupportedOperationException(compiler.toString())
|
||||
}
|
||||
}
|
||||
|
||||
withPreRelease(false) {
|
||||
compileKotlin("source.kt", usageDestination, listOf(result), compiler, additionalOptions.toList())
|
||||
}
|
||||
compileKotlin(
|
||||
"source.kt", usageDestination, listOf(result), compiler,
|
||||
additionalOptions.toList() + listOf("-language-version", LanguageVersion.LATEST_STABLE.versionString)
|
||||
)
|
||||
}
|
||||
|
||||
private fun <T> withPreRelease(value: Boolean, block: () -> T): T =
|
||||
try {
|
||||
System.setProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY, value.toString())
|
||||
block()
|
||||
} finally {
|
||||
System.clearProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
fun testRawTypes() {
|
||||
@@ -311,31 +306,6 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
doTestPreReleaseKotlinLibrary(K2JVMCompiler(), "library", tmpdir, "-Xskip-metadata-version-check")
|
||||
}
|
||||
|
||||
fun testPreReleaseCompilerAgainstPreReleaseLibraryStableLanguageVersion() {
|
||||
withPreRelease(true) {
|
||||
val library = compileLibrary("library")
|
||||
val someStableReleasedVersion = LanguageVersion.values().first { it.isStable && it >= LanguageVersion.FIRST_SUPPORTED }
|
||||
compileKotlin(
|
||||
"source.kt", tmpdir, listOf(library), K2JVMCompiler(),
|
||||
listOf("-language-version", someStableReleasedVersion.versionString)
|
||||
)
|
||||
|
||||
checkPreReleaseness(File(tmpdir, "usage/SourceKt.class"), shouldBePreRelease = false)
|
||||
}
|
||||
}
|
||||
|
||||
fun testPreReleaseCompilerAgainstPreReleaseLibraryLatestStable() {
|
||||
withPreRelease(true) {
|
||||
val library = compileLibrary("library")
|
||||
compileKotlin(
|
||||
"source.kt", tmpdir, listOf(library), K2JVMCompiler(),
|
||||
listOf("-language-version", LanguageVersion.LATEST_STABLE.versionString)
|
||||
)
|
||||
|
||||
checkPreReleaseness(File(tmpdir, "usage/SourceKt.class"), shouldBePreRelease = true)
|
||||
}
|
||||
}
|
||||
|
||||
fun testWrongMetadataVersion() {
|
||||
doTestKotlinLibraryWithWrongMetadataVersion("library", null)
|
||||
}
|
||||
@@ -685,25 +655,6 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
assertEquals("Output:\n$output", ExitCode.INTERNAL_ERROR, exitCode)
|
||||
}
|
||||
|
||||
// If this test fails, then bootstrap compiler most likely should be advanced
|
||||
fun testPreReleaseFlagIsConsistentBetweenBootstrapAndCurrentCompiler() {
|
||||
val bootstrapCompiler = JarFile(PathUtil.kotlinPathsForCompiler.compilerPath)
|
||||
val classFromBootstrapCompiler = bootstrapCompiler.getEntry(LanguageFeature::class.java.name.replace(".", "/") + ".class")
|
||||
checkPreReleaseness(
|
||||
bootstrapCompiler.getInputStream(classFromBootstrapCompiler).readBytes(),
|
||||
KotlinCompilerVersion.isPreRelease()
|
||||
)
|
||||
}
|
||||
|
||||
fun testPreReleaseFlagIsConsistentBetweenStdlibAndCurrentCompiler() {
|
||||
val stdlib = JarFile(PathUtil.kotlinPathsForCompiler.stdlibPath)
|
||||
val classFromStdlib = stdlib.getEntry(KotlinVersion::class.java.name.replace(".", "/") + ".class")
|
||||
checkPreReleaseness(
|
||||
stdlib.getInputStream(classFromStdlib).readBytes(),
|
||||
KotlinCompilerVersion.isPreRelease()
|
||||
)
|
||||
}
|
||||
|
||||
fun testAnonymousObjectTypeMetadata() {
|
||||
val library = compileCommonLibrary(
|
||||
libraryName = "library",
|
||||
@@ -798,31 +749,5 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
|
||||
return outputFile
|
||||
}
|
||||
|
||||
private fun checkPreReleaseness(classFileBytes: ByteArray, shouldBePreRelease: Boolean) {
|
||||
// If there's no "xi" field in the Metadata annotation, it's value is assumed to be 0, i.e. _not_ pre-release
|
||||
var isPreRelease = false
|
||||
|
||||
ClassReader(classFileBytes).accept(object : ClassVisitor(Opcodes.API_VERSION) {
|
||||
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
|
||||
if (desc != JvmAnnotationNames.METADATA_DESC) return null
|
||||
|
||||
return object : AnnotationVisitor(Opcodes.API_VERSION) {
|
||||
override fun visit(name: String, value: Any) {
|
||||
if (name != JvmAnnotationNames.METADATA_EXTRA_INT_FIELD_NAME) return
|
||||
|
||||
isPreRelease = (value as Int and JvmAnnotationNames.METADATA_PRE_RELEASE_FLAG) != 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0)
|
||||
|
||||
TestCase.assertEquals("Pre-release flag of the class file has incorrect value", shouldBePreRelease, isPreRelease)
|
||||
}
|
||||
|
||||
|
||||
private fun checkPreReleaseness(file: File, shouldBePreRelease: Boolean) {
|
||||
checkPreReleaseness(file.readBytes(), shouldBePreRelease)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user