< prev index next >

src/hotspot/share/classfile/classFileParser.hpp

Print this page

 57   unsigned int _nonstatic_oop_map_count;
 58   unsigned int _max_nonstatic_oop_maps;
 59 
 60   OopMapBlocksBuilder(unsigned int  max_blocks);
 61   OopMapBlock* last_oop_map() const;
 62   void initialize_inherited_blocks(OopMapBlock* blocks, unsigned int nof_blocks);
 63   void add(int offset, int count);
 64   void copy(OopMapBlock* dst);
 65   void compact();
 66   void print_on(outputStream* st) const;
 67   void print_value_on(outputStream* st) const;
 68 };
 69 
 70 // Values needed for oopmap and InstanceKlass creation
 71 class FieldLayoutInfo : public ResourceObj {
 72  public:
 73   OopMapBlocksBuilder* oop_map_blocks;
 74   int _instance_size;
 75   int _nonstatic_field_size;
 76   int _static_field_size;
 77   bool  _has_nonstatic_fields;













 78 };
 79 
 80 // Parser for for .class files
 81 //
 82 // The bytes describing the class file structure is read from a Stream object
 83 
 84 class ClassFileParser {
 85   friend class FieldLayoutBuilder;
 86   friend class FieldLayout;
 87 
 88   class ClassAnnotationCollector;
 89   class FieldAnnotationCollector;
 90 
 91  public:
 92   // The ClassFileParser has an associated "publicity" level
 93   // It is used to control which subsystems (if any)
 94   // will observe the parsing (logging, events, tracing).
 95   // Default level is "BROADCAST", which is equivalent to
 96   // a "public" parsing attempt.
 97   //

112   const ClassFileStream* _stream; // Actual input stream
113   Symbol* _class_name;
114   mutable ClassLoaderData* _loader_data;
115   const bool _is_hidden;
116   const bool _can_access_vm_annotations;
117   int _orig_cp_size;
118   unsigned int _static_oop_count;
119 
120   // Metadata created before the instance klass is created.  Must be deallocated
121   // if not transferred to the InstanceKlass upon successful class loading
122   // in which case these pointers have been set to null.
123   const InstanceKlass* _super_klass;
124   ConstantPool* _cp;
125   Array<u1>* _fieldinfo_stream;
126   Array<FieldStatus>* _fields_status;
127   Array<Method*>* _methods;
128   Array<u2>* _inner_classes;
129   Array<u2>* _nest_members;
130   u2 _nest_host;
131   Array<u2>* _permitted_subclasses;

132   Array<RecordComponent*>* _record_components;
133   Array<InstanceKlass*>* _local_interfaces;

134   Array<InstanceKlass*>* _transitive_interfaces;
135   Annotations* _combined_annotations;
136   AnnotationArray* _class_annotations;
137   AnnotationArray* _class_type_annotations;
138   Array<AnnotationArray*>* _fields_annotations;
139   Array<AnnotationArray*>* _fields_type_annotations;
140   InstanceKlass* _klass;  // InstanceKlass* once created.
141   InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
142 
143   ClassAnnotationCollector* _parsed_annotations;
144   FieldLayoutInfo* _field_info;

145   GrowableArray<FieldInfo>* _temp_field_info;
146   const intArray* _method_ordering;
147   GrowableArray<Method*>* _all_mirandas;
148 
149   enum { fixed_buffer_size = 128 };
150   u_char _linenumbertable_buffer[fixed_buffer_size];
151 
152   // Size of Java vtable (in words)
153   int _vtable_size;
154   int _itable_size;
155 
156   int _num_miranda_methods;
157 

158   Handle _protection_domain;
159   AccessFlags _access_flags;
160 
161   // for tracing and notifications
162   Publicity _pub_level;
163 
164   // Used to keep track of whether a constant pool item 19 or 20 is found.  These
165   // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
166   // in regular class files.  For class file version >= 53, a CFE cannot be thrown
167   // immediately when these are seen because a NCDFE must be thrown if the class's
168   // access_flags have ACC_MODULE set.  But, the access_flags haven't been looked
169   // at yet.  So, the bad constant pool item is cached here.  A value of zero
170   // means that no constant pool item 19 or 20 was found.
171   short _bad_constant_seen;
172 
173   // class attributes parsed before the instance klass is created:
174   bool _synthetic_flag;
175   int _sde_length;
176   const char* _sde_buffer;
177   u2 _sourcefile_index;
178   u2 _generic_signature_index;
179 
180   u2 _major_version;
181   u2 _minor_version;
182   u2 _this_class_index;
183   u2 _super_class_index;
184   u2 _itfs_len;
185   u2 _java_fields_count;
186 
187   bool _need_verify;
188 
189   bool _has_nonstatic_concrete_methods;
190   bool _declares_nonstatic_concrete_methods;
191   bool _has_localvariable_table;
192   bool _has_final_method;
193   bool _has_contended_fields;
194 





195   // precomputed flags
196   bool _has_finalizer;
197   bool _has_empty_finalizer;
198   int _max_bootstrap_specifier_index;  // detects BSS values
199 
200   void parse_stream(const ClassFileStream* const stream, TRAPS);
201 
202   void mangle_hidden_class_name(InstanceKlass* const ik);
203 
204   void post_process_parsed_stream(const ClassFileStream* const stream,
205                                   ConstantPool* cp,
206                                   TRAPS);
207 
208   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH,
209                            const ClassInstanceInfo& cl_inst_info, TRAPS);
210 
211   void set_klass(InstanceKlass* instance);
212 
213   void set_class_bad_constant_seen(short bad_constant);
214   short class_bad_constant_seen() { return  _bad_constant_seen; }

