Here you can find the source of getAnnotation(Member m, Class
private static <T extends Annotation> T getAnnotation(Member m, Class<T> annotationClass)
//package com.java2s; /*/*from w ww . j a v a 2 s.c o m*/ * Quasar: lightweight threads and actors for the JVM. * Copyright (c) 2013-2015, Parallel Universe Software Co. All rights reserved. * * This program and the accompanying materials are dual-licensed under * either the terms of the Eclipse Public License v1.0 as published by * the Eclipse Foundation * * or (per the licensee's choosing) * * under the terms of the GNU Lesser General Public License version 3.0 * as published by the Free Software Foundation. */ import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; import java.lang.reflect.Member; import java.lang.reflect.Method; public class Main { private static <T extends Annotation> T getAnnotation(Member m, Class<T> annotationClass) { if (m == null || annotationClass == null) return null; if (m instanceof Constructor) return ((Constructor<?>) m).getAnnotation(annotationClass); else return ((Method) m).getAnnotation(annotationClass); } }