Here you can find the source of getAnnotation(Class> clazz, Class annotationClass)
Parameter | Description |
---|---|
clazz | the class to be tested |
annotationClass | the annotation be be looked up |
A | the annotation type |
public static <A extends Annotation> A getAnnotation(Class<?> clazz, Class<A> annotationClass)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; public class Main { /**//w w w.j a v a2 s. c om * This is proxy ready implementation {@link Class#getAnnotation(Class)}. * * @param clazz the class to be tested * @param annotationClass the annotation be be looked up * @param <A> the annotation type * @return {@code true} if the {@code clazz} or its super-class(s) is annotated by {@code annotationClass} */ public static <A extends Annotation> A getAnnotation(Class<?> clazz, Class<A> annotationClass) { final A annotation = clazz.getAnnotation(annotationClass); if (annotation == null && clazz.isSynthetic()) { //OK, this is probably proxy return getAnnotation(clazz.getSuperclass(), annotationClass); } else { return annotation; } } }