langtools/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
author darcy
Mon, 23 Jan 2017 10:37:27 -0800
changeset 43280 692b0dfbb390
parent 42825 c22877f68145
child 43369 aafd33c96bac
permissions -rw-r--r--
8173164: Resolve remaining HTML5 issues in javax.lang.model.* Reviewed-by: martin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
     2
 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4074
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4074
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4074
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4074
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 4074
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.lang.model.util;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.Map;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
42825
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
    32
import javax.lang.model.AnnotatedConstruct;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * Utility methods for operating on program elements.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * <p><b>Compatibility Note:</b> Methods may be added to this interface
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * in future releases of the platform.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @see javax.annotation.processing.ProcessingEnvironment#getElementUtils
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
public interface Elements {
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    51
     * Returns a package given its fully qualified name if the package is unique in the environment.
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    52
     * If running with modules, all modules in the modules graph are searched for matching packages.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     *
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    54
     * @param name  fully qualified package name, or an empty string for an unnamed package
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    55
     * @return the named package, or {@code null} if it cannot be uniquely found
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    PackageElement getPackageElement(CharSequence name);
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    /**
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    60
     * Returns a package given its fully qualified name, as seen from the given module.
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    61
     *
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    62
     * @param name  fully qualified package name, or an empty string for an unnamed package
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    63
     * @param module module relative to which the lookup should happen
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    64
     * @return the named package, or {@code null} if it cannot be found
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    65
     * @since 9
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    66
     */
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    67
    PackageElement getPackageElement(ModuleElement module, CharSequence name);
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    68
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    69
    /**
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    70
     * Returns a type element given its canonical name if the type element is unique in the environment.
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    71
     * If running with modules, all modules in the modules graph are searched for matching
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    72
     * type elements.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * @param name  the canonical name
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    75
     * @return the named type element, or {@code null} if it cannot be uniquely found
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    TypeElement getTypeElement(CharSequence name);
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    /**
37848
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    80
     * Returns a type element given its canonical name, as seen from the given module.
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    81
     *
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    82
     * @param name  the canonical name
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    83
     * @param module module relative to which the lookup should happen
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    84
     * @return the named type element, or {@code null} if it cannot be found
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    85
     * @since 9
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    86
     */
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    87
    TypeElement getTypeElement(ModuleElement module, CharSequence name);
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    88
3c8ff4204d2d 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36526
diff changeset
    89
    /**
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    90
     * Returns a module element given its fully qualified name.
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    91
     * If the named module cannot be found, null is returned. One situation where a module
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    92
     * cannot be found is if the environment does not include modules, such as
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
    93
     * an annotation processing environment configured for
43280
692b0dfbb390 8173164: Resolve remaining HTML5 issues in javax.lang.model.*
darcy
parents: 42825
diff changeset
    94
     * a {@linkplain
692b0dfbb390 8173164: Resolve remaining HTML5 issues in javax.lang.model.*
darcy
parents: 42825
diff changeset
    95
     * javax.annotation.processing.ProcessingEnvironment#getSourceVersion
692b0dfbb390 8173164: Resolve remaining HTML5 issues in javax.lang.model.*
darcy
parents: 42825
diff changeset
    96
     * source version} without modules.
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    97
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    98
     * @param name  the name
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
    99
     * @return the named module element, or {@code null} if it cannot be found
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   100
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   101
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   102
    ModuleElement getModuleElement(CharSequence name);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   103
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   104
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * Returns the values of an annotation's elements, including defaults.
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * @see AnnotationMirror#getElementValues()
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * @param a  annotation to examine
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * @return the values of the annotation's elements, including defaults
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    Map<? extends ExecutableElement, ? extends AnnotationValue>
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
            getElementValuesWithDefaults(AnnotationMirror a);
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * Returns the text of the documentation (&quot;Javadoc&quot;)
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * comment of an element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     *
4074
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   118
     * <p> A documentation comment of an element is a comment that
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   119
     * begins with "{@code /**}" , ends with a separate
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 9303
diff changeset
   120
     * "<code>*&#47;</code>", and immediately precedes the element,
4074
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   121
     * ignoring white space.  Therefore, a documentation comment
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   122
     * contains at least three"{@code *}" characters.  The text
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   123
     * returned for the documentation comment is a processed form of
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   124
     * the comment as it appears in source code.  The leading "{@code
13844
56339cf983a3 7177970: fix issues in langtools doc comments
jjg
parents: 9303
diff changeset
   125
     * /**}" and trailing "<code>*&#47;</code>" are removed.  For lines
4074
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   126
     * of the comment starting after the initial "{@code /**}",
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   127
     * leading white space characters are discarded as are any
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   128
     * consecutive "{@code *}" characters appearing after the white
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   129
     * space or starting the line.  The processed lines are then
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   130
     * concatenated together (including line terminators) and
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   131
     * returned.
2b391dcb03ff 6558804: Specification for Elements.getDocComment(Element e) should be clarified
darcy
parents: 10
diff changeset
   132
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * @param e  the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * @return the documentation comment of the element, or {@code null}
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     *          if there is none
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   136
     * @jls 3.6 White Space
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    String getDocComment(Element e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     * Returns {@code true} if the element is deprecated, {@code false} otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * @param e  the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * @return {@code true} if the element is deprecated, {@code false} otherwise
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    boolean isDeprecated(Element e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    /**
42825
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   149
     * Returns the <em>origin</em> of the given element.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   150
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   151
     * <p>Note that if this method returns {@link Origin#EXPLICIT
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   152
     * EXPLICIT} and the element was created from a class file, then
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   153
     * the element may not, in fact, correspond to an explicitly
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   154
     * declared construct in source code. This is due to limitations
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   155
     * of the fidelity of the class file format in preserving
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   156
     * information from source code. For example, at least some
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   157
     * versions of the class file format do not preserve whether a
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   158
     * constructor was explicitly declared by the programmer or was
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   159
     * implicitly declared as the <em>default constructor</em>.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   160
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   161
     * @implSpec The default implementation of this method returns
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   162
     * {@link Origin#EXPLICIT EXPLICIT}.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   163
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   164
     * @param e  the element being examined
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   165
     * @return the origin of the given element
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   166
     * @since 9
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   167
     */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   168
    default Origin getOrigin(Element e) {
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   169
        return Origin.EXPLICIT;
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   170
    }
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   171
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   172
    /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   173
     * Returns the <em>origin</em> of the given annotation mirror.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   174
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   175
     * An annotation mirror is {@linkplain Origin#MANDATED mandated}
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   176
     * if it is an implicitly declared <em>container annotation</em>
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   177
     * used to hold repeated annotations of a repeatable annotation
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   178
     * type.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   179
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   180
     * <p>Note that if this method returns {@link Origin#EXPLICIT
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   181
     * EXPLICIT} and the annotation mirror was created from a class
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   182
     * file, then the element may not, in fact, correspond to an
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   183
     * explicitly declared construct in source code. This is due to
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   184
     * limitations of the fidelity of the class file format in
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   185
     * preserving information from source code. For example, at least
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   186
     * some versions of the class file format do not preserve whether
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   187
     * an annotation was explicitly declared by the programmer or was
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   188
     * implicitly declared as a <em>container annotation</em>.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   189
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   190
     * @implSpec The default implementation of this method returns
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   191
     * {@link Origin#EXPLICIT EXPLICIT}.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   192
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   193
     * @param c the construct the annotation mirror modifies
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   194
     * @param a the annotation mirror being examined
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   195
     * @return the origin of the given annotation mirror
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   196
     * @jls 9.6.3 Repeatable Annotation Types
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   197
     * @jls 9.7.5 Multiple Annotations of the Same Type
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   198
     * @since 9
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   199
     */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   200
    default Origin getOrigin(AnnotatedConstruct c,
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   201
                             AnnotationMirror a) {
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   202
        return Origin.EXPLICIT;
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   203
    }
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   204
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   205
    /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   206
     * Returns the <em>origin</em> of the given module directive.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   207
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   208
     * <p>Note that if this method returns {@link Origin#EXPLICIT
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   209
     * EXPLICIT} and the module directive was created from a class
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   210
     * file, then the module directive may not, in fact, correspond to
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   211
     * an explicitly declared construct in source code. This is due to
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   212
     * limitations of the fidelity of the class file format in
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   213
     * preserving information from source code. For example, at least
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   214
     * some versions of the class file format do not preserve whether
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   215
     * a {@code uses} directive was explicitly declared by the
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   216
     * programmer or was added as a synthetic construct.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   217
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   218
     * <p>Note that an implementation may not be able to reliably
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   219
     * determine the origin status of the directive if the directive
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   220
     * is created from a class file due to limitations of the fidelity
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   221
     * of the class file format in preserving information from source
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   222
     * code.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   223
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   224
     * @implSpec The default implementation of this method returns
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   225
     * {@link Origin#EXPLICIT EXPLICIT}.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   226
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   227
     * @param m the module of the directive
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   228
     * @param directive  the module directive being examined
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   229
     * @return the origin of the given directive
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   230
     * @since 9
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   231
     */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   232
    default Origin getOrigin(ModuleElement m,
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   233
                             ModuleElement.Directive directive) {
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   234
        return Origin.EXPLICIT;
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   235
    }
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   236
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   237
    /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   238
     * The <em>origin</em> of an element or other language model
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   239
     * item. The origin of an element or item models how a construct
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   240
     * in a program is declared in the source code, explicitly,
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   241
     * implicitly, etc.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   242
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   243
     * <p>Note that it is possible additional kinds of origin values
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   244
     * will be added in future versions of the platform.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   245
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   246
     * @jls 13.1 The Form of a Binary
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   247
     * @since 9
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   248
     */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   249
    public enum Origin {
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   250
        /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   251
         * Describes a construct explicitly declared in source code.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   252
         */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   253
        EXPLICIT,
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   254
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   255
       /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   256
         * A mandated construct is one that is not explicitly declared
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   257
         * in the source code, but whose presence is mandated by the
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   258
         * specification. Such a construct is said to be implicitly
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   259
         * declared.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   260
         *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   261
         * One example of a mandated element is a <em>default
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   262
         * constructor</em> in a class that contains no explicit
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   263
         * constructor declarations.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   264
         *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   265
         * Another example of a mandated construct is an implicitly
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   266
         * declared <em>container annotation</em> used to hold
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   267
         * multiple annotations of a repeatable annotation type.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   268
         *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   269
         * @jls 8.8.9 Default Constructor
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   270
         * @jls 9.6.3 Repeatable Annotation Types
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   271
         * @jls 9.7.5 Multiple Annotations of the Same Type
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   272
         */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   273
        MANDATED,
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   274
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   275
       /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   276
         * A synthetic construct is one that is neither implicitly nor
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   277
         * explicitly declared in the source code. Such a construct is
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   278
         * typically a translation artifact created by a compiler.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   279
         */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   280
        SYNTHETIC;
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   281
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   282
        /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   283
         * Returns {@code true} for values corresponding to constructs
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   284
         * that are implicitly or explicitly declared, {@code false}
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   285
         * otherwise.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   286
         * @return {@code true} for {@link EXPLICIT} and {@link
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   287
         * MANDATED}, {@code false} otherwise.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   288
         */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   289
        public boolean isDeclared() {
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   290
            return this != SYNTHETIC;
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   291
        }
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   292
    }
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   293
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   294
    /**
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   295
     * Returns {@code true} if the executable element is a bridge
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   296
     * method, {@code false} otherwise.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   297
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   298
     * @implSpec The default implementation of this method returns {@code false}.
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   299
     *
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   300
     * @param e  the executable being examined
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   301
     * @return {@code true} if the executable element is a bridge
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   302
     * method, {@code false} otherwise
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   303
     * @since 9
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   304
     */
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   305
    default boolean isBridge(ExecutableElement e) {
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   306
        return false;
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   307
    }
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   308
c22877f68145 8163315: Implement an API to identify an implicitly declared annotation (or declaration)
darcy
parents: 42824
diff changeset
   309
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     * Returns the <i>binary name</i> of a type element.
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
     * @param type  the type element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
     * @return the binary name
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
     * @see TypeElement#getQualifiedName
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   316
     * @jls 13.1 The Form of a Binary
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
    Name getBinaryName(TypeElement type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
     * Returns the package of an element.  The package of a package is
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
     * itself.
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
     * @param type the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
     * @return the package of an element
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
    PackageElement getPackageOf(Element type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
    /**
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   331
     * Returns the module of an element.  The module of a module is
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   332
     * itself.
42824
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
   333
     * If there is no module for the element, null is returned. One situation where there is
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
   334
     * no module for an element is if the environment does not include modules, such as
89b14017e8d6 8133896: Update javax.lang.model APIs
jlahoda
parents: 37848
diff changeset
   335
     * an annotation processing environment configured for
43280
692b0dfbb390 8173164: Resolve remaining HTML5 issues in javax.lang.model.*
darcy
parents: 42825
diff changeset
   336
     * a {@linkplain
692b0dfbb390 8173164: Resolve remaining HTML5 issues in javax.lang.model.*
darcy
parents: 42825
diff changeset
   337
     * javax.annotation.processing.ProcessingEnvironment#getSourceVersion
692b0dfbb390 8173164: Resolve remaining HTML5 issues in javax.lang.model.*
darcy
parents: 42825
diff changeset
   338
     * source version} without modules.
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   339
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   340
     * @param type the element being examined
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   341
     * @return the module of an element
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   342
     * @since 9
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   343
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   344
    ModuleElement getModuleOf(Element type);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   345
3b41f1c69604 8142968: Module System implementation
alanb
parents: 25874
diff changeset
   346
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
     * Returns all members of a type element, whether inherited or
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
     * declared directly.  For a class the result also includes its
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
     * constructors, but not local or anonymous classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
     * <p>Note that elements of certain kinds can be isolated using
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
     * methods in {@link ElementFilter}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
     * @param type  the type being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
     * @return all members of the type
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
     * @see Element#getEnclosedElements
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
    List<? extends Element> getAllMembers(TypeElement type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
    /**
17802
83c53847fc7e 8010680: Clarify "present" and annotation ordering in javax.lang.model
darcy
parents: 17548
diff changeset
   361
     * Returns all annotations <i>present</i> on an element, whether
83c53847fc7e 8010680: Clarify "present" and annotation ordering in javax.lang.model
darcy
parents: 17548
diff changeset
   362
     * directly present or present via inheritance.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
     * @param e  the element being examined
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
     * @return all annotations of the element
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
     * @see Element#getAnnotationMirrors
17802
83c53847fc7e 8010680: Clarify "present" and annotation ordering in javax.lang.model
darcy
parents: 17548
diff changeset
   367
     * @see javax.lang.model.AnnotatedConstruct
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
    List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
     * Tests whether one type, method, or field hides another.
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
     * @param hider   the first element
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
     * @param hidden  the second element
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
     * @return {@code true} if and only if the first element hides
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
     *          the second
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
    boolean hides(Element hider, Element hidden);
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
     * Tests whether one method, as a member of a given type,
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     * overrides another method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
     * When a non-abstract method overrides an abstract one, the
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
     * former is also said to <i>implement</i> the latter.
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
     * <p> In the simplest and most typical usage, the value of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
     * {@code type} parameter will simply be the class or interface
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
     * directly enclosing {@code overrider} (the possibly-overriding
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
     * method).  For example, suppose {@code m1} represents the method
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
     * {@code String.hashCode} and {@code m2} represents {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
     * Object.hashCode}.  We can then ask whether {@code m1} overrides
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
     * {@code m2} within the class {@code String} (it does):
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
     * {@code assert elements.overrides(m1, m2,
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
     *          elements.getTypeElement("java.lang.String")); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
     * A more interesting case can be illustrated by the following example
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
     * in which a method in type {@code A} does not override a
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
     * like-named method in type {@code B}:
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
     * {@code class A { public void m() {} } }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
     * {@code interface B { void m(); } }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
     * ...<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
     * {@code m1 = ...;  // A.m }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
     * {@code m2 = ...;  // B.m }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
     * {@code assert ! elements.overrides(m1, m2,
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
     *          elements.getTypeElement("A")); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
     * When viewed as a member of a third type {@code C}, however,
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
     * the method in {@code A} does override the one in {@code B}:
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
     * {@code class C extends A implements B {} }<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
     * ...<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
     * {@code assert elements.overrides(m1, m2,
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
     *          elements.getTypeElement("C")); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
     * @param overrider  the first method, possible overrider
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
     * @param overridden  the second method, possibly being overridden
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
     * @param type   the type of which the first method is a member
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
     * @return {@code true} if and only if the first method overrides
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
     *          the second
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   429
     * @jls 8.4.8 Inheritance, Overriding, and Hiding
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   430
     * @jls 9.4.1 Inheritance and Overriding
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
    boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
                      TypeElement type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
     * Returns the text of a <i>constant expression</i> representing a
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
     * primitive value or a string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
     * The text returned is in a form suitable for representing the value
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
     * in source code.
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
     * @param value  a primitive value or string
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
     * @return the text of a constant expression
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
     * @throws IllegalArgumentException if the argument is not a primitive
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
     *          value or string
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
     * @see VariableElement#getConstantValue()
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
    String getConstantExpression(Object value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
     * Prints a representation of the elements to the given writer in
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
     * the specified order.  The main purpose of this method is for
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
     * diagnostics.  The exact format of the output is <em>not</em>
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
     * specified and is subject to change.
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
     * @param w the writer to print the output to
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
     * @param elements the elements to print
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
    void printElements(java.io.Writer w, Element... elements);
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
     * Return a name with the same sequence of characters as the
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
     * argument.
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
     * @param cs the character sequence to return as a name
17548
b0a4fd89079c 8013909: Fix doclint issues in javax.lang.model
darcy
parents: 15714
diff changeset
   466
     * @return a name with the same sequence of characters as the argument
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
    Name getName(CharSequence cs);
15714
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   469
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   470
    /**
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   471
     * Returns {@code true} if the type element is a functional interface, {@code false} otherwise.
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   472
     *
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   473
     * @param type the type element being examined
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   474
     * @return {@code true} if the element is a functional interface, {@code false} otherwise
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   475
     * @jls 9.8 Functional Interfaces
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   476
     * @since 1.8
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   477
     */
d9a83ab62853 8007574: Provide isFunctionalInterface in javax.lang.model
darcy
parents: 13844
diff changeset
   478
    boolean isFunctionalInterface(TypeElement type);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
}