240                         bool* has_nonstatic_concrete_methods,
241                         TRAPS);
242 
243   const InstanceKlass* parse_super_class(ConstantPool* const cp,
244                                          const int super_class_index,
245                                          const bool need_verify,
246                                          TRAPS);
247 
248   // Field parsing
249   void parse_field_attributes(const ClassFileStream* const cfs,
250                               u2 attributes_count,
251                               bool is_static,
252                               u2 signature_index,
253                               u2* const constantvalue_index_addr,
254                               bool* const is_synthetic_addr,
255                               u2* const generic_signature_index_addr,
256                               FieldAnnotationCollector* parsed_annotations,
257                               TRAPS);
258 
259   void parse_fields(const ClassFileStream* const cfs,
260                     bool is_interface,
261                     ConstantPool* cp,
262                     const int cp_size,
263                     u2* const java_fields_count_ptr,
264                     TRAPS);
265 
266   // Method parsing
267   Method* parse_method(const ClassFileStream* const cfs,
268                        bool is_interface,


269                        const ConstantPool* cp,
270                        bool* const has_localvariable_table,
271                        TRAPS);
272 
273   void parse_methods(const ClassFileStream* const cfs,
274                      bool is_interface,


275                      bool* const has_localvariable_table,
276                      bool* const has_final_method,
277                      bool* const declares_nonstatic_concrete_methods,
278                      TRAPS);
279 
280   const unsafe_u2* parse_exception_table(const ClassFileStream* const stream,
281                                          u4 code_length,
282                                          u4 exception_table_length,
283                                          TRAPS);
284 
285   void parse_linenumber_table(u4 code_attribute_length,
286                               u4 code_length,
287                               CompressedLineNumberWriteStream**const write_stream,
288                               TRAPS);
289 
290   const unsafe_u2* parse_localvariable_table(const ClassFileStream* const cfs,
291                                              u4 code_length,
292                                              u2 max_locals,
293                                              u4 code_attribute_length,
294                                              u2* const localvariable_table_length,

309 
310   // Check for circularity in InnerClasses attribute.
311   bool check_inner_classes_circularity(const ConstantPool* cp, int length, TRAPS);
312 
313   u2   parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs,
314                                                const ConstantPool* cp,
315                                                const u1* const inner_classes_attribute_start,
316                                                bool parsed_enclosingmethod_attribute,
317                                                u2 enclosing_method_class_index,
318                                                u2 enclosing_method_method_index,
319                                                TRAPS);
320 
321   u2 parse_classfile_nest_members_attribute(const ClassFileStream* const cfs,
322                                             const u1* const nest_members_attribute_start,
323                                             TRAPS);
324 
325   u2 parse_classfile_permitted_subclasses_attribute(const ClassFileStream* const cfs,
326                                                     const u1* const permitted_subclasses_attribute_start,
327                                                     TRAPS);
328 




