src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java
author darcy
Wed, 27 Sep 2017 14:23:41 -0700
changeset 47283 ce5fd3ba3fea
parent 47216 71c04702a3d5
child 55118 9ea55cb79d77
permissions -rw-r--r--
8187982: Update SourceVersion to mention restricted keywords Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
22448
a85fbad9d687 8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
ksrini
parents: 15042
diff changeset
     2
 * Copyright (c) 2005, 2013, 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: 10
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: 10
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: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
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.element;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import javax.lang.model.util.Elements;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * Represents a field, {@code enum} constant, method or constructor
8233
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
    32
 * parameter, local variable, resource variable, or exception
fda68eae1504 7015530: Reiterate API specializations in javax.lang.model.elment subinterfaces
darcy
parents: 5520
diff changeset
    33
 * parameter.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * @author Peter von der Ahé
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
public interface VariableElement extends Element {
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
     * Returns the value of this variable if this is a {@code final}
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
     * field initialized to a compile-time constant.  Returns {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
     * null} otherwise.  The value will be of a primitive type or a
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     * {@code String}.  If the value is of a primitive type, it is
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
     * wrapped in the appropriate wrapper class (such as {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
     * Integer}).
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * <p>Note that not all {@code final} fields will have
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * constant values.  In particular, {@code enum} constants are
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * <em>not</em> considered to be compile-time constants.  To have a
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * constant value, a field's type must be either a primitive type
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * or {@code String}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * @return the value of this variable if this is a {@code final}
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     * field initialized to a compile-time constant, or {@code null}
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     * otherwise
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     * @see Elements#getConstantExpression(Object)
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8233
diff changeset
    61
     * @jls 15.28 Constant Expression
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 8233
diff changeset
    62
     * @jls 4.12.4 final Variables
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    Object getConstantValue();
15042
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    65
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    66
    /**
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    67
     * Returns the simple name of this variable element.
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    68
     *
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    69
     * <p>For method and constructor parameters, the name of each
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    70
     * parameter must be distinct from the names of all other
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    71
     * parameters of the same executable.  If the original source
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    72
     * names are not available, an implementation may synthesize names
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    73
     * subject to the distinctness requirement above.
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    74
     *
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    75
     * @return the simple name of this variable element
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    76
     */
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    77
    @Override
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    78
    Name getSimpleName();
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    79
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    80
    /**
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    81
     * Returns the enclosing element of this variable.
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    82
     *
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    83
     * The enclosing element of a method or constructor parameter is
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    84
     * the executable declaring the parameter.
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    85
     *
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    86
     * @return the enclosing element of this variable
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    87
     */
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    88
    @Override
88ce00b3841a 8004730: Add language model support for parameter reflection
darcy
parents: 14258
diff changeset
    89
    Element getEnclosingElement();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
}