Prohibit JVM target 1.6
But still compile stdlib, reflect, kotlin.test and scripting runtimes with JVM target 1.6 to simplify migration from Kotlin 1.6 to 1.7. #KT-45165 Fixed
This commit is contained in:
@@ -56,10 +56,10 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
val jvmTarget = JvmTarget.fromString(jvmTargetValue)
|
||||
if (jvmTarget != null) {
|
||||
put(JVMConfigurationKeys.JVM_TARGET, jvmTarget)
|
||||
if (jvmTarget == JvmTarget.JVM_1_6 && !arguments.suppressDeprecatedJvmTargetWarning) {
|
||||
if (jvmTarget == JvmTarget.JVM_1_6 && !isJvmTarget6Allowed()) {
|
||||
messageCollector.report(
|
||||
STRONG_WARNING,
|
||||
"JVM target 1.6 is deprecated and will be removed in a future release. Please migrate to JVM target 1.8 or above"
|
||||
ERROR,
|
||||
"JVM target 1.6 is no longer supported. Please migrate to JVM target 1.8 or above"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -353,3 +353,6 @@ private val CompilerConfiguration.messageCollector: MessageCollector
|
||||
|
||||
private fun getJavaVersion(): Int =
|
||||
System.getProperty("java.specification.version")?.substringAfter('.')?.toIntOrNull() ?: 6
|
||||
|
||||
private fun isJvmTarget6Allowed(): Boolean =
|
||||
K2JVMCompiler::class.java.classLoader.getResource("META-INF/unsafe-allow-jvm6") != null
|
||||
|
||||
Reference in New Issue
Block a user