< prev index next >

src/hotspot/share/oops/fieldStreams.hpp

Print this page

 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_FIELDSTREAMS_HPP
 26 #define SHARE_OOPS_FIELDSTREAMS_HPP
 27 
 28 #include "oops/instanceKlass.hpp"
 29 #include "oops/fieldInfo.hpp"
 30 #include "runtime/fieldDescriptor.hpp"
 31 
 32 // The is the base class for iteration over the fields array
 33 // describing the declared fields in the class.  Several subclasses
 34 // are provided depending on the kind of iteration required.  The
 35 // JavaFieldStream is for iterating over regular Java fields and it
 36 // generally the preferred iterator.  InternalFieldStream only
 37 // iterates over fields that have been injected by the JVM.
 38 // AllFieldStream exposes all fields and should only be used in rare
 39 // cases.
 40 // HierarchicalFieldStream allows to also iterate over fields of supertypes.
 41 class FieldStreamBase : public StackObj {

 42  protected:
 43   const Array<u1>*    _fieldinfo_stream;
 44   FieldInfoReader     _reader;
 45   constantPoolHandle  _constants;
 46   int                 _index;
 47   int                 _limit;
 48 
 49   FieldInfo           _fi_buf;
 50   fieldDescriptor     _fd_buf;
 51 
 52   FieldInfo const * field() const {
 53     assert(!done(), "no more fields");
 54     return &_fi_buf;
 55   }
 56 
 57   inline FieldStreamBase(const Array<u1>* fieldinfo_stream, ConstantPool* constants, int start, int limit);
 58 
 59   inline FieldStreamBase(Array<u1>* fieldinfo_stream, ConstantPool* constants);
 60 
 61   private:

 93   Symbol* name() const {
 94     return field()->name(_constants());
 95   }
 96 
 97   Symbol* signature() const {
 98     return field()->signature(_constants());
 99   }
100 
101   Symbol* generic_signature() const {
102     if (field()->field_flags().is_generic()) {
103       return _constants->symbol_at(field()->generic_signature_index());
104     } else {
105       return nullptr;
106     }
107   }
108 
109   int offset() const {
110     return field()->offset();
111   }
112 








113   bool is_contended() const {
114     return field()->is_contended();
115   }
116 
117   int contended_group() const {
118     return field()->contended_group();
119   }
120 




121   // Convenient methods
122 
123   FieldInfo to_FieldInfo() {
124     return _fi_buf;
125   }
126 
127   int num_total_fields() const {
128     return FieldInfoStream::num_total_fields(_fieldinfo_stream);
129   }
130 
131   // bridge to a heavier API:
132   fieldDescriptor& field_descriptor() const {
133     fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf);
134     field.reinitialize(field_holder(), _index);
135     return field;
136   }
137 };
138 
139 // Iterate over only the Java fields
140 class JavaFieldStream : public FieldStreamBase {

220     }
221   }
222 
223  public:
224   HierarchicalFieldStream(InstanceKlass* klass) :
225     _interfaces(klass->transitive_interfaces()),
226     _next_klass(klass),
227     _current_stream(FieldStreamType(klass)),
228     _interface_index(_interfaces->length()) {
229       prepare();
230   }
231 
232   void next() {
233     _current_stream.next();
234     next_stream_if_done();
235   }
236 
237   bool done() const { return _next_klass == nullptr && _current_stream.done(); }
238 
239   // bridge functions from FieldStreamBase



240 
241   AccessFlags access_flags() const {
242     return _current_stream.access_flags();
243   }
244 
245   FieldInfo::FieldFlags field_flags() const {
246     return _current_stream.field_flags();
247   }
248 
249   Symbol* name() const {
250     return _current_stream.name();
251   }
252 
253   Symbol* signature() const {
254     return _current_stream.signature();
255   }
256 
257   Symbol* generic_signature() const {
258     return _current_stream.generic_signature();
259   }

261   int offset() const {
262     return _current_stream.offset();
263   }
264 
265   bool is_contended() const {
266     return _current_stream.is_contended();
267   }
268 
269   int contended_group() const {
270     return _current_stream.contended_group();
271   }
272 
273   FieldInfo to_FieldInfo() {
274     return _current_stream.to_FieldInfo();
275   }
276 
277   fieldDescriptor& field_descriptor() const {
278     return _current_stream.field_descriptor();
279   }
280 



