< prev index next >

src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java

Print this page




  88  *
  89  * <li>An annotation <i>A</i> is <em>associated</em> with an element <i>E</i>
  90  * if either:
  91  *
  92  * <ul>
  93  *
  94  * <li><i>A</i> is directly or indirectly present on <i>E</i>; or
  95  *
  96  * <li>No annotation of <i>A</i> 's type is directly or indirectly
  97  * present on <i>E</i>, and <i>E</i> is a class, and <i>A</i>'s type
  98  * is inheritable, and <i>A</i> is associated with the superclass of
  99  * <i>E</i>.
 100  *
 101  * </ul>
 102  *
 103  * </ul>
 104  *
 105  * <p>The table below summarizes which kind of annotation presence
 106  * different methods in this interface examine.
 107  *
 108  * <table border>
 109  * <caption>Overview of kind of presence detected by different AnnotatedElement methods</caption>

 110  * <tr><th colspan=2></th><th colspan=4>Kind of Presence</th>
 111  * <tr><th colspan=2>Method</th><th>Directly Present</th><th>Indirectly Present</th><th>Present</th><th>Associated</th>


 112  * <tr><td style="text-align:right">{@code T}</td><td>{@link #getAnnotation(Class) getAnnotation(Class&lt;T&gt;)}
 113  * <td></td><td></td><td>X</td><td></td>
 114  * </tr>
 115  * <tr><td style="text-align:right">{@code Annotation[]}</td><td>{@link #getAnnotations getAnnotations()}
 116  * <td></td><td></td><td>X</td><td></td>
 117  * </tr>
 118  * <tr><td style="text-align:right">{@code T[]}</td><td>{@link #getAnnotationsByType(Class) getAnnotationsByType(Class&lt;T&gt;)}
 119  * <td></td><td></td><td></td><td>X</td>
 120  * </tr>
 121  * <tr><td style="text-align:right">{@code T}</td><td>{@link #getDeclaredAnnotation(Class) getDeclaredAnnotation(Class&lt;T&gt;)}
 122  * <td>X</td><td></td><td></td><td></td>
 123  * </tr>
 124  * <tr><td style="text-align:right">{@code Annotation[]}</td><td>{@link #getDeclaredAnnotations getDeclaredAnnotations()}
 125  * <td>X</td><td></td><td></td><td></td>
 126  * </tr>
 127  * <tr><td style="text-align:right">{@code T[]}</td><td>{@link #getDeclaredAnnotationsByType(Class) getDeclaredAnnotationsByType(Class&lt;T&gt;)}
 128  * <td>X</td><td>X</td><td></td><td></td>
 129  * </tr>

 130  * </table>
 131  *
 132  * <p>For an invocation of {@code get[Declared]AnnotationsByType( Class <
 133  * T >)}, the order of annotations which are directly or indirectly
 134  * present on an element <i>E</i> is computed as if indirectly present
 135  * annotations on <i>E</i> are directly present on <i>E</i> in place
 136  * of their container annotation, in the order in which they appear in
 137  * the value element of the container annotation.
 138  *
 139  * <p>There are several compatibility concerns to keep in mind if an
 140  * annotation type <i>T</i> is originally <em>not</em> repeatable and
 141  * later modified to be repeatable.
 142  *
 143  * The containing annotation type for <i>T</i> is <i>TC</i>.
 144  *
 145  * <ul>
 146  *
 147  * <li>Modifying <i>T</i> to be repeatable is source and binary
 148  * compatible with existing uses of <i>T</i> and with existing uses
 149  * of <i>TC</i>.




  88  *
  89  * <li>An annotation <i>A</i> is <em>associated</em> with an element <i>E</i>
  90  * if either:
  91  *
  92  * <ul>
  93  *
  94  * <li><i>A</i> is directly or indirectly present on <i>E</i>; or
  95  *
  96  * <li>No annotation of <i>A</i> 's type is directly or indirectly
  97  * present on <i>E</i>, and <i>E</i> is a class, and <i>A</i>'s type
  98  * is inheritable, and <i>A</i> is associated with the superclass of
  99  * <i>E</i>.
 100  *
 101  * </ul>
 102  *
 103  * </ul>
 104  *
 105  * <p>The table below summarizes which kind of annotation presence
 106  * different methods in this interface examine.
 107  *
 108  * <table class="plain">
 109  * <caption>Overview of kind of presence detected by different AnnotatedElement methods</caption>
 110  * <thead>
 111  * <tr><th colspan=2></th><th colspan=4>Kind of Presence</th>
 112  * <tr><th colspan=2>Method</th><th>Directly Present</th><th>Indirectly Present</th><th>Present</th><th>Associated</th>
 113  * </thead>
 114  * <tbody>
 115  * <tr><td style="text-align:right">{@code T}</td><td>{@link #getAnnotation(Class) getAnnotation(Class&lt;T&gt;)}
 116  * <td></td><td></td><td>X</td><td></td>
 117  * </tr>
 118  * <tr><td style="text-align:right">{@code Annotation[]}</td><td>{@link #getAnnotations getAnnotations()}
 119  * <td></td><td></td><td>X</td><td></td>
 120  * </tr>
 121  * <tr><td style="text-align:right">{@code T[]}</td><td>{@link #getAnnotationsByType(Class) getAnnotationsByType(Class&lt;T&gt;)}
 122  * <td></td><td></td><td></td><td>X</td>
 123  * </tr>
 124  * <tr><td style="text-align:right">{@code T}</td><td>{@link #getDeclaredAnnotation(Class) getDeclaredAnnotation(Class&lt;T&gt;)}
 125  * <td>X</td><td></td><td></td><td></td>
 126  * </tr>
 127  * <tr><td style="text-align:right">{@code Annotation[]}</td><td>{@link #getDeclaredAnnotations getDeclaredAnnotations()}
 128  * <td>X</td><td></td><td></td><td></td>
 129  * </tr>
 130  * <tr><td style="text-align:right">{@code T[]}</td><td>{@link #getDeclaredAnnotationsByType(Class) getDeclaredAnnotationsByType(Class&lt;T&gt;)}
 131  * <td>X</td><td>X</td><td></td><td></td>
 132  * </tr>
 133  * </tbody>
 134  * </table>
 135  *
 136  * <p>For an invocation of {@code get[Declared]AnnotationsByType( Class <
 137  * T >)}, the order of annotations which are directly or indirectly
 138  * present on an element <i>E</i> is computed as if indirectly present
 139  * annotations on <i>E</i> are directly present on <i>E</i> in place
 140  * of their container annotation, in the order in which they appear in
 141  * the value element of the container annotation.
 142  *
 143  * <p>There are several compatibility concerns to keep in mind if an
 144  * annotation type <i>T</i> is originally <em>not</em> repeatable and
 145  * later modified to be repeatable.
 146  *
 147  * The containing annotation type for <i>T</i> is <i>TC</i>.
 148  *
 149  * <ul>
 150  *
 151  * <li>Modifying <i>T</i> to be repeatable is source and binary
 152  * compatible with existing uses of <i>T</i> and with existing uses
 153  * of <i>TC</i>.


< prev index next >