Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/runtime/fieldDescriptor.hpp
32285 views
/*1* Copyright (c) 1997, 2013, 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.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_RUNTIME_FIELDDESCRIPTOR_HPP25#define SHARE_VM_RUNTIME_FIELDDESCRIPTOR_HPP2627#include "oops/constantPool.hpp"28#include "oops/symbol.hpp"29#include "runtime/fieldType.hpp"30#include "utilities/accessFlags.hpp"31#include "utilities/constantTag.hpp"3233// A fieldDescriptor describes the attributes of a single field (instance or class variable).34// It needs the class constant pool to work (because it only holds indices into the pool35// rather than the actual info).3637class fieldDescriptor VALUE_OBJ_CLASS_SPEC {38private:39AccessFlags _access_flags;40int _index; // the field index41constantPoolHandle _cp;4243// update the access_flags for the field in the klass44void update_klass_field_access_flag() {45InstanceKlass* ik = field_holder();46ik->field(index())->set_access_flags(_access_flags.as_short());47}4849FieldInfo* field() const {50InstanceKlass* ik = field_holder();51return ik->field(_index);52}5354public:55fieldDescriptor() {56DEBUG_ONLY(_index = badInt);57}58fieldDescriptor(InstanceKlass* ik, int index) {59DEBUG_ONLY(_index = badInt);60reinitialize(ik, index);61}62Symbol* name() const {63return field()->name(_cp);64}65Symbol* signature() const {66return field()->signature(_cp);67}68InstanceKlass* field_holder() const { return _cp->pool_holder(); }69ConstantPool* constants() const { return _cp(); }70AccessFlags access_flags() const { return _access_flags; }71oop loader() const;72// Offset (in words) of field from start of instanceOop / Klass*73int offset() const { return field()->offset(); }74Symbol* generic_signature() const;75int index() const { return _index; }76AnnotationArray* annotations() const;77AnnotationArray* type_annotations() const;7879// Initial field value80bool has_initial_value() const { return field()->initval_index() != 0; }81int initial_value_index() const { return field()->initval_index(); }82constantTag initial_value_tag() const; // The tag will return true on one of is_int(), is_long(), is_single(), is_double()83jint int_initial_value() const;84jlong long_initial_value() const;85jfloat float_initial_value() const;86jdouble double_initial_value() const;87oop string_initial_value(TRAPS) const;8889// Field signature type90BasicType field_type() const { return FieldType::basic_type(signature()); }9192// Access flags93bool is_public() const { return access_flags().is_public(); }94bool is_private() const { return access_flags().is_private(); }95bool is_protected() const { return access_flags().is_protected(); }96bool is_package_private() const { return !is_public() && !is_private() && !is_protected(); }9798bool is_static() const { return access_flags().is_static(); }99bool is_final() const { return access_flags().is_final(); }100bool is_stable() const { return access_flags().is_stable(); }101bool is_volatile() const { return access_flags().is_volatile(); }102bool is_transient() const { return access_flags().is_transient(); }103104bool is_synthetic() const { return access_flags().is_synthetic(); }105106bool is_field_access_watched() const { return access_flags().is_field_access_watched(); }107bool is_field_modification_watched() const108{ return access_flags().is_field_modification_watched(); }109bool has_initialized_final_update() const { return access_flags().has_field_initialized_final_update(); }110bool has_generic_signature() const { return access_flags().field_has_generic_signature(); }111112void set_is_field_access_watched(const bool value) {113_access_flags.set_is_field_access_watched(value);114update_klass_field_access_flag();115}116117void set_is_field_modification_watched(const bool value) {118_access_flags.set_is_field_modification_watched(value);119update_klass_field_access_flag();120}121122void set_has_initialized_final_update(const bool value) {123_access_flags.set_has_field_initialized_final_update(value);124update_klass_field_access_flag();125}126127// Initialization128void reinitialize(InstanceKlass* ik, int index);129130131void print() { print_on(tty); }132void print_on(outputStream* st) const PRODUCT_RETURN;133void print_on_for(outputStream* st, oop obj) PRODUCT_RETURN;134void verify() const PRODUCT_RETURN;135};136137#endif // SHARE_VM_RUNTIME_FIELDDESCRIPTOR_HPP138139140