Here you can find the source of getAnnotation(Class cls, Class extends Annotation> annotationCls)
public static Annotation getAnnotation(Class cls, Class<? extends Annotation> annotationCls)
//package com.java2s; //License from project: Open Source License import java.lang.annotation.Annotation; public class Main { public static Annotation getAnnotation(Class cls, Class<? extends Annotation> annotationCls) { Annotation res = cls.getAnnotation(annotationCls); if (res != null) { return res; } else if (!cls.equals(Object.class)) { return getAnnotation(cls.getSuperclass(), annotationCls); } else {// w w w . ja v a 2s .com return null; } } }