How does Java: understand the < An extends Annotation > template?

you can get comments in the following ways

public <A extends Annotation> A getAnnotation(Class<A> annotationClass) {
    Objects.requireNonNull(annotationClass);

    return (A) annotationData().annotations.get(annotationClass);
}

but annotation definitions generally do not write extends Annotation
. Are all annotations extends Annotation by default?

Mar.24,2021
The
annotation is essentially an interface, which is essentially defined as: interface SomeAnnotation extends Annotation.
this Annotation interface is located in the java/lang/annotation package, and the first sentence in its comment is The common interface extended by all annotation types.
-- dynamically modifies an attribute value of the annotation through reflection .

it is recommended to look up the Annotation source code so that you have everything you want

Menu