comparison src/share/vm/runtime/fieldDescriptor.hpp @ 3938:e6b1331a51d2

7086585: make Java field injection more flexible Reviewed-by: jrose, twisti, kvn, coleenp
author never
date Sat, 10 Sep 2011 17:29:02 -0700
parents 1d1603768966
children 04b9a2566eec 71afdabfd05b
comparison
equal deleted inserted replaced
3937:c565834fb592 3938:e6b1331a51d2
38 // rather than the actual info). 38 // rather than the actual info).
39 39
40 class fieldDescriptor VALUE_OBJ_CLASS_SPEC { 40 class fieldDescriptor VALUE_OBJ_CLASS_SPEC {
41 private: 41 private:
42 AccessFlags _access_flags; 42 AccessFlags _access_flags;
43 int _name_index; 43 int _index; // the field index
44 int _signature_index;
45 int _initial_value_index;
46 int _offset;
47 int _generic_signature_index;
48 int _index; // index into fields() array
49 constantPoolHandle _cp; 44 constantPoolHandle _cp;
50 45
46 // update the access_flags for the field in the klass
47 void update_klass_field_access_flag() {
48 instanceKlass* ik = instanceKlass::cast(field_holder());
49 ik->field(index())->set_access_flags(_access_flags.as_short());
50 }
51
52 FieldInfo* field() const {
53 instanceKlass* ik = instanceKlass::cast(field_holder());
54 return ik->field(_index);
55 }
56
51 public: 57 public:
52 Symbol* name() const { return _cp->symbol_at(_name_index); } 58 Symbol* name() const {
53 Symbol* signature() const { return _cp->symbol_at(_signature_index); } 59 return field()->name(_cp);
60 }
61 Symbol* signature() const {
62 return field()->signature(_cp);
63 }
54 klassOop field_holder() const { return _cp->pool_holder(); } 64 klassOop field_holder() const { return _cp->pool_holder(); }
55 constantPoolOop constants() const { return _cp(); } 65 constantPoolOop constants() const { return _cp(); }
56 AccessFlags access_flags() const { return _access_flags; } 66 AccessFlags access_flags() const { return _access_flags; }
57 oop loader() const; 67 oop loader() const;
58 // Offset (in words) of field from start of instanceOop / klassOop 68 // Offset (in words) of field from start of instanceOop / klassOop
59 int offset() const { return _offset; } 69 int offset() const { return field()->offset(); }
60 Symbol* generic_signature() const { return (_generic_signature_index > 0 ? _cp->symbol_at(_generic_signature_index) : (Symbol*)NULL); } 70 Symbol* generic_signature() const { return field()->generic_signature(_cp); }
61 int index() const { return _index; } 71 int index() const { return _index; }
62 typeArrayOop annotations() const; 72 typeArrayOop annotations() const;
63 73
64 // Initial field value 74 // Initial field value
65 bool has_initial_value() const { return _initial_value_index != 0; } 75 bool has_initial_value() const { return field()->initval_index() != 0; }
76 int initial_value_index() const { return field()->initval_index(); }
66 constantTag initial_value_tag() const; // The tag will return true on one of is_int(), is_long(), is_single(), is_double() 77 constantTag initial_value_tag() const; // The tag will return true on one of is_int(), is_long(), is_single(), is_double()
67 jint int_initial_value() const; 78 jint int_initial_value() const;
68 jlong long_initial_value() const; 79 jlong long_initial_value() const;
69 jfloat float_initial_value() const; 80 jfloat float_initial_value() const;
70 jdouble double_initial_value() const; 81 jdouble double_initial_value() const;
72 83
73 // Field signature type 84 // Field signature type
74 BasicType field_type() const { return FieldType::basic_type(signature()); } 85 BasicType field_type() const { return FieldType::basic_type(signature()); }
75 86
76 // Access flags 87 // Access flags
77 bool is_public() const { return _access_flags.is_public(); } 88 bool is_public() const { return access_flags().is_public(); }
78 bool is_private() const { return _access_flags.is_private(); } 89 bool is_private() const { return access_flags().is_private(); }
79 bool is_protected() const { return _access_flags.is_protected(); } 90 bool is_protected() const { return access_flags().is_protected(); }
80 bool is_package_private() const { return !is_public() && !is_private() && !is_protected(); } 91 bool is_package_private() const { return !is_public() && !is_private() && !is_protected(); }
81 92
82 bool is_static() const { return _access_flags.is_static(); } 93 bool is_static() const { return access_flags().is_static(); }
83 bool is_final() const { return _access_flags.is_final(); } 94 bool is_final() const { return access_flags().is_final(); }
84 bool is_volatile() const { return _access_flags.is_volatile(); } 95 bool is_volatile() const { return access_flags().is_volatile(); }
85 bool is_transient() const { return _access_flags.is_transient(); } 96 bool is_transient() const { return access_flags().is_transient(); }
86 97
87 bool is_synthetic() const { return _access_flags.is_synthetic(); } 98 bool is_synthetic() const { return access_flags().is_synthetic(); }
88 99
89 bool is_field_access_watched() const { return _access_flags.is_field_access_watched(); } 100 bool is_field_access_watched() const { return access_flags().is_field_access_watched(); }
90 bool is_field_modification_watched() const 101 bool is_field_modification_watched() const
91 { return _access_flags.is_field_modification_watched(); } 102 { return access_flags().is_field_modification_watched(); }
92 void set_is_field_access_watched(const bool value) 103
93 { _access_flags.set_is_field_access_watched(value); } 104 void set_is_field_access_watched(const bool value) {
94 void set_is_field_modification_watched(const bool value) 105 _access_flags.set_is_field_access_watched(value);
95 { _access_flags.set_is_field_modification_watched(value); } 106 update_klass_field_access_flag();
107 }
108
109 void set_is_field_modification_watched(const bool value) {
110 _access_flags.set_is_field_modification_watched(value);
111 update_klass_field_access_flag();
112 }
96 113
97 // Initialization 114 // Initialization
98 void initialize(klassOop k, int index); 115 void initialize(klassOop k, int index);
99 116
100 // Print 117 // Print