author | darcy |
Wed, 25 Apr 2018 22:12:06 -0700 | |
changeset 49895 | 661ef62a6618 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
44532
39f580829da1
8177949: @link tag arguments need correction for ElementType documentation
darcy
parents:
42338
diff
changeset
|
2 |
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.lang.annotation; |
|
27 |
||
28 |
/** |
|
21828
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
29 |
* The constants of this enumerated type provide a simple classification of the |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
30 |
* syntactic locations where annotations may appear in a Java program. These |
44532
39f580829da1
8177949: @link tag arguments need correction for ElementType documentation
darcy
parents:
42338
diff
changeset
|
31 |
* constants are used in {@link java.lang.annotation.Target Target} |
21828
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
32 |
* meta-annotations to specify where it is legal to write annotations of a |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
33 |
* given type. |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
34 |
* |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
35 |
* <p>The syntactic locations where annotations may appear are split into |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
36 |
* <em>declaration contexts</em> , where annotations apply to declarations, and |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
37 |
* <em>type contexts</em> , where annotations apply to types used in |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
38 |
* declarations and expressions. |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
39 |
* |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
40 |
* <p>The constants {@link #ANNOTATION_TYPE}, {@link #CONSTRUCTOR}, {@link |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
41 |
* #FIELD}, {@link #LOCAL_VARIABLE}, {@link #METHOD}, {@link #PACKAGE}, {@link |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
42 |
* #MODULE}, {@link #PARAMETER}, {@link #TYPE}, and {@link #TYPE_PARAMETER} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
43 |
* correspond to the declaration contexts in JLS 9.6.4.1. |
2 | 44 |
* |
21828
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
45 |
* <p>For example, an annotation whose type is meta-annotated with |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
46 |
* {@code @Target(ElementType.FIELD)} may only be written as a modifier for a |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
47 |
* field declaration. |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
48 |
* |
38587
512822cb2cfe
8033812: javadoc for java.lang.annotation.ElementType needs minor correction
sadayapalam
parents:
25859
diff
changeset
|
49 |
* <p>The constant {@link #TYPE_USE} corresponds to the type contexts in JLS |
21828
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
50 |
* 4.11, as well as to two declaration contexts: type declarations (including |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
51 |
* annotation type declarations) and type parameter declarations. |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
52 |
* |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
53 |
* <p>For example, an annotation whose type is meta-annotated with |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
54 |
* {@code @Target(ElementType.TYPE_USE)} may be written on the type of a field |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
55 |
* (or within the type of the field, if it is a nested, parameterized, or array |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
56 |
* type), and may also appear as a modifier for, say, a class declaration. |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
57 |
* |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
58 |
* <p>The {@code TYPE_USE} constant includes type declarations and type |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
59 |
* parameter declarations as a convenience for designers of type checkers which |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
60 |
* give semantics to annotation types. For example, if the annotation type |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
61 |
* {@code NonNull} is meta-annotated with |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
62 |
* {@code @Target(ElementType.TYPE_USE)}, then {@code @NonNull} |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
63 |
* {@code class C {...}} could be treated by a type checker as indicating that |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
64 |
* all variables of class {@code C} are non-null, while still allowing |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
65 |
* variables of other classes to be non-null or not non-null based on whether |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
66 |
* {@code @NonNull} appears at the variable's declaration. |
2 | 67 |
* |
68 |
* @author Joshua Bloch |
|
69 |
* @since 1.5 |
|
21828
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
70 |
* @jls 9.6.4.1 @Target |
5c9519eb783c
8027413: Clarify javadoc for j.l.a.Target and j.l.a.ElementType
jfranck
parents:
14419
diff
changeset
|
71 |
* @jls 4.1 The Kinds of Types and Values |
2 | 72 |
*/ |
73 |
public enum ElementType { |
|
74 |
/** Class, interface (including annotation type), or enum declaration */ |
|
75 |
TYPE, |
|
76 |
||
77 |
/** Field declaration (includes enum constants) */ |
|
78 |
FIELD, |
|
79 |
||
80 |
/** Method declaration */ |
|
81 |
METHOD, |
|
82 |
||
14419 | 83 |
/** Formal parameter declaration */ |
2 | 84 |
PARAMETER, |
85 |
||
86 |
/** Constructor declaration */ |
|
87 |
CONSTRUCTOR, |
|
88 |
||
89 |
/** Local variable declaration */ |
|
90 |
LOCAL_VARIABLE, |
|
91 |
||
92 |
/** Annotation type declaration */ |
|
93 |
ANNOTATION_TYPE, |
|
94 |
||
95 |
/** Package declaration */ |
|
14419 | 96 |
PACKAGE, |
97 |
||
98 |
/** |
|
99 |
* Type parameter declaration |
|
100 |
* |
|
101 |
* @since 1.8 |
|
102 |
*/ |
|
103 |
TYPE_PARAMETER, |
|
104 |
||
105 |
/** |
|
106 |
* Use of a type |
|
107 |
* |
|
108 |
* @since 1.8 |
|
109 |
*/ |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
110 |
TYPE_USE, |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
111 |
|
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
112 |
/** |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
113 |
* Module declaration. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
114 |
* |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
115 |
* @since 9 |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
116 |
*/ |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
38587
diff
changeset
|
117 |
MODULE |
2 | 118 |
} |