Here you can find the source of getAnnotation(Class
public static <T> T getAnnotation(Class<T> cls, Annotation... annotations)
//package com.java2s; //License from project: Apache License import java.lang.annotation.Annotation; public class Main { public static <T> T getAnnotation(Class<T> cls, Annotation... annotations) { if (annotations == null) { return null; }//from w w w . j av a2 s . com for (Annotation annotation : annotations) { if (cls.isAssignableFrom(annotation.getClass())) { return (T) annotation; } } return null; } }