Separate JVM target option from javac's --enable-preview analogue

This commit is contained in:
Denis.Zharkov
2020-12-04 19:04:14 +03:00
parent 3abd8b1ab2
commit 46c3979acd
18 changed files with 73 additions and 39 deletions
@@ -140,4 +140,7 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> USE_OLD_INLINE_CLASSES_MANGLING_SCHEME =
CompilerConfigurationKey.create("Use old, 1.4 version of inline classes mangling scheme");
public static final CompilerConfigurationKey<Boolean> ENABLE_JVM_PREVIEW =
CompilerConfigurationKey.create("Enable Java language preview features");
}
@@ -22,8 +22,6 @@ import org.jetbrains.org.objectweb.asm.Opcodes
enum class JvmTarget(
override val description: String,
val majorVersion: Int,
val descriptionForJavacArgument: String = description,
val isPreview: Boolean = false,
) : TargetPlatformVersion {
JVM_1_6("1.6", Opcodes.V1_6),
JVM_1_8("1.8", Opcodes.V1_8),
@@ -34,22 +32,8 @@ enum class JvmTarget(
JVM_13("13", Opcodes.V13),
JVM_14("14", Opcodes.V14),
JVM_15("15", Opcodes.V15),
JVM_15_PREVIEW(
"15_PREVIEW", Opcodes.V15,
descriptionForJavacArgument = "15", isPreview = true
),
;
val minorVersion: Int =
if (isPreview)
0xffff
else
0
val bytecodeVersion: Int by lazy {
(minorVersion shl 16) + majorVersion
}
companion object {
@JvmField
val DEFAULT = JVM_1_6
@@ -57,14 +41,14 @@ enum class JvmTarget(
@JvmStatic
fun fromString(string: String) = values().find { it.description == string }
fun getDescription(bytecodeVersion: Int): String {
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?: when (bytecodeVersion) {
fun getDescription(majorVersion: Int): String {
val platformDescription = values().find { it.majorVersion == majorVersion }?.description ?: when (majorVersion) {
Opcodes.V1_7 -> "1.7"
else -> null
}
return if (platformDescription != null) "JVM target $platformDescription"
else "JVM bytecode version $bytecodeVersion"
else "JVM bytecode version $majorVersion"
}
}
}