Files
kotlin-fork/compiler/testData/codegen/box/annotations/javaAnnotationOnProperty.kt
T
pyos 5efe774dba FIR: remap Java meta-annotations to Kotlin equivalents
This is a direct port of JavaAnnotationMapper from the old frontend.
2020-12-10 20:52:43 +03:00

26 lines
639 B
Kotlin
Vendored

// WITH_REFLECT
// TARGET_BACKEND: JVM
// FILE: Ann1.java
import java.lang.annotation.*;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann1 {}
// FILE: Ann2.java
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann2 {}
// FILE: box.kt
class C {
@Ann1 @Ann2 val x = 1
}
fun box(): String {
require(C::class.java.getDeclaredField("x")?.getAnnotation(Ann1::class.java) != null) { "no Ann1 on field x" }
require(C::class.java.getDeclaredMethod("getX\$annotations")?.getAnnotation(Ann2::class.java) != null) { "no Ann2 on property x" }
return "OK"
}