Here you can find the source of getAnnotation(Class cls, Class annotationCls)
public static Annotation getAnnotation(Class cls, Class annotationCls)
//package com.java2s; //License from project: Apache License import java.lang.annotation.Annotation; public class Main { public static Annotation getAnnotation(Class cls, Class annotationCls) { if (cls == null) { return null; }/*from w w w . j a v a 2 s . c om*/ Annotation ret = cls.getAnnotation(annotationCls); if (ret != null) { return ret; } ret = getAnnotation(cls.getSuperclass(), annotationCls); if (ret != null) { return ret; } for (Class intrface : cls.getInterfaces()) { ret = getAnnotation(intrface, annotationCls); if (ret != null) { return ret; } } return null; } }