Here you can find the source of getAnnotations(Class cls)
public static Set<Annotation> getAnnotations(Class cls)
//package com.java2s; //License from project: Apache License import java.lang.annotation.Annotation; import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class Main { public static Set<Annotation> getAnnotations(Class cls) { Set<Annotation> ret = new HashSet<Annotation>(); ret.addAll(Arrays.asList(cls.getAnnotations())); if (cls.getSuperclass() != null) { ret.addAll(getAnnotations(cls.getSuperclass())); }//from ww w. ja v a 2 s . c om for (Class intrface : cls.getInterfaces()) { ret.addAll(getAnnotations(intrface)); } return ret; } }