Here you can find the source of getAnnotation(Class> clazz, Class
public static <T extends Annotation> T getAnnotation(Class<?> clazz, Class<T> annotationClass)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class Main { public static <T extends Annotation> T getAnnotation(Class<?> clazz, Class<T> annotationClass) { T annotation = null;/* w ww. j a va 2s .c o m*/ if (hasAnnotation(clazz, annotationClass)) { annotation = clazz.getAnnotation(annotationClass); } return annotation; } public static boolean hasAnnotation(Method method, Class<? extends Annotation> annotation) { return method != null && method.isAnnotationPresent(annotation); } public static boolean hasAnnotation(Class<?> clazz, Class<? extends Annotation> annotation) { return clazz != null && clazz.isAnnotationPresent(annotation); } }