From 363611874399ceb6d035a3af715720b27d6af569 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 29 Jul 2021 15:00:46 +0200 Subject: [PATCH] Introduce typealias JvmRepeatable for j.l.a.Repeatable #KT-12794 Fixed --- .../jvmRepeatableKotlinAnnotation.kt | 4 +++- .../kotlinAnnotationWithBothRepeatables.kt | 4 +++- .../kotlinAnnotationWithBothRepeatables.kt | 4 +++- .../src/kotlin/annotations/JvmRepeatable.kt | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 libraries/stdlib/jdk8/src/kotlin/annotations/JvmRepeatable.kt diff --git a/compiler/testData/codegen/box/annotations/repeatable/jvmRepeatableKotlinAnnotation.kt b/compiler/testData/codegen/box/annotations/repeatable/jvmRepeatableKotlinAnnotation.kt index 03f3d3e7a2b..20a3d3b1d8f 100644 --- a/compiler/testData/codegen/box/annotations/repeatable/jvmRepeatableKotlinAnnotation.kt +++ b/compiler/testData/codegen/box/annotations/repeatable/jvmRepeatableKotlinAnnotation.kt @@ -1,13 +1,15 @@ // !LANGUAGE: +RepeatableAnnotations +// !API_VERSION: LATEST // TARGET_BACKEND: JVM_IR // WITH_RUNTIME // FULL_JDK // JVM_TARGET: 1.8 +// STDLIB_JDK8 // java.lang.NoSuchMethodError: java.lang.Class.getAnnotationsByType // IGNORE_BACKEND: ANDROID -@java.lang.annotation.Repeatable(As::class) +@JvmRepeatable(As::class) annotation class A(val value: String) annotation class As(val value: Array) diff --git a/compiler/testData/codegen/box/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt b/compiler/testData/codegen/box/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt index 32339868a53..823bdc79f43 100644 --- a/compiler/testData/codegen/box/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt +++ b/compiler/testData/codegen/box/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt @@ -1,14 +1,16 @@ // !LANGUAGE: +RepeatableAnnotations +// !API_VERSION: LATEST // TARGET_BACKEND: JVM_IR // WITH_RUNTIME // FULL_JDK // JVM_TARGET: 1.8 +// STDLIB_JDK8 // java.lang.NoSuchMethodError: java.lang.Class.getAnnotationsByType // IGNORE_BACKEND: ANDROID @Repeatable -@java.lang.annotation.Repeatable(As::class) +@JvmRepeatable(As::class) annotation class A(val value: String) annotation class As(val value: Array) diff --git a/compiler/testData/codegen/bytecodeListing/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt b/compiler/testData/codegen/bytecodeListing/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt index 5bc1806f9f5..436ab65b6fe 100644 --- a/compiler/testData/codegen/bytecodeListing/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt +++ b/compiler/testData/codegen/bytecodeListing/annotations/repeatable/kotlinAnnotationWithBothRepeatables.kt @@ -1,13 +1,15 @@ // !LANGUAGE: +RepeatableAnnotations +// !API_VERSION: LATEST // TARGET_BACKEND: JVM_IR // WITH_RUNTIME // FULL_JDK // JVM_TARGET: 1.8 +// STDLIB_JDK8 package test @Repeatable -@java.lang.annotation.Repeatable(As::class) +@JvmRepeatable(As::class) annotation class A(val value: String) annotation class As(val value: Array) diff --git a/libraries/stdlib/jdk8/src/kotlin/annotations/JvmRepeatable.kt b/libraries/stdlib/jdk8/src/kotlin/annotations/JvmRepeatable.kt new file mode 100644 index 00000000000..c0686fb0d7d --- /dev/null +++ b/libraries/stdlib/jdk8/src/kotlin/annotations/JvmRepeatable.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@file:kotlin.jvm.JvmPackageName("kotlin.jvm.jdk8") + +package kotlin.jvm + +/** + * Makes the annotation class repeatable in Java and Kotlin. A repeatable annotation can be applied more than once + * on the same element. + * + * @property value the container annotation class, used to hold repeated entries of the annotation in the JVM bytecode. + */ +@Suppress("NEWER_VERSION_IN_SINCE_KOTLIN") +@SinceKotlin("1.6") +public typealias JvmRepeatable = java.lang.annotation.Repeatable