jdk/src/share/classes/java/lang/reflect/AnnotatedElement.java
author jfranck
Thu, 31 Jan 2013 10:10:34 +0100
changeset 15511 8f45487ac694
parent 14676 985410ec95e3
child 15534 19228f4aedb4
permissions -rw-r--r--
8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement 8004919: AnnotationSupport uses possibly half-constructed AnnotationType instances Summary: Implements the simplified semantics for repeating annotations and removes the incorrect obtaining of an AnnotationType Reviewed-by: darcy, abuckley
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3630
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3630
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3630
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3630
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3630
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.lang.reflect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.annotation.Annotation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Represents an annotated element of the program currently running in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * VM.  This interface allows annotations to be read reflectively.  All
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * annotations returned by methods in this interface are immutable and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * serializable.  It is permissible for the caller to modify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * arrays returned by accessors for array-valued enum members; it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * have no affect on the arrays returned to other callers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    38
 * <p>An annotation A is <em>directly present</em> on an element E if the
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    39
 * RuntimeVisibleAnnotations or RuntimeVisibleParameterAnnotations attribute
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    40
 * associated with E either:
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    41
 * <ul>
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    42
 * <li>contains A; or
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    43
 * <li>for invocations of get[Declared]Annotations(Class<T>),
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    44
 * contains A or exactly one annotation C whose type is the containing
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    45
 * annotation type of A's type (JLS 9.6) and whose value element contains A
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    46
 * </ul>
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    47
 *
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    48
 * <p>An annotation A is <em>present</em> on an element E if either:
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    49
 * <ul>
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    50
 * <li>A is <em>directly present</em> on E; or
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    51
 * <li>There are no annotations of A's type which are <em>directly present</em>
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    52
 * on E, and E is a class, and A's type is inheritable (JLS 9.6.3.3), and A is
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    53
 * present on the superclass of E
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    54
 * </ul>
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    55
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <p>If an annotation returned by a method in this interface contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * (directly or indirectly) a {@link Class}-valued member referring to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * a class that is not accessible in this VM, attempting to read the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * by calling the relevant Class-returning method on the returned annotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * will result in a {@link TypeNotPresentException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <p>Similarly, attempting to read an enum-valued member will result in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * a {@link EnumConstantNotPresentException} if the enum constant in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * annotation is no longer present in the enum type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
14676
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
    66
 * <p>Attempting to read annotations of a repeatable annotation type T
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
    67
 * that are contained in an annotation whose type is not, in fact, the
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
    68
 * containing annotation type of T will result in an
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
    69
 * InvalidContainerAnnotationError.
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
    70
 *
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    71
 * <p>Finally, attempting to read a member whose definition has evolved
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * incompatibly will result in a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * java.lang.annotation.AnnotationTypeMismatchException} or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * {@link java.lang.annotation.IncompleteAnnotationException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
3630
28237c1f0c41 6378701: (enum) Unclear purpose of EnumConstantNotPresentException
darcy
parents: 2
diff changeset
    76
 * @see java.lang.EnumConstantNotPresentException
28237c1f0c41 6378701: (enum) Unclear purpose of EnumConstantNotPresentException
darcy
parents: 2
diff changeset
    77
 * @see java.lang.TypeNotPresentException
28237c1f0c41 6378701: (enum) Unclear purpose of EnumConstantNotPresentException
darcy
parents: 2
diff changeset
    78
 * @see java.lang.annotation.AnnotationFormatError
28237c1f0c41 6378701: (enum) Unclear purpose of EnumConstantNotPresentException
darcy
parents: 2
diff changeset
    79
 * @see java.lang.annotation.AnnotationTypeMismatchException
28237c1f0c41 6378701: (enum) Unclear purpose of EnumConstantNotPresentException
darcy
parents: 2
diff changeset
    80
 * @see java.lang.annotation.IncompleteAnnotationException
14676
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
    81
 * @see java.lang.annotation.InvalidContainerAnnotationError
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * @author Josh Bloch
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
public interface AnnotatedElement {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * Returns true if an annotation for the specified type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * is present on this element, else false.  This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * is designed primarily for convenient access to marker annotations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    91
     * <p>The truth value returned by this method is equivalent to:
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    92
     * {@code getAnnotation(annotationClass) != null}
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
    93
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param annotationClass the Class object corresponding to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *        annotation type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @return true if an annotation for the specified annotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *     type is present on this element, else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * @throws NullPointerException if the given annotation class is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     boolean isAnnotationPresent(Class<? extends Annotation> annotationClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Returns this element's annotation for the specified type if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * such an annotation is present, else null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @param annotationClass the Class object corresponding to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *        annotation type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @return this element's annotation for the specified annotation type if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *     present on this element, else null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @throws NullPointerException if the given annotation class is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    <T extends Annotation> T getAnnotation(Class<T> annotationClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
14676
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   117
     * Returns an array of all this element's annotations for the
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   118
     * specified type if one or more of such annotation is present,
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   119
     * else an array of length zero.
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   120
     *
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   121
     * The caller of this method is free to modify the returned array;
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   122
     * it will have no effect on the arrays returned to other callers.
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   123
     *
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   124
     * @param annotationClass the Class object corresponding to the
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   125
     *        annotation type
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   126
     * @return all this element's annotations for the specified annotation type if
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   127
     *     present on this element, else an array of length zero
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   128
     * @throws NullPointerException if the given annotation class is null
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   129
     * @since 1.8
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   130
     */
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   131
    <T extends Annotation> T[] getAnnotations(Class<T> annotationClass);
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   132
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   133
    /**
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   134
     * Returns annotations that are <em>present</em> on this element.
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   135
     *
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   136
     * If there are no annotations <em>present</em> on this element, the return
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   137
     * value is an array of length 0.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   139
     * The caller of this method is free to modify the returned array; it will
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   140
     * have no effect on the arrays returned to other callers.
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   141
     *
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   142
     * @return annotations present on this element
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    Annotation[] getAnnotations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
14676
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   148
     * Returns this element's annotation for the specified type if
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   149
     * such an annotation is present, else null.
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   150
     *
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   151
     * This method ignores inherited annotations. (Returns null if no
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   152
     * annotations are directly present on this element.)
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   153
     *
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   154
     * @param annotationClass the Class object corresponding to the
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   155
     *        annotation type
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   156
     * @return this element's annotation for the specified annotation type if
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   157
     *     present on this element, else null
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   158
     * @throws NullPointerException if the given annotation class is null
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   159
     * @since 1.8
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   160
     */
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   161
    <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass);
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   162
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   163
   /**
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   164
     * Returns an array of all this element's annotations for the
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   165
     * specified type if one or more of such annotation is directly
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   166
     * present, else an array of length zero.
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   167
     *
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   168
     * This method ignores inherited annotations. (Returns
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   169
     * an array of length zero if no annotations are directly present
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   170
     * on this element.)  The caller of this method is free to modify
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   171
     * the returned array; it will have no effect on the arrays
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   172
     * returned to other callers.
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   173
     *
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   174
     * @param annotationClass the Class object corresponding to the
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   175
     *        annotation type
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   176
     * @return all this element's annotations for the specified annotation type if
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   177
     *     present on this element, else an array of length zero
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   178
     * @throws NullPointerException if the given annotation class is null
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   179
     * @since 1.8
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   180
     */
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   181
    <T extends Annotation> T[] getDeclaredAnnotations(Class<T> annotationClass);
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   182
985410ec95e3 7154390: Add support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 5506
diff changeset
   183
    /**
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   184
     * Returns annotations that are <em>directly present</em> on this element.
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   185
     * This method ignores inherited annotations.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *
15511
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   187
     * If there are no annotations <em>directly present</em> on this element,
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   188
     * the return value is an array of length 0.
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   189
     *
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   190
     * The caller of this method is free to modify the returned array; it will
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   191
     * have no effect on the arrays returned to other callers.
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   192
     *
8f45487ac694 8005712: Simplify support for repeating annotations in j.l.r.AnnotatedElement
jfranck
parents: 14676
diff changeset
   193
     * @return annotations directly present on this element
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    Annotation[] getDeclaredAnnotations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
}