Java: Kein Zugriff auf Anmerkungen durch Reflektion

Hier ist eine Testklasse:

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class TestAnnotations {

    @interface Annotate{}

    @Annotate public void myMethod(){}

    public static void main(String[] args) {
        try{
            Method[] methods = TestAnnotations.class.getDeclaredMethods();
            Method m = methods[1];
            assert m.getName().equals("myMethod");

            System.out.println("method inspected ? " + m.getName());
            Annotation a = m.getAnnotation(Annotate.class);
            System.out.println("annotation ? " + a);
            System.out.println("annotations length ? "
                + m.getDeclaredAnnotations().length);
        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
}

Hier ist meine Ausgabe:

method inspected ? myMethod
annotation : null
annotations length : 0

Was fehlt mir, um Annotationen durch Reflektion sichtbar zu machen?
Benötige ich einen Anmerkungsprozessor, um nur zu überprüfen, ob er vorhanden ist?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage