1 /*
2 * Copyright (c) 2005, 2013, 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
36 * appearing inside method bodies, such as local variables and
37 * anonymous classes.
38 *
39 * <p>When used in the context of annotation processing, an accurate
40 * model of the element being represented must be returned. As this
41 * is a language model, the source code provides the fiducial
42 * (reference) representation of the construct in question rather than
43 * a representation in an executable output like a class file.
44 * Executable output may serve as the basis for creating a modeling
45 * element. However, the process of translating source code to
46 * executable output may not permit recovering some aspects of the
47 * source code representation. For example, annotations with
48 * {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
49 * {@linkplain java.lang.annotation.Retention retention} cannot be
50 * recovered from class files and class files might not be able to
51 * provide source position information.
52 *
53 * Names of parameters may not be recoverable from class files.
54 *
55 * The {@linkplain javax.lang.model.element.Modifier modifiers} on an
56 * element may differ in some cases including:
57 *
58 * <ul>
59 * <li> {@code strictfp} on a class or interface
60 * <li> {@code final} on a parameter
61 * <li> {@code protected}, {@code private}, and {@code static} on classes and interfaces
62 * </ul>
63 *
64 * Additionally, synthetic constructs in a class file, such as
65 * accessor methods used in implementing nested classes and bridge
66 * methods used in implementing covariant returns, are translation
67 * artifacts outside of this model.
68 *
69 * <p>During annotation processing, operating on incomplete or
70 * erroneous programs is necessary; however, there are fewer
71 * guarantees about the nature of the resulting model. If the source
72 * code is not syntactically well-formed or has some other
73 * irrecoverable error that could not be removed by the generation of
74 * new types, a model may or may not be provided as a quality of
75 * implementation issue.
76 * If a program is syntactically valid but erroneous in some other
77 * fashion, any returned model must have no less information than if
78 * all the method bodies in the program were replaced by {@code "throw
79 * new RuntimeException();"}. If a program refers to a missing type XYZ,
80 * the returned model must contain no less information than if the
81 * declaration of type XYZ were assumed to be {@code "class XYZ {}"},
82 * {@code "interface XYZ {}"}, {@code "enum XYZ {}"}, or {@code
83 * "@interface XYZ {}"}. If a program refers to a missing type {@code
84 * XYZ<K1, ... ,Kn>}, the returned model must contain no less
85 * information than if the declaration of XYZ were assumed to be
86 * {@code "class XYZ<T1, ... ,Tn> {}"} or {@code "interface XYZ<T1,
87 * ... ,Tn> {}"}
|
1 /*
2 * Copyright (c) 2005, 2016, 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
36 * appearing inside method bodies, such as local variables and
37 * anonymous classes.
38 *
39 * <p>When used in the context of annotation processing, an accurate
40 * model of the element being represented must be returned. As this
41 * is a language model, the source code provides the fiducial
42 * (reference) representation of the construct in question rather than
43 * a representation in an executable output like a class file.
44 * Executable output may serve as the basis for creating a modeling
45 * element. However, the process of translating source code to
46 * executable output may not permit recovering some aspects of the
47 * source code representation. For example, annotations with
48 * {@linkplain java.lang.annotation.RetentionPolicy#SOURCE source}
49 * {@linkplain java.lang.annotation.Retention retention} cannot be
50 * recovered from class files and class files might not be able to
51 * provide source position information.
52 *
53 * Names of parameters may not be recoverable from class files.
54 *
55 * The {@linkplain javax.lang.model.element.Modifier modifiers} on an
56 * element created from a class file may differ in some cases from an
57 * element for the same declaration created from a source file
58 * including:
59 *
60 * <ul>
61 * <li> {@code strictfp} on a class or interface
62 * <li> {@code final} on a parameter
63 * <li> {@code protected}, {@code private}, and {@code static} on classes and interfaces
64 * </ul>
65 *
66 * Some elements which are {@linkplain Elements.Naturalness#MANDATED
67 * mandated} may not be marked as such when created from class files.
68 *
69 * Additionally, {@linkplain Elements.Naturalness#SYNTHETIC synthetic}
70 * constructs in a class file, such as accessor methods used in
71 * implementing nested classes and {@linkplain
72 * Elements#isBridge(Element) bridge methods} used in implementing
73 * covariant returns, are translation artifacts strictly outside of
74 * this model. However, when operation on class files, it is helpful
75 * be able to operate on such elements, screening them out when
76 * appropriate.
77 *
78 * <p>During annotation processing, operating on incomplete or
79 * erroneous programs is necessary; however, there are fewer
80 * guarantees about the nature of the resulting model. If the source
81 * code is not syntactically well-formed or has some other
82 * irrecoverable error that could not be removed by the generation of
83 * new types, a model may or may not be provided as a quality of
84 * implementation issue.
85 * If a program is syntactically valid but erroneous in some other
86 * fashion, any returned model must have no less information than if
87 * all the method bodies in the program were replaced by {@code "throw
88 * new RuntimeException();"}. If a program refers to a missing type XYZ,
89 * the returned model must contain no less information than if the
90 * declaration of type XYZ were assumed to be {@code "class XYZ {}"},
91 * {@code "interface XYZ {}"}, {@code "enum XYZ {}"}, or {@code
92 * "@interface XYZ {}"}. If a program refers to a missing type {@code
93 * XYZ<K1, ... ,Kn>}, the returned model must contain no less
94 * information than if the declaration of XYZ were assumed to be
95 * {@code "class XYZ<T1, ... ,Tn> {}"} or {@code "interface XYZ<T1,
96 * ... ,Tn> {}"}
|