Path: blob/master/src/hotspot/share/runtime/fieldDescriptor.hpp
40951 views
/*1* Copyright (c) 1997, 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.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_RUNTIME_FIELDDESCRIPTOR_HPP25#define SHARE_RUNTIME_FIELDDESCRIPTOR_HPP2627#include "oops/constantPool.hpp"28#include "oops/fieldInfo.hpp"29#include "oops/instanceKlass.hpp"30#include "oops/symbol.hpp"31#include "utilities/accessFlags.hpp"32#include "utilities/constantTag.hpp"3334// A fieldDescriptor describes the attributes of a single field (instance or class variable).35// It needs the class constant pool to work (because it only holds indices into the pool36// rather than the actual info).3738class fieldDescriptor {39private:40AccessFlags _access_flags;41int _index; // the field index42constantPoolHandle _cp;4344// update the access_flags for the field in the klass45inline void update_klass_field_access_flag();4647inline FieldInfo* field() const;4849public:50fieldDescriptor() {51DEBUG_ONLY(_index = badInt);52}53fieldDescriptor(InstanceKlass* ik, int index) {54DEBUG_ONLY(_index = badInt);55reinitialize(ik, index);56}57inline Symbol* name() const;58inline Symbol* signature() const;59inline InstanceKlass* field_holder() const;60inline ConstantPool* constants() const;6162AccessFlags access_flags() const { return _access_flags; }63oop loader() const;64// Offset (in words) of field from start of instanceOop / Klass*65inline int offset() const;66Symbol* generic_signature() const;67int index() const { return _index; }68AnnotationArray* annotations() const;69AnnotationArray* type_annotations() const;7071// Initial field value72inline bool has_initial_value() const;73inline int initial_value_index() const;74constantTag initial_value_tag() const; // The tag will return true on one of is_int(), is_long(), is_single(), is_double()75jint int_initial_value() const;76jlong long_initial_value() const;77jfloat float_initial_value() const;78jdouble double_initial_value() const;79oop string_initial_value(TRAPS) const;8081// Field signature type82inline BasicType field_type() const;8384// Access flags85bool is_public() const { return access_flags().is_public(); }86bool is_private() const { return access_flags().is_private(); }87bool is_protected() const { return access_flags().is_protected(); }88bool is_package_private() const { return !is_public() && !is_private() && !is_protected(); }8990bool is_static() const { return access_flags().is_static(); }91bool is_final() const { return access_flags().is_final(); }92bool is_stable() const { return access_flags().is_stable(); }93bool is_volatile() const { return access_flags().is_volatile(); }94bool is_transient() const { return access_flags().is_transient(); }9596bool is_synthetic() const { return access_flags().is_synthetic(); }9798bool is_field_access_watched() const { return access_flags().is_field_access_watched(); }99bool is_field_modification_watched() const100{ return access_flags().is_field_modification_watched(); }101bool has_initialized_final_update() const { return access_flags().has_field_initialized_final_update(); }102bool has_generic_signature() const { return access_flags().field_has_generic_signature(); }103104bool is_trusted_final() const;105106inline void set_is_field_access_watched(const bool value);107inline void set_is_field_modification_watched(const bool value);108inline void set_has_initialized_final_update(const bool value);109110// Initialization111void reinitialize(InstanceKlass* ik, int index);112113114void print() const;115void print_on(outputStream* st) const PRODUCT_RETURN;116void print_on_for(outputStream* st, oop obj) PRODUCT_RETURN;117void verify() const PRODUCT_RETURN;118};119120#endif // SHARE_RUNTIME_FIELDDESCRIPTOR_HPP121122123