mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
25 lines
482 B
Kotlin
Vendored
25 lines
482 B
Kotlin
Vendored
// FILE: JavaAnn.java
|
|
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
|
|
@Retention(RetentionPolicy.RUNTIME)
|
|
@interface JavaAnn {
|
|
Class<?> value();
|
|
}
|
|
|
|
// FILE: MyJavaClass.java
|
|
|
|
class OK {}
|
|
|
|
@JavaAnn(OK.class)
|
|
class MyJavaClass {}
|
|
|
|
// FILE: 1.kt
|
|
|
|
fun box(): String {
|
|
val ann = MyJavaClass::class.java.getAnnotation(JavaAnn::class.java)
|
|
if (ann == null) return "fail: cannot find JavaAnn on MyClass"
|
|
return ann.value.simpleName!!
|
|
}
|