Here you can find the source of getAnnotation(Class> base, Class
public static <T extends Annotation> T getAnnotation(Class<?> base, Class<T> annotationClass)
//package com.java2s; //License from project: LGPL import java.lang.annotation.Annotation; public class Main { public static <T extends Annotation> T getAnnotation(Class<?> base, Class<T> annotationClass) { T annotation = null;//ww w. ja va 2s . co m annotation = base.getAnnotation(annotationClass); if (null != annotation) { return annotation; } Class<?>[] implementees = base.getInterfaces(); for (int i = 0; null == annotation && i < implementees.length; i++) { annotation = implementees[i].getAnnotation(annotationClass); } return annotation; } }