jtulach@258: /* jtulach@258: * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. jtulach@258: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jtulach@258: * jtulach@258: * This code is free software; you can redistribute it and/or modify it jtulach@258: * under the terms of the GNU General Public License version 2 only, as jtulach@258: * published by the Free Software Foundation. Oracle designates this jtulach@258: * particular file as subject to the "Classpath" exception as provided jtulach@258: * by Oracle in the LICENSE file that accompanied this code. jtulach@258: * jtulach@258: * This code is distributed in the hope that it will be useful, but WITHOUT jtulach@258: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jtulach@258: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jtulach@258: * version 2 for more details (a copy is included in the LICENSE file that jtulach@258: * accompanied this code). jtulach@258: * jtulach@258: * You should have received a copy of the GNU General Public License version jtulach@258: * 2 along with this work; if not, write to the Free Software Foundation, jtulach@258: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jtulach@258: * jtulach@258: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jtulach@258: * or visit www.oracle.com if you need additional information or have any jtulach@258: * questions. jtulach@258: */ jtulach@258: jtulach@258: package java.lang.reflect; jtulach@258: jtulach@258: import java.lang.annotation.Annotation; jtulach@258: jtulach@258: /** jtulach@258: * Represents an annotated element of the program currently running in this jtulach@258: * VM. This interface allows annotations to be read reflectively. All jtulach@258: * annotations returned by methods in this interface are immutable and jtulach@258: * serializable. It is permissible for the caller to modify the jtulach@258: * arrays returned by accessors for array-valued enum members; it will jtulach@258: * have no affect on the arrays returned to other callers. jtulach@258: * jtulach@258: *
If an annotation returned by a method in this interface contains jtulach@258: * (directly or indirectly) a {@link Class}-valued member referring to jtulach@258: * a class that is not accessible in this VM, attempting to read the class jtulach@258: * by calling the relevant Class-returning method on the returned annotation jtulach@258: * will result in a {@link TypeNotPresentException}. jtulach@258: * jtulach@258: *
Similarly, attempting to read an enum-valued member will result in jtulach@258: * a {@link EnumConstantNotPresentException} if the enum constant in the jtulach@258: * annotation is no longer present in the enum type. jtulach@258: * jtulach@258: *
Finally, Attempting to read a member whose definition has evolved
jtulach@258: * incompatibly will result in a {@link
jtulach@258: * java.lang.annotation.AnnotationTypeMismatchException} or an
jtulach@258: * {@link java.lang.annotation.IncompleteAnnotationException}.
jtulach@258: *
jtulach@258: * @see java.lang.EnumConstantNotPresentException
jtulach@258: * @see java.lang.TypeNotPresentException
jtulach@258: * @see java.lang.annotation.AnnotationFormatError
jtulach@258: * @see java.lang.annotation.AnnotationTypeMismatchException
jtulach@258: * @see java.lang.annotation.IncompleteAnnotationException
jtulach@258: * @since 1.5
jtulach@258: * @author Josh Bloch
jtulach@258: */
jtulach@258: public interface AnnotatedElement {
jtulach@258: /**
jtulach@258: * Returns true if an annotation for the specified type
jtulach@258: * is present on this element, else false. This method
jtulach@258: * is designed primarily for convenient access to marker annotations.
jtulach@258: *
jtulach@258: * @param annotationClass the Class object corresponding to the
jtulach@258: * annotation type
jtulach@258: * @return true if an annotation for the specified annotation
jtulach@258: * type is present on this element, else false
jtulach@258: * @throws NullPointerException if the given annotation class is null
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: boolean isAnnotationPresent(Class extends Annotation> annotationClass);
jtulach@258:
jtulach@258: /**
jtulach@258: * Returns this element's annotation for the specified type if
jtulach@258: * such an annotation is present, else null.
jtulach@258: *
jtulach@258: * @param annotationClass the Class object corresponding to the
jtulach@258: * annotation type
jtulach@258: * @return this element's annotation for the specified annotation type if
jtulach@258: * present on this element, else null
jtulach@258: * @throws NullPointerException if the given annotation class is null
jtulach@258: * @since 1.5
jtulach@258: */
jtulach@258: