Here you can find the source of getAnnotation(Object obj, Class annotation)
public static <A extends Annotation> A getAnnotation(Object obj, Class<A> annotation)
//package com.java2s; //License from project: Apache License import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.util.Objects; public class Main { public static <A extends Annotation> A getAnnotation(Object obj, Class<A> annotation) { Objects.requireNonNull(obj); return obj.getClass().getDeclaredAnnotation(annotation); }/*from ww w . java 2 s .c o m*/ public static <A extends Annotation> A getAnnotation(Class<?> clazz, Class<A> annotation) { Objects.requireNonNull(clazz); Objects.requireNonNull(annotation); return clazz.getDeclaredAnnotation(annotation); } public static <A extends Annotation> A getAnnotation(Field field, Class<A> annotation) { Objects.requireNonNull(field); Objects.requireNonNull(annotation); return field.getDeclaredAnnotation(annotation); } }