I have a kotlin class whose properties have a Java annotation, but i can't acess these annotations with Java reflection:
class TestClass(@A var field : String)
The following test prints null:
public class TestKotlinField {
@Retention(RetentionPolicy.RUNTIME)
public @interface A{}
@Test
public void test() throws NoSuchFieldException {
System.out.println(TestClass.class.getDeclaredField("field").getAnnotation(A.class));
}
}
How can i get the annotations of a given kotlin property?
Aucun commentaire:
Enregistrer un commentaire