Here you can find the source of getAnnotation(Class clazz, Class
public static <T extends Annotation> T getAnnotation(Class clazz, Class<T> annotation)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; public class Main { public static <T extends Annotation> T getAnnotation(Class clazz, Class<T> annotation) { if (clazz.isAnnotationPresent(annotation)) { Annotation value = clazz.getAnnotation(annotation); return annotation.cast(value); }/*from w w w . j a v a 2 s .co m*/ return null; } }