Add JVM bytecode target version 13

#KT-34119 Fixed
This commit is contained in:
Alexander Udalov
2019-10-25 11:37:23 +02:00
parent 1354de1780
commit df4ab4ed81
7 changed files with 36 additions and 38 deletions
@@ -248,6 +248,7 @@ public abstract class AnnotationCodegen {
annotationTargetMaps.put(JvmTarget.JVM_10, jvm8); annotationTargetMaps.put(JvmTarget.JVM_10, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_11, jvm8); annotationTargetMaps.put(JvmTarget.JVM_11, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_12, jvm8); annotationTargetMaps.put(JvmTarget.JVM_12, jvm8);
annotationTargetMaps.put(JvmTarget.JVM_13, jvm8);
} }
private void generateTargetAnnotation( private void generateTargetAnnotation(
@@ -63,7 +63,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 or 12), default is 1.6" description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12 or 13), default is 1.6"
) )
var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description) var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description)
@@ -27,6 +27,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
JVM_10("10"), JVM_10("10"),
JVM_11("11"), JVM_11("11"),
JVM_12("12"), JVM_12("12"),
JVM_13("13"),
; ;
val bytecodeVersion: Int by lazy { val bytecodeVersion: Int by lazy {
@@ -34,9 +35,10 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
JVM_1_6 -> Opcodes.V1_6 JVM_1_6 -> Opcodes.V1_6
JVM_1_8 -> Opcodes.V1_8 JVM_1_8 -> Opcodes.V1_8
JVM_9 -> Opcodes.V9 JVM_9 -> Opcodes.V9
JVM_10 -> Opcodes.V9 + 1 JVM_10 -> Opcodes.V10
JVM_11 -> Opcodes.V9 + 2 JVM_11 -> Opcodes.V11
JVM_12 -> Opcodes.V9 + 3 JVM_12 -> Opcodes.V12
JVM_13 -> Opcodes.V12 + 1
} }
} }
@@ -174,39 +174,34 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
) )
} }
private val annotationTargetMaps: Map<JvmTarget, MutableMap<KotlinTarget, IrEnumEntry>> = private val jvm6TargetMap = mutableMapOf(
KotlinTarget.CLASS to etType,
KotlinTarget.ANNOTATION_CLASS to etAnnotationType,
KotlinTarget.CONSTRUCTOR to etConstructor,
KotlinTarget.LOCAL_VARIABLE to etLocalVariable,
KotlinTarget.FUNCTION to etMethod,
KotlinTarget.PROPERTY_GETTER to etMethod,
KotlinTarget.PROPERTY_SETTER to etMethod,
KotlinTarget.FIELD to etField,
KotlinTarget.VALUE_PARAMETER to etParameter
)
private val jvm8TargetMap = jvm6TargetMap + mutableMapOf(
KotlinTarget.TYPE_PARAMETER to etTypeParameter,
KotlinTarget.TYPE to etTypeUse
)
private val annotationTargetMaps: Map<JvmTarget, Map<KotlinTarget, IrEnumEntry>> =
mapOf( mapOf(
JvmTarget.JVM_1_6 to mutableMapOf( JvmTarget.JVM_1_6 to jvm6TargetMap,
KotlinTarget.CLASS to etType, JvmTarget.JVM_1_8 to jvm8TargetMap,
KotlinTarget.ANNOTATION_CLASS to etAnnotationType, JvmTarget.JVM_9 to jvm8TargetMap,
KotlinTarget.CONSTRUCTOR to etConstructor, JvmTarget.JVM_10 to jvm8TargetMap,
KotlinTarget.LOCAL_VARIABLE to etLocalVariable, JvmTarget.JVM_11 to jvm8TargetMap,
KotlinTarget.FUNCTION to etMethod, JvmTarget.JVM_12 to jvm8TargetMap,
KotlinTarget.PROPERTY_GETTER to etMethod, JvmTarget.JVM_13 to jvm8TargetMap
KotlinTarget.PROPERTY_SETTER to etMethod,
KotlinTarget.FIELD to etField,
KotlinTarget.VALUE_PARAMETER to etParameter
),
// additional values for jvm8
JvmTarget.JVM_1_8 to mutableMapOf(
KotlinTarget.TYPE_PARAMETER to etTypeParameter,
KotlinTarget.TYPE to etTypeUse
),
JvmTarget.JVM_9 to mutableMapOf(),
JvmTarget.JVM_10 to mutableMapOf(),
JvmTarget.JVM_11 to mutableMapOf(),
JvmTarget.JVM_12 to mutableMapOf()
) )
init {
annotationTargetMaps[JvmTarget.JVM_1_8]!!.putAll(annotationTargetMaps[JvmTarget.JVM_1_6]!!.toList())
annotationTargetMaps[JvmTarget.JVM_9]!!.putAll(annotationTargetMaps[JvmTarget.JVM_1_8]!!.toList())
annotationTargetMaps[JvmTarget.JVM_10]!!.putAll(annotationTargetMaps[JvmTarget.JVM_9]!!.toList())
annotationTargetMaps[JvmTarget.JVM_11]!!.putAll(annotationTargetMaps[JvmTarget.JVM_10]!!.toList())
annotationTargetMaps[JvmTarget.JVM_12]!!.putAll(annotationTargetMaps[JvmTarget.JVM_11]!!.toList())
}
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
val annotationTargetMap = annotationTargetMaps[jvmTarget] val annotationTargetMap = annotationTargetMaps[jvmTarget]
+1 -1
View File
@@ -5,7 +5,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 or 12), default is 1.6 -jvm-target <version> Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12 or 13), 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 Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13
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 or 12), default is 1.6 * Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12 or 13), default is 1.6
* Possible values: "1.6", "1.8", "9", "10", "11", "12" * Possible values: "1.6", "1.8", "9", "10", "11", "12", "13"
* Default value: "1.6" * Default value: "1.6"
*/ */
var jvmTarget: kotlin.String var jvmTarget: kotlin.String