jdk/src/share/classes/java/lang/annotation/ContainerFor.java
changeset 15726 27bb87e628ae
parent 15725 e0516b913894
parent 15722 b3dd9b35c97f
child 15727 e3baad90c331
equal deleted inserted replaced
15725:e0516b913894 15726:27bb87e628ae
     1 /*
       
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package java.lang.annotation;
       
    27 
       
    28 /**
       
    29  * The annotation type {@code java.lang.annotation.ContainerFor} is
       
    30  * used to indicate that the annotation type whose declaration it
       
    31  * (meta-)annotates is a <em>containing annotation type</em>. The
       
    32  * value of {@code @ContainerFor} indicates the <em>repeatable
       
    33  * annotation type</em> for the containing annotation type.
       
    34  *
       
    35  * <p>The pair of annotation types {@link
       
    36  * java.lang.annotation.ContainedBy @ContainedBy} and
       
    37  * {@code @ContainerFor} are used to indicate that annotation types
       
    38  * are repeatable. Specifically:
       
    39  *
       
    40  * <ul>
       
    41  * <li>The annotation type {@code @ContainedBy} is used on the
       
    42  * declaration of a repeatable annotation type (JLS 9.6) to indicate
       
    43  * its containing annotation type.
       
    44  *
       
    45  * <li>The annotation type {@code @ContainerFor} is used on the
       
    46  * declaration of a containing annotation type (JLS 9.6) to indicate
       
    47  * the repeatable annotation type for which it serves as the
       
    48  * containing annotation type.
       
    49  * </ul>
       
    50  *
       
    51  * <p>
       
    52  * An inconsistent pair of {@code @ContainedBy} and
       
    53  * {@code @ContainerFor} annotations on a repeatable annotation type
       
    54  * and its containing annotation type (JLS 9.6) will lead to
       
    55  * compile-time errors and runtime exceptions when using reflection to
       
    56  * read annotations of a repeatable type.
       
    57  *
       
    58  * @see java.lang.annotation.ContainedBy
       
    59  * @since 1.8
       
    60  * @jls 9.6 Annotation Types
       
    61  * @jls 9.7 Annotations
       
    62  */
       
    63 @Documented
       
    64 @Retention(RetentionPolicy.RUNTIME)
       
    65 @Target(ElementType.ANNOTATION_TYPE)
       
    66 public @interface ContainerFor {
       
    67 
       
    68     /**
       
    69      * Indicates the repeatable annotation type for the containing
       
    70      * annotation type.
       
    71      */
       
    72     Class<? extends Annotation> value();
       
    73 }