281 };
282 
283 #endif // SHARE_OOPS_FIELDSTREAMS_HPP

 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_FIELDSTREAMS_HPP
 26 #define SHARE_OOPS_FIELDSTREAMS_HPP
 27 
 28 #include "oops/instanceKlass.hpp"
 29 #include "oops/fieldInfo.hpp"
 30 #include "runtime/fieldDescriptor.hpp"
 31 
 32 // The is the base class for iteration over the fields array
 33 // describing the declared fields in the class.  Several subclasses
 34 // are provided depending on the kind of iteration required.  The
 35 // JavaFieldStream is for iterating over regular Java fields and it
 36 // generally the preferred iterator.  InternalFieldStream only
 37 // iterates over fields that have been injected by the JVM.
 38 // AllFieldStream exposes all fields and should only be used in rare
 39 // cases.
 40 // HierarchicalFieldStream allows to also iterate over fields of supertypes.
 41 class FieldStreamBase : public StackObj {
 42 
 43  protected:
 44   const Array<u1>*    _fieldinfo_stream;
 45   FieldInfoReader     _reader;
 46   constantPoolHandle  _constants;
 47   int                 _index;
 48   int                 _limit;
 49 
 50   FieldInfo           _fi_buf;
 51   fieldDescriptor     _fd_buf;
 52 
 53   FieldInfo const * field() const {
 54     assert(!done(), "no more fields");
 55     return &_fi_buf;
 56   }
 57 
 58   inline FieldStreamBase(const Array<u1>* fieldinfo_stream, ConstantPool* constants, int start, int limit);
 59 
 60   inline FieldStreamBase(Array<u1>* fieldinfo_stream, ConstantPool* constants);
 61 
 62   private:

 94   Symbol* name() const {
 95     return field()->name(_constants());
 96   }
 97 
 98   Symbol* signature() const {
 99     return field()->signature(_constants());
100   }
101 
102   Symbol* generic_signature() const {
103     if (field()->field_flags().is_generic()) {
104       return _constants->symbol_at(field()->generic_signature_index());
105     } else {
106       return nullptr;
107     }
108   }
109 
110   int offset() const {
111     return field()->offset();
112   }
113 
114   bool is_null_free_inline_type() {
115     return field()->field_flags().is_null_free_inline_type();
116   }
117 
118   bool is_flat() const {
119     return field()->field_flags().is_flat();
120   }
121 
122   bool is_contended() const {
123     return field()->is_contended();
124   }
125 
126   int contended_group() const {
127     return field()->contended_group();
128   }
129 
130   int null_marker_offset() const {
131     return field()->null_marker_offset();
132   }
133 
134   // Convenient methods
135 
136   FieldInfo to_FieldInfo() {
137     return _fi_buf;
138   }
139 
140   int num_total_fields() const {
141     return FieldInfoStream::num_total_fields(_fieldinfo_stream);
142   }
143 
144   // bridge to a heavier API:
145   fieldDescriptor& field_descriptor() const {
146     fieldDescriptor& field = const_cast<fieldDescriptor&>(_fd_buf);
147     field.reinitialize(field_holder(), _index);
148     return field;
149   }
150 };
151 
152 // Iterate over only the Java fields
153 class JavaFieldStream : public FieldStreamBase {

233     }
234   }
235 
236  public:
237   HierarchicalFieldStream(InstanceKlass* klass) :
238     _interfaces(klass->transitive_interfaces()),
239     _next_klass(klass),
240     _current_stream(FieldStreamType(klass)),
241     _interface_index(_interfaces->length()) {
242       prepare();
243   }
244 
245   void next() {
246     _current_stream.next();
247     next_stream_if_done();
248   }
249 
250   bool done() const { return _next_klass == nullptr && _current_stream.done(); }
251 
252   // bridge functions from FieldStreamBase
253   int index() const {
254     return _current_stream.index();
255   }
256 
257   AccessFlags access_flags() const {
258     return _current_stream.access_flags();
259   }
260 
261   FieldInfo::FieldFlags field_flags() const {
262     return _current_stream.field_flags();
263   }
264 
265   Symbol* name() const {
266     return _current_stream.name();
267   }
268 
269   Symbol* signature() const {
270     return _current_stream.signature();
271   }
272 
273   Symbol* generic_signature() const {
274     return _current_stream.generic_signature();
275   }

277   int offset() const {
278     return _current_stream.offset();
279   }
280 
281   bool is_contended() const {
282     return _current_stream.is_contended();
283   }
284 
285   int contended_group() const {
286     return _current_stream.contended_group();
287   }
288 
289   FieldInfo to_FieldInfo() {
290     return _current_stream.to_FieldInfo();
291   }
292 
293   fieldDescriptor& field_descriptor() const {
294     return _current_stream.field_descriptor();
295   }
296 
297   bool is_flat() const {
298     return _current_stream.is_flat();
299   }
300 };
301 
302 #endif // SHARE_OOPS_FIELDSTREAMS_HPP
< prev index next >