Here is a test class:
import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class TestAnnotations { @interface Annotate{}
In order to access an annotation at runtime, it needs to have a Retention policy of Runtime.
@Retention(RetentionPolicy.RUNTIME) @interface Annotate {}
Otherwise, the annotations are dropped and the JVM is not aware of them. For more information, see here.