Path: blob/master/src/java.compiler/share/classes/javax/lang/model/element/package-info.java
41161 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/**26* Interfaces used to model elements of the Java programming language.27*28* The term "element" in this package is used to refer to program29* elements, the declared entities that make up a program. Elements30* include classes, interfaces, methods, constructors, and fields.31* The interfaces in this package do not model the structure of a32* program inside a method body; for example there is no33* representation of a {@code for} loop or {@code try}-{@code finally}34* block. However, the interfaces can model some structures only35* appearing inside method bodies, such as local variables and36* anonymous classes.37*38* <p>When used in the context of annotation processing, an accurate39* model of the element being represented must be returned. As this40* is a language model, the source code provides the fiducial41* (reference) representation of the construct in question rather than42* a representation in an executable output like a class file.43* Executable output may serve as the basis for creating a modeling44* element. However, the process of translating source code to45* executable output may not permit recovering some aspects of the46* source code representation. For example, annotations with47* {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}48* {@linkplain java.lang.annotation.Retention retention} cannot be49* recovered from class files and class files might not be able to50* provide source position information.51*52* Names of {@linkplain53* javax.lang.model.element.ExecutableElement#getParameters()54* parameters} may not be recoverable from class files.55*56* The {@linkplain javax.lang.model.element.Modifier modifiers} on an57* element created from a class file may differ in some cases from an58* element for the same declaration created from a source file59* including:60*61* <ul>62* <li> {@code strictfp} on a class or interface63* <li> {@code final} on a parameter64* <li> {@code protected}, {@code private}, and {@code static} on classes and interfaces65* </ul>66*67* Some elements which are {@linkplain68* javax.lang.model.util.Elements.Origin#MANDATED mandated} may not be69* marked as such when created from class files.70*71* Additionally, {@linkplain72* javax.lang.model.util.Elements.Origin#SYNTHETIC synthetic}73* constructs in a class file, such as accessor methods used in74* implementing nested classes and {@linkplain75* javax.lang.model.util.Elements.Origin#isBridge(ExecutableElement)76* bridge methods} used in implementing covariant returns, are77* translation artifacts strictly outside of this model. However, when78* operating on class files, it is helpful be able to operate on such79* elements, screening them out when appropriate.80*81* <p>During annotation processing, operating on incomplete or82* erroneous programs is necessary; however, there are fewer83* guarantees about the nature of the resulting model. If the source84* code is not syntactically well-formed or has some other85* irrecoverable error that could not be removed by the generation of86* new classes or interfaces, a model may or may not be provided as a87* quality of implementation issue. If a program is syntactically88* valid but erroneous in some other fashion, any returned model must89* have no less information than if all the method bodies in the90* program were replaced by {@code "throw new RuntimeException();"}.91* If a program refers to a missing class or interface Xyz, the92* returned model must contain no less information than if the93* declaration of class or interface Xyz were assumed to be {@code94* "class Xyz {}"}, {@code "interface Xyz {}"}, {@code "enum Xyz {}"},95* {@code "@interface Xyz {}"}, or {@code "record Xyz {}"}. If a96* program refers to a missing class or interface {@code Xyz<K1,97* ... ,Kn>}, the returned model must contain no less information than98* if the declaration of Xyz were assumed to be {@code "class Xyz<T1,99* ... ,Tn> {}"} or {@code "interface Xyz<T1, ... ,Tn> {}"}100*101* <p> Unless otherwise specified in a particular implementation, the102* collections returned by methods in this package should be expected103* to be unmodifiable by the caller and unsafe for concurrent access.104*105* <p> Unless otherwise specified, methods in this package will throw106* a {@code NullPointerException} if given a {@code null} argument.107*108* @author Joseph D. Darcy109* @author Scott Seligman110* @author Peter von der Ahé111* @see javax.lang.model.util.Elements112* @jls 6.1 Declarations113* @jls 7.4 Package Declarations114* @jls 7.7 Module Declarations115* @jls 8.1 Class Declarations116* @jls 8.3 Field Declarations117* @jls 8.4 Method Declarations118* @jls 8.5 Member Class and Interface Declarations119* @jls 8.8 Constructor Declarations120* @jls 9.1 Interface Declarations121* @since 1.6122*/123package javax.lang.model.element;124125126