Files
kotlin-fork/compiler/testData/codegen/box/annotations/annotationWithKotlinProperty.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

36 lines
755 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
// FILE: JavaClass.java
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public class JavaClass {
@Retention(RetentionPolicy.RUNTIME)
@interface Foo {
int value();
}
@Foo(KotlinClass.FOO_INT)
public String test() throws NoSuchMethodException {
return KotlinClass.FOO_STRING +
JavaClass.class.getMethod("test").getAnnotation(Foo.class).value();
}
}
// FILE: kotlinClass.kt
class KotlinClass {
companion object {
const val FOO_INT: Int = 10
@JvmField val FOO_STRING: String = "OK"
}
}
fun box(): String {
val test = JavaClass().test()
return if (test == "OK10") "OK" else "fail : $test"
}