src/share/vm/runtime/fieldDescriptor.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 5732
b2e698d2276c
parent 0
f90c822e73f8
child 8856
ac27a9c85bea
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_RUNTIME_FIELDDESCRIPTOR_HPP
aoqi@0 26 #define SHARE_VM_RUNTIME_FIELDDESCRIPTOR_HPP
aoqi@0 27
aoqi@0 28 #include "oops/constantPool.hpp"
aoqi@0 29 #include "oops/symbol.hpp"
aoqi@0 30 #include "runtime/fieldType.hpp"
aoqi@0 31 #include "utilities/accessFlags.hpp"
aoqi@0 32 #include "utilities/constantTag.hpp"
aoqi@0 33
aoqi@0 34 // A fieldDescriptor describes the attributes of a single field (instance or class variable).
aoqi@0 35 // It needs the class constant pool to work (because it only holds indices into the pool
aoqi@0 36 // rather than the actual info).
aoqi@0 37
aoqi@0 38 class fieldDescriptor VALUE_OBJ_CLASS_SPEC {
aoqi@0 39 private:
aoqi@0 40 AccessFlags _access_flags;
aoqi@0 41 int _index; // the field index
aoqi@0 42 constantPoolHandle _cp;
aoqi@0 43
aoqi@0 44 // update the access_flags for the field in the klass
aoqi@0 45 void update_klass_field_access_flag() {
aoqi@0 46 InstanceKlass* ik = field_holder();
aoqi@0 47 ik->field(index())->set_access_flags(_access_flags.as_short());
aoqi@0 48 }
aoqi@0 49
aoqi@0 50 FieldInfo* field() const {
aoqi@0 51 InstanceKlass* ik = field_holder();
aoqi@0 52 return ik->field(_index);
aoqi@0 53 }
aoqi@0 54
aoqi@0 55 public:
aoqi@0 56 fieldDescriptor() {
aoqi@0 57 DEBUG_ONLY(_index = badInt);
aoqi@0 58 }
aoqi@0 59 fieldDescriptor(InstanceKlass* ik, int index) {
aoqi@0 60 DEBUG_ONLY(_index = badInt);
aoqi@0 61 reinitialize(ik, index);
aoqi@0 62 }
aoqi@0 63 Symbol* name() const {
aoqi@0 64 return field()->name(_cp);
aoqi@0 65 }
aoqi@0 66 Symbol* signature() const {
aoqi@0 67 return field()->signature(_cp);
aoqi@0 68 }
aoqi@0 69 InstanceKlass* field_holder() const { return _cp->pool_holder(); }
aoqi@0 70 ConstantPool* constants() const { return _cp(); }
aoqi@0 71 AccessFlags access_flags() const { return _access_flags; }
aoqi@0 72 oop loader() const;
aoqi@0 73 // Offset (in words) of field from start of instanceOop / Klass*
aoqi@0 74 int offset() const { return field()->offset(); }
aoqi@0 75 Symbol* generic_signature() const;
aoqi@0 76 int index() const { return _index; }
aoqi@0 77 AnnotationArray* annotations() const;
aoqi@0 78 AnnotationArray* type_annotations() const;
aoqi@0 79
aoqi@0 80 // Initial field value
aoqi@0 81 bool has_initial_value() const { return field()->initval_index() != 0; }
aoqi@0 82 int initial_value_index() const { return field()->initval_index(); }
aoqi@0 83 constantTag initial_value_tag() const; // The tag will return true on one of is_int(), is_long(), is_single(), is_double()
aoqi@0 84 jint int_initial_value() const;
aoqi@0 85 jlong long_initial_value() const;
aoqi@0 86 jfloat float_initial_value() const;
aoqi@0 87 jdouble double_initial_value() const;
aoqi@0 88 oop string_initial_value(TRAPS) const;
aoqi@0 89
aoqi@0 90 // Field signature type
aoqi@0 91 BasicType field_type() const { return FieldType::basic_type(signature()); }
aoqi@0 92
aoqi@0 93 // Access flags
aoqi@0 94 bool is_public() const { return access_flags().is_public(); }
aoqi@0 95 bool is_private() const { return access_flags().is_private(); }
aoqi@0 96 bool is_protected() const { return access_flags().is_protected(); }
aoqi@0 97 bool is_package_private() const { return !is_public() && !is_private() && !is_protected(); }
aoqi@0 98
aoqi@0 99 bool is_static() const { return access_flags().is_static(); }
aoqi@0 100 bool is_final() const { return access_flags().is_final(); }
aoqi@0 101 bool is_volatile() const { return access_flags().is_volatile(); }
aoqi@0 102 bool is_transient() const { return access_flags().is_transient(); }
aoqi@0 103
aoqi@0 104 bool is_synthetic() const { return access_flags().is_synthetic(); }
aoqi@0 105
aoqi@0 106 bool is_field_access_watched() const { return access_flags().is_field_access_watched(); }
aoqi@0 107 bool is_field_modification_watched() const
aoqi@0 108 { return access_flags().is_field_modification_watched(); }
aoqi@0 109 bool has_generic_signature() const { return access_flags().field_has_generic_signature(); }
aoqi@0 110
aoqi@0 111 void set_is_field_access_watched(const bool value) {
aoqi@0 112 _access_flags.set_is_field_access_watched(value);
aoqi@0 113 update_klass_field_access_flag();
aoqi@0 114 }
aoqi@0 115
aoqi@0 116 void set_is_field_modification_watched(const bool value) {
aoqi@0 117 _access_flags.set_is_field_modification_watched(value);
aoqi@0 118 update_klass_field_access_flag();
aoqi@0 119 }
aoqi@0 120
aoqi@0 121 // Initialization
aoqi@0 122 void reinitialize(InstanceKlass* ik, int index);
aoqi@0 123
aoqi@0 124 // Print
aoqi@0 125 void print() { print_on(tty); }
aoqi@0 126 void print_on(outputStream* st) const PRODUCT_RETURN;
aoqi@0 127 void print_on_for(outputStream* st, oop obj) PRODUCT_RETURN;
aoqi@0 128 void verify() const PRODUCT_RETURN;
aoqi@0 129 };
aoqi@0 130
aoqi@0 131 #endif // SHARE_VM_RUNTIME_FIELDDESCRIPTOR_HPP

mercurial