329   u4 parse_classfile_record_attribute(const ClassFileStream* const cfs,
330                                       const ConstantPool* cp,
331                                       const u1* const record_attribute_start,
332                                       TRAPS);
333 
334   void parse_classfile_attributes(const ClassFileStream* const cfs,
335                                   ConstantPool* cp,
336                                   ClassAnnotationCollector* parsed_annotations,
337                                   TRAPS);
338 
339   void parse_classfile_synthetic_attribute();
340   void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
341   void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
342                                                    ConstantPool* cp,
343                                                    u4 attribute_length,
344                                                    TRAPS);
345 
346   // Annotations handling
347   AnnotationArray* allocate_annotations(const u1* const anno,
348                                         int anno_length,

401                                  const char *name,
402                                  TRAPS) const {
403     if (!b) { classfile_parse_error(msg, index, name, THREAD); return; }
404   }
405 
406   void throwIllegalSignature(const char* type,
407                              const Symbol* name,
408                              const Symbol* sig,
409                              TRAPS) const;
410 
411   void verify_constantvalue(const ConstantPool* const cp,
412                             int constantvalue_index,
413                             int signature_index,
414                             TRAPS) const;
415 
416   void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const;
417   void verify_legal_class_name(const Symbol* name, TRAPS) const;
418   void verify_legal_field_name(const Symbol* name, TRAPS) const;
419   void verify_legal_method_name(const Symbol* name, TRAPS) const;
420 


421   void verify_legal_field_signature(const Symbol* fieldname,
422                                     const Symbol* signature,
423                                     TRAPS) const;
424   int  verify_legal_method_signature(const Symbol* methodname,
425                                      const Symbol* signature,
426                                      TRAPS) const;
427   void verify_legal_name_with_signature(const Symbol* name,
428                                         const Symbol* signature,
429                                         TRAPS) const;
430 
431   void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS);
432 
433   void verify_legal_class_modifiers(jint flags, TRAPS) const;
434   void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS) const;


435   void verify_legal_method_modifiers(jint flags,
436                                      bool is_interface,
437                                      const Symbol* name,
438                                      TRAPS) const;
439 
440   void check_super_class_access(const InstanceKlass* this_klass,
441                                 TRAPS);
442 
443   void check_super_interface_access(const InstanceKlass* this_klass,
444                                     TRAPS);
445 
446   const char* skip_over_field_signature(const char* signature,
447                                         bool void_ok,
448                                         unsigned int length,
449                                         TRAPS) const;
450 
451   // Wrapper for constantTag.is_klass_[or_]reference.
452   // In older versions of the VM, Klass*s cannot sneak into early phases of
453   // constant pool construction, but in later versions they can.
454   // %%% Let's phase out the old is_klass_reference.
455   bool valid_klass_reference_at(int index) const {
456     return _cp->is_within_bounds(index) &&

468                                 u2* const localvariable_table_length,
469                                 const unsafe_u2** const localvariable_table_start,
470                                 int lvtt_cnt,
471                                 u2* const localvariable_type_table_length,
472                                 const unsafe_u2** const localvariable_type_table_start,
473                                 TRAPS);
474 
475   void copy_method_annotations(ConstMethod* cm,
476                                const u1* runtime_visible_annotations,
477                                int runtime_visible_annotations_length,
478                                const u1* runtime_visible_parameter_annotations,
479                                int runtime_visible_parameter_annotations_length,
480                                const u1* runtime_visible_type_annotations,
481                                int runtime_visible_type_annotations_length,
482                                const u1* annotation_default,
483                                int annotation_default_length,
484                                TRAPS);
485 
486   void update_class_name(Symbol* new_name);
487 



488  public:
489   ClassFileParser(ClassFileStream* stream,
490                   Symbol* name,
491                   ClassLoaderData* loader_data,
492                   const ClassLoadInfo* cl_info,
493                   Publicity pub_level,
494                   TRAPS);
495 
496   ~ClassFileParser();
497 
498   InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, const ClassInstanceInfo& cl_inst_info, TRAPS);
499 
500   const ClassFileStream* clone_stream() const;
501 
502   void set_klass_to_deallocate(InstanceKlass* klass);
503 
504   int static_field_size() const;
505   int total_oop_map_count() const;
506   jint layout_size() const;
507 
508   int vtable_size() const { return _vtable_size; }
509   int itable_size() const { return _itable_size; }
510 
511   u2 this_class_index() const { return _this_class_index; }
512 
513   bool is_hidden() const { return _is_hidden; }
514   bool is_interface() const { return _access_flags.is_interface(); }







