001/*
002 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package jdk.internal.jvmci.meta;
024
025import java.lang.annotation.*;
026import java.lang.reflect.*;
027
028/**
029 * Represents a reference to a resolved Java field. Fields, like methods and types, are resolved
030 * through {@link ConstantPool constant pools}.
031 */
032public interface ResolvedJavaField extends JavaField, ModifiersProvider {
033
034    /**
035     * {@inheritDoc}
036     * <p>
037     * Only the {@linkplain Modifier#fieldModifiers() field flags} specified in the JVM
038     * specification will be included in the returned mask.
039     */
040    int getModifiers();
041
042    default boolean isFinal() {
043        return ModifiersProvider.super.isFinalFlagSet();
044    }
045
046    /**
047     * Determines if this field was injected by the VM. Such a field, for example, is not derived
048     * from a class file.
049     */
050    boolean isInternal();
051
052    /**
053     * Determines if this field is a synthetic field as defined by the Java Language Specification.
054     */
055    boolean isSynthetic();
056
057    /**
058     * Returns the {@link ResolvedJavaType} object representing the class or interface that declares
059     * this field.
060     */
061    ResolvedJavaType getDeclaringClass();
062
063    /**
064     * Returns the annotation for the specified type of this field, if such an annotation is
065     * present.
066     *
067     * @param annotationClass the Class object corresponding to the annotation type
068     * @return this element's annotation for the specified annotation type if present on this field,
069     *         else {@code null}
070     */
071    <T extends Annotation> T getAnnotation(Class<T> annotationClass);
072
073    /**
074     * Returns an object representing the unique location identity of this resolved Java field.
075     *
076     * @return the location identity of the field
077     */
078    LocationIdentity getLocationIdentity();
079}