diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index 43fd26301b2..91370848e2a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -248,6 +248,7 @@ public abstract class AnnotationCodegen { annotationTargetMaps.put(JvmTarget.JVM_10, jvm8); annotationTargetMaps.put(JvmTarget.JVM_11, jvm8); annotationTargetMaps.put(JvmTarget.JVM_12, jvm8); + annotationTargetMaps.put(JvmTarget.JVM_13, jvm8); } private void generateTargetAnnotation( diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index b8d46b818ae..aad36d7dfa4 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -63,7 +63,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { @Argument( value = "-jvm-target", valueDescription = "", - 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) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/config/JvmTarget.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/config/JvmTarget.kt index eb408d8af1a..27adb7d3121 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/config/JvmTarget.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/config/JvmTarget.kt @@ -27,6 +27,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion { JVM_10("10"), JVM_11("11"), JVM_12("12"), + JVM_13("13"), ; 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_8 -> Opcodes.V1_8 JVM_9 -> Opcodes.V9 - JVM_10 -> Opcodes.V9 + 1 - JVM_11 -> Opcodes.V9 + 2 - JVM_12 -> Opcodes.V9 + 3 + JVM_10 -> Opcodes.V10 + JVM_11 -> Opcodes.V11 + JVM_12 -> Opcodes.V12 + JVM_13 -> Opcodes.V12 + 1 } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt index 88ceff8a440..06436216ddd 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AdditionalClassAnnotationLowering.kt @@ -174,39 +174,34 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC ) } - private val annotationTargetMaps: Map> = + 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> = mapOf( - JvmTarget.JVM_1_6 to 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 - ), - // 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() + JvmTarget.JVM_1_6 to jvm6TargetMap, + 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 ) - 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) { if (irClass.hasAnnotation(FqName("java.lang.annotation.Target"))) return val annotationTargetMap = annotationTargetMaps[jvmTarget] diff --git a/compiler/testData/cli/jvm/help.out b/compiler/testData/cli/jvm/help.out index 60eec99d92a..e3dc1f09062 100644 --- a/compiler/testData/cli/jvm/help.out +++ b/compiler/testData/cli/jvm/help.out @@ -5,7 +5,7 @@ where possible options include: -include-runtime Include Kotlin runtime into the resulting JAR -java-parameters Generate metadata for Java 1.8 reflection on method parameters -jdk-home Include a custom JDK from the specified location into the classpath instead of the default JAVA_HOME - -jvm-target Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11 or 12), default is 1.6 + -jvm-target Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12 or 13), default is 1.6 -module-name Name of the generated .kotlin_module file -no-jdk Don't automatically include the Java runtime into the classpath -no-reflect Don't automatically include Kotlin reflection into the classpath diff --git a/compiler/testData/cli/jvm/wrongJvmTargetVersion.out b/compiler/testData/cli/jvm/wrongJvmTargetVersion.out index 1dd8238be49..a9ab081c675 100644 --- a/compiler/testData/cli/jvm/wrongJvmTargetVersion.out +++ b/compiler/testData/cli/jvm/wrongJvmTargetVersion.out @@ -1,3 +1,3 @@ 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 diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt index 997b05b7fe2..20340fa35ec 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt @@ -23,8 +23,8 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption var jdkHome: kotlin.String? /** - * Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11 or 12), default is 1.6 - * Possible values: "1.6", "1.8", "9", "10", "11", "12" + * 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", "13" * Default value: "1.6" */ var jvmTarget: kotlin.String