Java Annotations not working

后端 未结 3 1134
独厮守ぢ
独厮守ぢ 2021-01-01 14:33

I\'m trying to use Java annotations, but can\'t seem to get my code to recognize that one exists. What am I doing wrong?

  import java.lang.reflect.*;
  im         


        
3条回答
  •  旧巷少年郎
    2021-01-01 15:21

    You need to specify the annotation as being a Runtime annotation using the @Retention annotation on the annotation interface.

    i.e.

    @Retention(RetentionPolicy.RUNTIME)
    @interface MyAnnotation{}
    

提交回复
热议问题