Add JVM target bytecode version 14

#KT-38413 Fixed
This commit is contained in:
Alexander Udalov
2020-04-20 15:18:57 +02:00
parent 098a935aa7
commit 94346e8a03
7 changed files with 15 additions and 22 deletions
@@ -40,7 +40,6 @@ import org.jetbrains.kotlin.types.FlexibleType;
import org.jetbrains.kotlin.types.FlexibleTypesKt; import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.KotlinType;
import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext;
import org.jetbrains.org.objectweb.asm.*; import org.jetbrains.org.objectweb.asm.*;
import java.lang.annotation.*; import java.lang.annotation.*;
@@ -254,12 +253,11 @@ public abstract class AnnotationCodegen {
jvm8.put(KotlinTarget.TYPE, ElementType.TYPE_USE); jvm8.put(KotlinTarget.TYPE, ElementType.TYPE_USE);
annotationTargetMaps.put(JvmTarget.JVM_1_6, jvm6); annotationTargetMaps.put(JvmTarget.JVM_1_6, jvm6);
annotationTargetMaps.put(JvmTarget.JVM_1_8, jvm8); for (JvmTarget target : JvmTarget.values()) {
annotationTargetMaps.put(JvmTarget.JVM_9, jvm8); if (target != JvmTarget.JVM_1_6) {
annotationTargetMaps.put(JvmTarget.JVM_10, jvm8); annotationTargetMaps.put(target, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_11, jvm8); }
annotationTargetMaps.put(JvmTarget.JVM_12, jvm8); }
annotationTargetMaps.put(JvmTarget.JVM_13, jvm8);
} }
private void generateTargetAnnotation( private void generateTargetAnnotation(
@@ -70,7 +70,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument( @Argument(
value = "-jvm-target", value = "-jvm-target",
valueDescription = "<version>", valueDescription = "<version>",
description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12 or 13), default is 1.6" description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13 or 14), default is 1.6"
) )
var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description) var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description)
@@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jetbrains.kotlin.config package org.jetbrains.kotlin.config
import org.jetbrains.kotlin.platform.TargetPlatformVersion import org.jetbrains.kotlin.platform.TargetPlatformVersion
@@ -28,6 +27,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
JVM_11("11"), JVM_11("11"),
JVM_12("12"), JVM_12("12"),
JVM_13("13"), JVM_13("13"),
JVM_14("14"),
; ;
val bytecodeVersion: Int by lazy { val bytecodeVersion: Int by lazy {
@@ -39,6 +39,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
JVM_11 -> Opcodes.V11 JVM_11 -> Opcodes.V11
JVM_12 -> Opcodes.V12 JVM_12 -> Opcodes.V12
JVM_13 -> Opcodes.V12 + 1 JVM_13 -> Opcodes.V12 + 1
JVM_14 -> Opcodes.V12 + 2
} }
} }
@@ -188,15 +188,9 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
) )
private val annotationTargetMaps: Map<JvmTarget, Map<KotlinTarget, IrEnumEntry>> = private val annotationTargetMaps: Map<JvmTarget, Map<KotlinTarget, IrEnumEntry>> =
mapOf( JvmTarget.values().associate { target ->
JvmTarget.JVM_1_6 to jvm6TargetMap, target to (if (target == JvmTarget.JVM_1_6) jvm6TargetMap else jvm8TargetMap)
JvmTarget.JVM_1_8 to jvm8TargetMap, }
JvmTarget.JVM_9 to jvm8TargetMap,
JvmTarget.JVM_10 to jvm8TargetMap,
JvmTarget.JVM_11 to jvm8TargetMap,
JvmTarget.JVM_12 to jvm8TargetMap,
JvmTarget.JVM_13 to jvm8TargetMap
)
private fun generateTargetAnnotation(irClass: IrClass) { private fun generateTargetAnnotation(irClass: IrClass) {
if (irClass.hasAnnotation(FqName("java.lang.annotation.Target"))) return if (irClass.hasAnnotation(FqName("java.lang.annotation.Target"))) return
+1 -1
View File
@@ -6,7 +6,7 @@ where possible options include:
-include-runtime Include Kotlin runtime into the resulting JAR -include-runtime Include Kotlin runtime into the resulting JAR
-java-parameters Generate metadata for Java 1.8 reflection on method parameters -java-parameters Generate metadata for Java 1.8 reflection on method parameters
-jdk-home <path> Include a custom JDK from the specified location into the classpath instead of the default JAVA_HOME -jdk-home <path> Include a custom JDK from the specified location into the classpath instead of the default JAVA_HOME
-jvm-target <version> Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12 or 13), default is 1.6 -jvm-target <version> Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13 or 14), default is 1.6
-module-name <name> Name of the generated .kotlin_module file -module-name <name> Name of the generated .kotlin_module file
-no-jdk Don't automatically include the Java runtime into the classpath -no-jdk Don't automatically include the Java runtime into the classpath
-no-reflect Don't automatically include Kotlin reflection into the classpath -no-reflect Don't automatically include Kotlin reflection into the classpath
+1 -1
View File
@@ -1,3 +1,3 @@
error: unknown JVM target version: 1.5 error: unknown JVM target version: 1.5
Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13 Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14
COMPILATION_ERROR COMPILATION_ERROR
@@ -23,8 +23,8 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption
var jdkHome: kotlin.String? var jdkHome: kotlin.String?
/** /**
* Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12 or 13), default is 1.6 * Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13 or 14), default is 1.6
* Possible values: "1.6", "1.8", "9", "10", "11", "12", "13" * Possible values: "1.6", "1.8", "9", "10", "11", "12", "13", "14"
* Default value: "1.6" * Default value: "1.6"
*/ */
var jvmTarget: kotlin.String var jvmTarget: kotlin.String