mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Prohibit instantiation of annotation classes
#KT-3465 Fixed
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
String value();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
JavaAnn("value") class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<JavaAnn>())
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann.value() != "value") return "fail: annotation parameter i should be 'value', but was ${ann.value()}"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user