Could not find class annotation

Why does this code print 0?

@Table(name = "source")
public class SourceDetails implements DatabaseEntity{

    public static void main(String[] args) {
        System.out.println(SourceDetails.class.getAnnotations().length);
    }
...
}
+3
source share
1 answer

Since you did not set annotation saving at runtime.

@Retention(RetentionPolicy.RUNTIME)
@interface Table{
  String name();

  int intValue();
}
+4
source

Source: https://habr.com/ru/post/1724927/


All Articles