515   bool is_abstract() const { return _access_flags.is_abstract(); }
516 
517   // Returns true if the Klass to be generated will need to be addressable
518   // with a narrow Klass ID.
519   bool klass_needs_narrow_id() const;
520 
521   ClassLoaderData* loader_data() const { return _loader_data; }
522   const Symbol* class_name() const { return _class_name; }
523   const InstanceKlass* super_klass() const { return _super_klass; }
524 
525   ReferenceType super_reference_type() const;
526   bool is_instance_ref_klass() const;
527   bool is_java_lang_ref_Reference_subclass() const;
528 
529   AccessFlags access_flags() const { return _access_flags; }
530 
531   bool is_internal() const { return INTERNAL == _pub_level; }
532 


533   static bool verify_unqualified_name(const char* name, unsigned int length, int type);
534 
535 #ifdef ASSERT
536   static bool is_internal_format(Symbol* class_name);
537 #endif
538 
539 };
540 
541 #endif // SHARE_CLASSFILE_CLASSFILEPARSER_HPP

 57   unsigned int _nonstatic_oop_map_count;
 58   unsigned int _max_nonstatic_oop_maps;
 59 
 60   OopMapBlocksBuilder(unsigned int  max_blocks);
 61   OopMapBlock* last_oop_map() const;
 62   void initialize_inherited_blocks(OopMapBlock* blocks, unsigned int nof_blocks);
 63   void add(int offset, int count);
 64   void copy(OopMapBlock* dst);
 65   void compact();
 66   void print_on(outputStream* st) const;
 67   void print_value_on(outputStream* st) const;
 68 };
 69 
 70 // Values needed for oopmap and InstanceKlass creation
 71 class FieldLayoutInfo : public ResourceObj {
 72  public:
 73   OopMapBlocksBuilder* oop_map_blocks;
 74   int _instance_size;
 75   int _nonstatic_field_size;
 76   int _static_field_size;
 77   int _payload_alignment;
 78   int _payload_offset;
 79   int _payload_size_in_bytes;
 80   int _non_atomic_size_in_bytes;
 81   int _non_atomic_alignment;
 82   int _atomic_layout_size_in_bytes;
 83   int _nullable_layout_size_in_bytes;
 84   int _null_marker_offset;
 85   int _null_reset_value_offset;
 86   bool _has_nonstatic_fields;
 87   bool _is_naturally_atomic;
 88   bool _must_be_atomic;
 89   bool _has_inline_fields;
 90   bool _is_empty_inline_klass;
 91 };
 92 
 93 // Parser for for .class files
 94 //
 95 // The bytes describing the class file structure is read from a Stream object
 96 
 97 class ClassFileParser {
 98   friend class FieldLayoutBuilder;
 99   friend class FieldLayout;
100 
101   class ClassAnnotationCollector;
102   class FieldAnnotationCollector;
103 
104  public:
105   // The ClassFileParser has an associated "publicity" level
106   // It is used to control which subsystems (if any)
107   // will observe the parsing (logging, events, tracing).
108   // Default level is "BROADCAST", which is equivalent to
109   // a "public" parsing attempt.
110   //

125   const ClassFileStream* _stream; // Actual input stream
126   Symbol* _class_name;
127   mutable ClassLoaderData* _loader_data;
128   const bool _is_hidden;
129   const bool _can_access_vm_annotations;
130   int _orig_cp_size;
131   unsigned int _static_oop_count;
132 
133   // Metadata created before the instance klass is created.  Must be deallocated
134   // if not transferred to the InstanceKlass upon successful class loading
135   // in which case these pointers have been set to null.
136   const InstanceKlass* _super_klass;
137   ConstantPool* _cp;
138   Array<u1>* _fieldinfo_stream;
139   Array<FieldStatus>* _fields_status;
140   Array<Method*>* _methods;
141   Array<u2>* _inner_classes;
142   Array<u2>* _nest_members;
143   u2 _nest_host;
144   Array<u2>* _permitted_subclasses;
145   Array<u2>* _loadable_descriptors;
146   Array<RecordComponent*>* _record_components;
147   Array<InstanceKlass*>* _local_interfaces;
148   GrowableArray<u2>* _local_interface_indexes;
149   Array<InstanceKlass*>* _transitive_interfaces;
150   Annotations* _combined_annotations;
151   AnnotationArray* _class_annotations;
152   AnnotationArray* _class_type_annotations;
153   Array<AnnotationArray*>* _fields_annotations;
154   Array<AnnotationArray*>* _fields_type_annotations;
155   InstanceKlass* _klass;  // InstanceKlass* once created.
156   InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
157 
158   ClassAnnotationCollector* _parsed_annotations;
159   FieldLayoutInfo* _layout_info;
160   Array<InlineLayoutInfo>* _inline_layout_info_array;
161   GrowableArray<FieldInfo>* _temp_field_info;
162   const intArray* _method_ordering;
163   GrowableArray<Method*>* _all_mirandas;
164 
165   enum { fixed_buffer_size = 128 };
166   u_char _linenumbertable_buffer[fixed_buffer_size];
167 
168   // Size of Java vtable (in words)
169   int _vtable_size;
170   int _itable_size;
171 
172   int _num_miranda_methods;
173 
174 
175   Handle _protection_domain;
176   AccessFlags _access_flags;
177 
178   // for tracing and notifications
179   Publicity _pub_level;
180 
181   // Used to keep track of whether a constant pool item 19 or 20 is found.  These
182   // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
183   // in regular class files.  For class file version >= 53, a CFE cannot be thrown
184   // immediately when these are seen because a NCDFE must be thrown if the class's
185   // access_flags have ACC_MODULE set.  But, the access_flags haven't been looked
186   // at yet.  So, the bad constant pool item is cached here.  A value of zero
187   // means that no constant pool item 19 or 20 was found.
188   short _bad_constant_seen;
189 
190   // class attributes parsed before the instance klass is created:
191   bool _synthetic_flag;
192   int _sde_length;
193   const char* _sde_buffer;
194   u2 _sourcefile_index;
195   u2 _generic_signature_index;
196 
197   u2 _major_version;
198   u2 _minor_version;
199   u2 _this_class_index;
200   u2 _super_class_index;
201   u2 _itfs_len;
202   u2 _java_fields_count;
203 
204   bool _need_verify;
205 
206   bool _has_nonstatic_concrete_methods;
207   bool _declares_nonstatic_concrete_methods;
208   bool _has_localvariable_table;
209   bool _has_final_method;
210   bool _has_contended_fields;
211 
212   bool _has_inline_type_fields;
213   bool _is_naturally_atomic;
214   bool _must_be_atomic;
215   bool _has_loosely_consistent_annotation;
216 
217   // precomputed flags
218   bool _has_finalizer;
219   bool _has_empty_finalizer;
220   int _max_bootstrap_specifier_index;  // detects BSS values
221 
222   void parse_stream(const ClassFileStream* const stream, TRAPS);
223 
224   void mangle_hidden_class_name(InstanceKlass* const ik);
225 
226   void post_process_parsed_stream(const ClassFileStream* const stream,
227                                   ConstantPool* cp,
228                                   TRAPS);
229 
230   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH,
231                            const ClassInstanceInfo& cl_inst_info, TRAPS);
232 
233   void set_klass(InstanceKlass* instance);
234 
235   void set_class_bad_constant_seen(short bad_constant);
236   short class_bad_constant_seen() { return  _bad_constant_seen; }

