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:
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.build
|
|||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
import org.jetbrains.kotlin.config.isPreRelease
|
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@@ -43,7 +42,7 @@ abstract class BuildMetaInfoFactory<T : BuildMetaInfo>(private val metaInfoClass
|
|||||||
val languageVersion = args.languageVersion?.let { LanguageVersion.fromVersionString(it) } ?: LanguageVersion.LATEST_STABLE
|
val languageVersion = args.languageVersion?.let { LanguageVersion.fromVersionString(it) } ?: LanguageVersion.LATEST_STABLE
|
||||||
|
|
||||||
return create(
|
return create(
|
||||||
isEAP = languageVersion.isPreRelease(),
|
isEAP = !languageVersion.isStable,
|
||||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||||
languageVersionString = languageVersion.versionString,
|
languageVersionString = languageVersion.versionString,
|
||||||
apiVersionString = args.apiVersion ?: languageVersion.versionString,
|
apiVersionString = args.apiVersion ?: languageVersion.versionString,
|
||||||
|
|||||||
+1
-24
@@ -15,23 +15,6 @@ public class KotlinCompilerVersion {
|
|||||||
public static final String VERSION_FILE_PATH = "/META-INF/compiler.version";
|
public static final String VERSION_FILE_PATH = "/META-INF/compiler.version";
|
||||||
public static final String VERSION;
|
public static final String VERSION;
|
||||||
|
|
||||||
// True if the latest stable language version supported by this compiler has not yet been released.
|
|
||||||
// Binaries produced by this compiler with that language version (or any future language version) are going to be marked
|
|
||||||
// as "pre-release" and will not be loaded by release versions of the compiler.
|
|
||||||
// Change this value before and after every major release
|
|
||||||
private static final boolean IS_PRE_RELEASE = false;
|
|
||||||
|
|
||||||
public static final String TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY = "kotlin.test.is.pre.release";
|
|
||||||
|
|
||||||
public static boolean isPreRelease() {
|
|
||||||
String overridden = System.getProperty(TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY);
|
|
||||||
if (overridden != null) {
|
|
||||||
return Boolean.parseBoolean(overridden);
|
|
||||||
}
|
|
||||||
|
|
||||||
return IS_PRE_RELEASE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return version of this compiler, or `null` if it isn't known (if VERSION is "@snapshot@")
|
* @return version of this compiler, or `null` if it isn't known (if VERSION is "@snapshot@")
|
||||||
*/
|
*/
|
||||||
@@ -40,6 +23,7 @@ public class KotlinCompilerVersion {
|
|||||||
return VERSION.equals("@snapshot@") ? null : VERSION;
|
return VERSION.equals("@snapshot@") ? null : VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"TryFinallyCanBeTryWithResources", "ConstantConditions"})
|
||||||
private static String loadKotlinCompilerVersion() throws IOException {
|
private static String loadKotlinCompilerVersion() throws IOException {
|
||||||
BufferedReader versionReader = new BufferedReader(
|
BufferedReader versionReader = new BufferedReader(
|
||||||
new InputStreamReader(KotlinCompilerVersion.class.getResourceAsStream(VERSION_FILE_PATH)));
|
new InputStreamReader(KotlinCompilerVersion.class.getResourceAsStream(VERSION_FILE_PATH)));
|
||||||
@@ -57,12 +41,5 @@ public class KotlinCompilerVersion {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to read compiler version from " + VERSION_FILE_PATH);
|
throw new IllegalStateException("Failed to read compiler version from " + VERSION_FILE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VERSION.equals("@snapshot@") && !VERSION.contains("-") && IS_PRE_RELEASE) {
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"IS_PRE_RELEASE cannot be true for a compiler without '-' in its version.\n" +
|
|
||||||
"Please change IS_PRE_RELEASE to false, commit and push this change to master"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.resolve
|
package org.jetbrains.kotlin.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.config.AnalysisFlags
|
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||||
@@ -17,7 +16,7 @@ class CompilerDeserializationConfiguration(languageVersionSettings: LanguageVers
|
|||||||
override val skipPrereleaseCheck = languageVersionSettings.getFlag(AnalysisFlags.skipPrereleaseCheck)
|
override val skipPrereleaseCheck = languageVersionSettings.getFlag(AnalysisFlags.skipPrereleaseCheck)
|
||||||
|
|
||||||
override val reportErrorsOnPreReleaseDependencies =
|
override val reportErrorsOnPreReleaseDependencies =
|
||||||
!skipPrereleaseCheck && !languageVersionSettings.isPreRelease() && !KotlinCompilerVersion.isPreRelease()
|
!skipPrereleaseCheck && !languageVersionSettings.isPreRelease()
|
||||||
|
|
||||||
override val allowUnstableDependencies = languageVersionSettings.getFlag(AnalysisFlags.allowUnstableDependencies)
|
override val allowUnstableDependencies = languageVersionSettings.getFlag(AnalysisFlags.allowUnstableDependencies)
|
||||||
|
|
||||||
|
|||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
package a
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun A.foo() = ""
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
package usage
|
|
||||||
|
|
||||||
import a.*
|
|
||||||
|
|
||||||
fun baz(param: A) {
|
|
||||||
param.foo()
|
|
||||||
}
|
|
||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
package a
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun foo() = ""
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
OK
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
package usage
|
|
||||||
|
|
||||||
import a.*
|
|
||||||
|
|
||||||
fun baz(param: A): A {
|
|
||||||
foo()
|
|
||||||
return param
|
|
||||||
}
|
|
||||||
+1
-1
@@ -39,7 +39,7 @@ data class CompilerTestLanguageVersionSettings(
|
|||||||
override fun getFeatureSupport(feature: LanguageFeature): LanguageFeature.State =
|
override fun getFeatureSupport(feature: LanguageFeature): LanguageFeature.State =
|
||||||
extraLanguageFeatures[feature] ?: delegate.getFeatureSupport(feature)
|
extraLanguageFeatures[feature] ?: delegate.getFeatureSupport(feature)
|
||||||
|
|
||||||
override fun isPreRelease(): Boolean = KotlinCompilerVersion.isPreRelease()
|
override fun isPreRelease(): Boolean = false
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun <T> getFlag(flag: AnalysisFlag<T>): T = analysisFlags[flag] as T? ?: flag.defaultValue
|
override fun <T> getFlag(flag: AnalysisFlag<T>): T = analysisFlags[flag] as T? ?: flag.defaultValue
|
||||||
|
|||||||
+16
-91
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.jvm.compiler
|
package org.jetbrains.kotlin.jvm.compiler
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import junit.framework.TestCase
|
|
||||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
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.cli.transformMetadataInClassFile
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
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.config.LanguageVersion
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
|
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.MockLibraryUtil
|
||||||
import org.jetbrains.kotlin.test.TestJdkKind
|
import org.jetbrains.kotlin.test.TestJdkKind
|
||||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparatorAdaptor.validateAndCompareDescriptorWithFile
|
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.*
|
||||||
import org.jetbrains.org.objectweb.asm.tree.ClassNode
|
import org.jetbrains.org.objectweb.asm.tree.ClassNode
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
@@ -115,29 +110,29 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
|||||||
usageDestination: File,
|
usageDestination: File,
|
||||||
vararg additionalOptions: String
|
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) {
|
when (compiler) {
|
||||||
is K2JSCompiler -> compileJsLibrary(libraryName)
|
is K2JSCompiler -> compileJsLibrary(libraryName, additionalOptions = libraryOptions)
|
||||||
is K2JVMCompiler -> compileLibrary(libraryName)
|
is K2JVMCompiler -> compileLibrary(libraryName, additionalOptions = libraryOptions)
|
||||||
else -> throw UnsupportedOperationException(compiler.toString())
|
else -> throw UnsupportedOperationException(compiler.toString())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
withPreRelease(false) {
|
compileKotlin(
|
||||||
compileKotlin("source.kt", usageDestination, listOf(result), compiler, additionalOptions.toList())
|
"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() {
|
fun testRawTypes() {
|
||||||
@@ -311,31 +306,6 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
|||||||
doTestPreReleaseKotlinLibrary(K2JVMCompiler(), "library", tmpdir, "-Xskip-metadata-version-check")
|
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() {
|
fun testWrongMetadataVersion() {
|
||||||
doTestKotlinLibraryWithWrongMetadataVersion("library", null)
|
doTestKotlinLibraryWithWrongMetadataVersion("library", null)
|
||||||
}
|
}
|
||||||
@@ -685,25 +655,6 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
|||||||
assertEquals("Output:\n$output", ExitCode.INTERNAL_ERROR, exitCode)
|
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() {
|
fun testAnonymousObjectTypeMetadata() {
|
||||||
val library = compileCommonLibrary(
|
val library = compileCommonLibrary(
|
||||||
libraryName = "library",
|
libraryName = "library",
|
||||||
@@ -798,31 +749,5 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
|||||||
|
|
||||||
return outputFile
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ class LanguageVersionSettingsImpl @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isPreRelease(): Boolean = languageVersion.isPreRelease() ||
|
override fun isPreRelease(): Boolean = !languageVersion.isStable ||
|
||||||
specificFeatures.any { (feature, state) ->
|
specificFeatures.any { (feature, state) ->
|
||||||
state == LanguageFeature.State.ENABLED && feature.forcesPreReleaseBinariesIfEnabled()
|
state == LanguageFeature.State.ENABLED && feature.forcesPreReleaseBinariesIfEnabled()
|
||||||
}
|
}
|
||||||
@@ -445,12 +445,6 @@ class LanguageVersionSettingsImpl @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LanguageVersion.isPreRelease(): Boolean {
|
|
||||||
if (!isStable) return true
|
|
||||||
|
|
||||||
return KotlinCompilerVersion.isPreRelease() && this == LanguageVersion.LATEST_STABLE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun LanguageFeature.forcesPreReleaseBinariesIfEnabled(): Boolean {
|
fun LanguageFeature.forcesPreReleaseBinariesIfEnabled(): Boolean {
|
||||||
val isFeatureNotReleasedYet = sinceVersion?.isStable != true
|
val isFeatureNotReleasedYet = sinceVersion?.isStable != true
|
||||||
return isFeatureNotReleasedYet && kind.forcesPreReleaseBinaries
|
return isFeatureNotReleasedYet && kind.forcesPreReleaseBinaries
|
||||||
|
|||||||
Reference in New Issue
Block a user