So there is the abstract @MyAnno
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnno { String value(); } Why can not I access its value through the code clazz.getAnnotation(MyAnno.class) using the value() method, where Class clazz = object.getClass();
When working with class fields, everything is ok, that is, this code works field.getAnnotation(MyAnno.class).value() , where field is an element of the arrayField[] fields = clazz.getDeclaredFields()
PS clazz.isAnnotationPresent(MyAnno.class) true
objectcomes as a parameter to the function:Object object- KnockKnockElementType.TYPEanswers. And no, it did not help - KnockKnock