262                         bool* has_nonstatic_concrete_methods,
263                         TRAPS);
264 
265   const InstanceKlass* parse_super_class(ConstantPool* const cp,
266                                          const int super_class_index,
267                                          const bool need_verify,
268                                          TRAPS);
269 
270   // Field parsing
271   void parse_field_attributes(const ClassFileStream* const cfs,
272                               u2 attributes_count,
273                               bool is_static,
274                               u2 signature_index,
275                               u2* const constantvalue_index_addr,
276                               bool* const is_synthetic_addr,
277                               u2* const generic_signature_index_addr,
278                               FieldAnnotationCollector* parsed_annotations,
279                               TRAPS);
280 
281   void parse_fields(const ClassFileStream* const cfs,
282                     AccessFlags class_access_flags,
283                     ConstantPool* cp,
284                     const int cp_size,
285                     u2* const java_fields_count_ptr,
286                     TRAPS);
287 
288   // Method parsing
289   Method* parse_method(const ClassFileStream* const cfs,
290                        bool is_interface,
291                        bool is_value_class,
292                        bool is_abstract_class,
293                        const ConstantPool* cp,
294                        bool* const has_localvariable_table,
295                        TRAPS);
296 
297   void parse_methods(const ClassFileStream* const cfs,
298                      bool is_interface,
299                      bool is_value_class,
300                      bool is_abstract_class,
301                      bool* const has_localvariable_table,
302                      bool* const has_final_method,
303                      bool* const declares_nonstatic_concrete_methods,
304                      TRAPS);
305 
306   const unsafe_u2* parse_exception_table(const ClassFileStream* const stream,
307                                          u4 code_length,
308                                          u4 exception_table_length,
309                                          TRAPS);
310 
311   void parse_linenumber_table(u4 code_attribute_length,
312                               u4 code_length,
313                               CompressedLineNumberWriteStream**const write_stream,
314                               TRAPS);
315 
316   const unsafe_u2* parse_localvariable_table(const ClassFileStream* const cfs,
317                                              u4 code_length,
318                                              u2 max_locals,
319                                              u4 code_attribute_length,
320                                              u2* const localvariable_table_length,

335 
336   // Check for circularity in InnerClasses attribute.
337   bool check_inner_classes_circularity(const ConstantPool* cp, int length, TRAPS);
338 
339   u2   parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs,
340                                                const ConstantPool* cp,
341                                                const u1* const inner_classes_attribute_start,
342                                                bool parsed_enclosingmethod_attribute,
343                                                u2 enclosing_method_class_index,
344                                                u2 enclosing_method_method_index,
345                                                TRAPS);
346 
347   u2 parse_classfile_nest_members_attribute(const ClassFileStream* const cfs,
348                                             const u1* const nest_members_attribute_start,
349                                             TRAPS);
350 
351   u2 parse_classfile_permitted_subclasses_attribute(const ClassFileStream* const cfs,
352                                                     const u1* const permitted_subclasses_attribute_start,
353                                                     TRAPS);
354 
355   u2 parse_classfile_loadable_descriptors_attribute(const ClassFileStream* const cfs,
356                                                     const u1* const loadable_descriptors_attribute_start,
357                                                     TRAPS);
358 
359   u4 parse_classfile_record_attribute(const ClassFileStream* const cfs,
360                                       const ConstantPool* cp,
361                                       const u1* const record_attribute_start,
362                                       TRAPS);
363 
364   void parse_classfile_attributes(const ClassFileStream* const cfs,
365                                   ConstantPool* cp,
366                                   ClassAnnotationCollector* parsed_annotations,
367                                   TRAPS);
368 
369   void parse_classfile_synthetic_attribute();
370   void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
371   void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
372                                                    ConstantPool* cp,
373                                                    u4 attribute_length,
374                                                    TRAPS);
375 
376   // Annotations handling
377   AnnotationArray* allocate_annotations(const u1* const anno,
378                                         int anno_length,

431                                  const char *name,
432                                  TRAPS) const {
433     if (!b) { classfile_parse_error(msg, index, name, THREAD); return; }
434   }
435 
436   void throwIllegalSignature(const char* type,
437                              const Symbol* name,
438                              const Symbol* sig,
439                              TRAPS) const;
440 
441   void verify_constantvalue(const ConstantPool* const cp,
442                             int constantvalue_index,
443                             int signature_index,
444                             TRAPS) const;
445 
446   void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const;
447   void verify_legal_class_name(const Symbol* name, TRAPS) const;
448   void verify_legal_field_name(const Symbol* name, TRAPS) const;
449   void verify_legal_method_name(const Symbol* name, TRAPS) const;
450 
451   bool legal_field_signature(const Symbol* signature, TRAPS) const;
452 
453   void verify_legal_field_signature(const Symbol* fieldname,
454                                     const Symbol* signature,
455                                     TRAPS) const;
456   int  verify_legal_method_signature(const Symbol* methodname,
457                                      const Symbol* signature,
458                                      TRAPS) const;
459   void verify_legal_name_with_signature(const Symbol* name,
460                                         const Symbol* signature,
461                                         TRAPS) const;
462 
463   void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS);
464 
465   void verify_legal_class_modifiers(jint flags, const char* name, bool is_Object, TRAPS) const;
466   void verify_legal_field_modifiers(jint flags,
467                                     AccessFlags class_access_flags,
468                                     TRAPS) const;
469   void verify_legal_method_modifiers(jint flags,
470                                      AccessFlags class_access_flags,
471                                      const Symbol* name,
472                                      TRAPS) const;
473 
474   void check_super_class_access(const InstanceKlass* this_klass,
475                                 TRAPS);
476 
477   void check_super_interface_access(const InstanceKlass* this_klass,
478                                     TRAPS);
479 
480   const char* skip_over_field_signature(const char* signature,
481                                         bool void_ok,
482                                         unsigned int length,
483                                         TRAPS) const;
484 
485   // Wrapper for constantTag.is_klass_[or_]reference.
486   // In older versions of the VM, Klass*s cannot sneak into early phases of
487   // constant pool construction, but in later versions they can.
488   // %%% Let's phase out the old is_klass_reference.
489   bool valid_klass_reference_at(int index) const {
490     return _cp->is_within_bounds(index) &&

502                                 u2* const localvariable_table_length,
503                                 const unsafe_u2** const localvariable_table_start,
504                                 int lvtt_cnt,
505                                 u2* const localvariable_type_table_length,
506                                 const unsafe_u2** const localvariable_type_table_start,
507                                 TRAPS);
508 
509   void copy_method_annotations(ConstMethod* cm,
510                                const u1* runtime_visible_annotations,
511                                int runtime_visible_annotations_length,
512                                const u1* runtime_visible_parameter_annotations,
513                                int runtime_visible_parameter_annotations_length,
514                                const u1* runtime_visible_type_annotations,
515                                int runtime_visible_type_annotations_length,
516                                const u1* annotation_default,
517                                int annotation_default_length,
518                                TRAPS);
519 
520   void update_class_name(Symbol* new_name);
521 
522   // Check if the class file supports inline types
523   bool supports_inline_types() const;
524 
525  public:
526   ClassFileParser(ClassFileStream* stream,
527                   Symbol* name,
528                   ClassLoaderData* loader_data,
529                   const ClassLoadInfo* cl_info,
530                   Publicity pub_level,
531                   TRAPS);
532 
533   ~ClassFileParser();
534 
535   InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, const ClassInstanceInfo& cl_inst_info, TRAPS);
536 
537   const ClassFileStream* clone_stream() const;
538 
539   void set_klass_to_deallocate(InstanceKlass* klass);
540 
541   int static_field_size() const;
542   int total_oop_map_count() const;
543   jint layout_size() const;
544 
545   int vtable_size() const { return _vtable_size; }
546   int itable_size() const { return _itable_size; }
547 
548   u2 this_class_index() const { return _this_class_index; }
549 
550   bool is_hidden() const { return _is_hidden; }
551   bool is_interface() const { return _access_flags.is_interface(); }
552   // Being an inline type means being a concrete value class
553   bool is_inline_type() const { return !_access_flags.is_identity_class() && !_access_flags.is_interface() && !_access_flags.is_abstract(); }
554   bool is_abstract_class() const { return _access_flags.is_abstract(); }
555   bool is_identity_class() const { return _access_flags.is_identity_class(); }
556   bool has_inline_fields() const { return _has_inline_type_fields; }
557 
558   u2 java_fields_count() const { return _java_fields_count; }
559   bool is_abstract() const { return _access_flags.is_abstract(); }
560 
561   // Returns true if the Klass to be generated will need to be addressable
562   // with a narrow Klass ID.
563   bool klass_needs_narrow_id() const;
564 
565   ClassLoaderData* loader_data() const { return _loader_data; }
566   const Symbol* class_name() const { return _class_name; }
567   const InstanceKlass* super_klass() const { return _super_klass; }
568 
569   ReferenceType super_reference_type() const;
570   bool is_instance_ref_klass() const;
571   bool is_java_lang_ref_Reference_subclass() const;
572 
573   AccessFlags access_flags() const { return _access_flags; }
574 
575   bool is_internal() const { return INTERNAL == _pub_level; }
576 
577   bool is_class_in_loadable_descriptors_attribute(Symbol *klass);
578 
579   static bool verify_unqualified_name(const char* name, unsigned int length, int type);
580 
581 #ifdef ASSERT
582   static bool is_internal_format(Symbol* class_name);
583 #endif
584 
585 };
586 
587 #endif // SHARE_CLASSFILE_CLASSFILEPARSER_HPP
< prev index next >