< prev index next >

src/hotspot/share/classfile/classFileParser.hpp

Print this page

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


 77 };
 78 
 79 // Parser for for .class files
 80 //
 81 // The bytes describing the class file structure is read from a Stream object
 82 
 83 class ClassFileParser {
 84   friend class FieldLayoutBuilder;
 85   friend class FieldLayout;
 86 
 87   class ClassAnnotationCollector;
 88   class FieldAllocationCount;
 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.

110   typedef void unsafe_u2;
111 
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 
119   // Metadata created before the instance klass is created.  Must be deallocated
120   // if not transferred to the InstanceKlass upon successful class loading
121   // in which case these pointers have been set to NULL.
122   const InstanceKlass* _super_klass;
123   ConstantPool* _cp;
124   Array<u2>* _fields;
125   Array<Method*>* _methods;
126   Array<u2>* _inner_classes;
127   Array<u2>* _nest_members;
128   u2 _nest_host;
129   Array<u2>* _permitted_subclasses;

130   Array<RecordComponent*>* _record_components;
131   Array<InstanceKlass*>* _local_interfaces;

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

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




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








194   // precomputed flags
195   bool _has_finalizer;
196   bool _has_empty_finalizer;
197   bool _has_vanilla_constructor;
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);

221   void apply_parsed_class_attributes(InstanceKlass* k);  // update k
222   void apply_parsed_class_metadata(InstanceKlass* k, int fields_count);
223   void clear_class_metadata();
224 
225   // Constant pool parsing
226   void parse_constant_pool_entries(const ClassFileStream* const stream,
227                                    ConstantPool* cp,
228                                    const int length,
229                                    TRAPS);
230 
231   void parse_constant_pool(const ClassFileStream* const cfs,
232                            ConstantPool* const cp,
233                            const int length,
234                            TRAPS);
235 
236   // Interface parsing
237   void parse_interfaces(const ClassFileStream* const stream,
238                         const int itfs_len,
239                         ConstantPool* const cp,
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                     FieldAllocationCount* const fac,
262                     ConstantPool* cp,
263                     const int cp_size,
264                     u2* const java_fields_count_ptr,
265                     TRAPS);
266 
267   // Method parsing
268   Method* parse_method(const ClassFileStream* const cfs,
269                        bool is_interface,


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


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

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




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

428   inline void guarantee_property(bool b,
429                                  const char* msg,
430                                  const char *name,
431                                  TRAPS) const {
432     if (!b) { classfile_parse_error(msg, name, THREAD); return; }
433   }
434 
435   inline void guarantee_property(bool b,
436                                  const char* msg,
437                                  int index,
438                                  const char *name,
439                                  TRAPS) const {
440     if (!b) { classfile_parse_error(msg, index, name, THREAD); return; }
441   }
442 
443   void throwIllegalSignature(const char* type,
444                              const Symbol* name,
445                              const Symbol* sig,
446                              TRAPS) const;
447 





448   void verify_constantvalue(const ConstantPool* const cp,
449                             int constantvalue_index,
450                             int signature_index,
451                             TRAPS) const;
452 
453   void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const;
454   void verify_legal_class_name(const Symbol* name, TRAPS) const;
455   void verify_legal_field_name(const Symbol* name, TRAPS) const;
456   void verify_legal_method_name(const Symbol* name, TRAPS) const;
457 
458   void verify_legal_field_signature(const Symbol* fieldname,
459                                     const Symbol* signature,
460                                     TRAPS) const;
461   int  verify_legal_method_signature(const Symbol* methodname,
462                                      const Symbol* signature,
463                                      TRAPS) const;
464   void verify_legal_name_with_signature(const Symbol* name,
465                                         const Symbol* signature,
466                                         TRAPS) const;
467 
468   void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS);
469 
470   void verify_legal_class_modifiers(jint flags, TRAPS) const;
471   void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS) const;


472   void verify_legal_method_modifiers(jint flags,
473                                      bool is_interface,
474                                      const Symbol* name,
475                                      TRAPS) const;
476 
477   void check_super_class_access(const InstanceKlass* this_klass,
478                                 TRAPS);
479 
480   void check_super_interface_access(const InstanceKlass* this_klass,
481                                     TRAPS);
482 
483   const char* skip_over_field_signature(const char* signature,
484                                         bool void_ok,
485                                         unsigned int length,
486                                         TRAPS) const;
487 
488   // Wrapper for constantTag.is_klass_[or_]reference.
489   // In older versions of the VM, Klass*s cannot sneak into early phases of
490   // constant pool construction, but in later versions they can.
491   // %%% Let's phase out the old is_klass_reference.
492   bool valid_klass_reference_at(int index) const {
493     return _cp->is_within_bounds(index) &&

511 
512   void copy_method_annotations(ConstMethod* cm,
513                                const u1* runtime_visible_annotations,
514                                int runtime_visible_annotations_length,
515                                const u1* runtime_invisible_annotations,
516                                int runtime_invisible_annotations_length,
517                                const u1* runtime_visible_parameter_annotations,
518                                int runtime_visible_parameter_annotations_length,
519                                const u1* runtime_invisible_parameter_annotations,
520                                int runtime_invisible_parameter_annotations_length,
521                                const u1* runtime_visible_type_annotations,
522                                int runtime_visible_type_annotations_length,
523                                const u1* runtime_invisible_type_annotations,
524                                int runtime_invisible_type_annotations_length,
525                                const u1* annotation_default,
526                                int annotation_default_length,
527                                TRAPS);
528 
529   void update_class_name(Symbol* new_name);
530 



531  public:
532   ClassFileParser(ClassFileStream* stream,
533                   Symbol* name,
534                   ClassLoaderData* loader_data,
535                   const ClassLoadInfo* cl_info,
536                   Publicity pub_level,
537                   TRAPS);
538 
539   ~ClassFileParser();
540 
541   InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, const ClassInstanceInfo& cl_inst_info, TRAPS);
542 
543   const ClassFileStream* clone_stream() const;
544 
545   void set_klass_to_deallocate(InstanceKlass* klass);
546 
547   int static_field_size() const;
548   int total_oop_map_count() const;
549   jint layout_size() const;
550 
551   int vtable_size() const { return _vtable_size; }
552   int itable_size() const { return _itable_size; }
553 
554   u2 this_class_index() const { return _this_class_index; }
555 
556   bool is_hidden() const { return _is_hidden; }
557   bool is_interface() const { return _access_flags.is_interface(); }












558 
559   ClassLoaderData* loader_data() const { return _loader_data; }
560   const Symbol* class_name() const { return _class_name; }
561   const InstanceKlass* super_klass() const { return _super_klass; }
562 
563   ReferenceType super_reference_type() const;
564   bool is_instance_ref_klass() const;
565   bool is_java_lang_ref_Reference_subclass() const;
566 
567   AccessFlags access_flags() const { return _access_flags; }
568 
569   bool is_internal() const { return INTERNAL == _pub_level; }
570 
571   static bool verify_unqualified_name(const char* name, unsigned int length, int type);
572 
573 #ifdef ASSERT
574   static bool is_internal_format(Symbol* class_name);
575 #endif
576 
577 };

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

112   typedef void unsafe_u2;
113 
114   const ClassFileStream* _stream; // Actual input stream
115   Symbol* _class_name;
116   mutable ClassLoaderData* _loader_data;
117   const bool _is_hidden;
118   const bool _can_access_vm_annotations;
119   int _orig_cp_size;
120 
121   // Metadata created before the instance klass is created.  Must be deallocated
122   // if not transferred to the InstanceKlass upon successful class loading
123   // in which case these pointers have been set to NULL.
124   const InstanceKlass* _super_klass;
125   ConstantPool* _cp;
126   Array<u2>* _fields;
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<u2>* _preload_classes;
133   Array<RecordComponent*>* _record_components;
134   Array<InstanceKlass*>* _local_interfaces;
135   GrowableArray<u2>* _local_interface_indexes;
136   Array<InstanceKlass*>* _transitive_interfaces;
137   Annotations* _combined_annotations;
138   AnnotationArray* _class_annotations;
139   AnnotationArray* _class_type_annotations;
140   Array<AnnotationArray*>* _fields_annotations;
141   Array<AnnotationArray*>* _fields_type_annotations;
142   InstanceKlass* _klass;  // InstanceKlass* once created.
143   InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
144 
145   ClassAnnotationCollector* _parsed_annotations;
146   FieldAllocationCount* _fac;
147   FieldLayoutInfo* _field_info;
148   Array<InlineKlass*>* _inline_type_field_klasses;
149   const intArray* _method_ordering;
150   GrowableArray<Method*>* _all_mirandas;
151 
152   enum { fixed_buffer_size = 128 };
153   u_char _linenumbertable_buffer[fixed_buffer_size];
154 
155   // Size of Java vtable (in words)
156   int _vtable_size;
157   int _itable_size;
158 
159   int _num_miranda_methods;
160 
161   int _alignment;
162   int _first_field_offset;
163   int _exact_size_in_bytes;
164 
165   Handle _protection_domain;
166   AccessFlags _access_flags;
167 
168   // for tracing and notifications
169   Publicity _pub_level;
170 
171   // Used to keep track of whether a constant pool item 19 or 20 is found.  These
172   // correspond to CONSTANT_Module and CONSTANT_Package tags and are not allowed
173   // in regular class files.  For class file version >= 53, a CFE cannot be thrown
174   // immediately when these are seen because a NCDFE must be thrown if the class's
175   // access_flags have ACC_MODULE set.  But, the access_flags haven't been looked
176   // at yet.  So, the bad constant pool item is cached here.  A value of zero
177   // means that no constant pool item 19 or 20 was found.
178   short _bad_constant_seen;
179 
180   // class attributes parsed before the instance klass is created:
181   bool _synthetic_flag;
182   int _sde_length;
183   const char* _sde_buffer;
184   u2 _sourcefile_index;
185   u2 _generic_signature_index;
186 
187   u2 _major_version;
188   u2 _minor_version;
189   u2 _this_class_index;
190   u2 _super_class_index;
191   u2 _itfs_len;
192   u2 _java_fields_count;
193 
194   bool _need_verify;
195   bool _relax_verify;
196 
197   bool _has_nonstatic_concrete_methods;
198   bool _declares_nonstatic_concrete_methods;
199   bool _has_localvariable_table;
200   bool _has_final_method;
201   bool _has_contended_fields;
202 
203   bool _has_inline_type_fields;
204   bool _has_nonstatic_fields;
205   bool _is_empty_inline_type;
206   bool _is_naturally_atomic;
207   bool _is_declared_atomic;
208   bool _carries_value_modifier;      // Has ACC_VALUE mddifier or one of its super types has
209   bool _carries_identity_modifier;   // Has ACC_IDENTITY modifier or one of its super types has
210 
211   // precomputed flags
212   bool _has_finalizer;
213   bool _has_empty_finalizer;
214   bool _has_vanilla_constructor;
215   int _max_bootstrap_specifier_index;  // detects BSS values
216 
217   void parse_stream(const ClassFileStream* const stream, TRAPS);
218 
219   void mangle_hidden_class_name(InstanceKlass* const ik);
220 
221   void post_process_parsed_stream(const ClassFileStream* const stream,
222                                   ConstantPool* cp,
223                                   TRAPS);
224 
225   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH,
226                            const ClassInstanceInfo& cl_inst_info, TRAPS);
227 
228   void set_klass(InstanceKlass* instance);
229 
230   void set_class_bad_constant_seen(short bad_constant);

238   void apply_parsed_class_attributes(InstanceKlass* k);  // update k
239   void apply_parsed_class_metadata(InstanceKlass* k, int fields_count);
240   void clear_class_metadata();
241 
242   // Constant pool parsing
243   void parse_constant_pool_entries(const ClassFileStream* const stream,
244                                    ConstantPool* cp,
245                                    const int length,
246                                    TRAPS);
247 
248   void parse_constant_pool(const ClassFileStream* const cfs,
249                            ConstantPool* const cp,
250                            const int length,
251                            TRAPS);
252 
253   // Interface parsing
254   void parse_interfaces(const ClassFileStream* const stream,
255                         const int itfs_len,
256                         ConstantPool* const cp,
257                         bool* has_nonstatic_concrete_methods,
258                         bool* is_declared_atomic,
259                         TRAPS);
260 
261   const InstanceKlass* parse_super_class(ConstantPool* const cp,
262                                          const int super_class_index,
263                                          const bool need_verify,
264                                          TRAPS);
265 
266   // Field parsing
267   void parse_field_attributes(const ClassFileStream* const cfs,
268                               u2 attributes_count,
269                               bool is_static,
270                               u2 signature_index,
271                               u2* const constantvalue_index_addr,
272                               bool* const is_synthetic_addr,
273                               u2* const generic_signature_index_addr,
274                               FieldAnnotationCollector* parsed_annotations,
275                               TRAPS);
276 
277   void parse_fields(const ClassFileStream* const cfs,
278                     AccessFlags class_access_flags,
279                     FieldAllocationCount* const fac,
280                     ConstantPool* cp,
281                     const int cp_size,
282                     u2* const java_fields_count_ptr,
283                     TRAPS);
284 
285   // Method parsing
286   Method* parse_method(const ClassFileStream* const cfs,
287                        bool is_interface,
288                        bool is_value_class,
289                        bool is_abstract_class,
290                        const ConstantPool* cp,
291                        bool* const has_localvariable_table,
292                        TRAPS);
293 
294   void parse_methods(const ClassFileStream* const cfs,
295                      bool is_interface,
296                      bool is_value_class,
297                      bool is_abstract_class,
298                      bool* const has_localvariable_table,
299                      bool* const has_final_method,
300                      bool* const declares_nonstatic_concrete_methods,
301                      TRAPS);
302 
303   const unsafe_u2* parse_exception_table(const ClassFileStream* const stream,
304                                          u4 code_length,
305                                          u4 exception_table_length,
306                                          TRAPS);
307 
308   void parse_linenumber_table(u4 code_attribute_length,
309                               u4 code_length,
310                               CompressedLineNumberWriteStream**const write_stream,
311                               TRAPS);
312 
313   const unsafe_u2* parse_localvariable_table(const ClassFileStream* const cfs,
314                                              u4 code_length,
315                                              u2 max_locals,
316                                              u4 code_attribute_length,
317                                              u2* const localvariable_table_length,

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

454   inline void guarantee_property(bool b,
455                                  const char* msg,
456                                  const char *name,
457                                  TRAPS) const {
458     if (!b) { classfile_parse_error(msg, name, THREAD); return; }
459   }
460 
461   inline void guarantee_property(bool b,
462                                  const char* msg,
463                                  int index,
464                                  const char *name,
465                                  TRAPS) const {
466     if (!b) { classfile_parse_error(msg, index, name, THREAD); return; }
467   }
468 
469   void throwIllegalSignature(const char* type,
470                              const Symbol* name,
471                              const Symbol* sig,
472                              TRAPS) const;
473 
474   void throwInlineTypeLimitation(THREAD_AND_LOCATION_DECL,
475                                  const char* msg,
476                                  const Symbol* name = NULL,
477                                  const Symbol* sig  = NULL) const;
478 
479   void verify_constantvalue(const ConstantPool* const cp,
480                             int constantvalue_index,
481                             int signature_index,
482                             TRAPS) const;
483 
484   void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS) const;
485   void verify_legal_class_name(const Symbol* name, TRAPS) const;
486   void verify_legal_field_name(const Symbol* name, TRAPS) const;
487   void verify_legal_method_name(const Symbol* name, TRAPS) const;
488 
489   void verify_legal_field_signature(const Symbol* fieldname,
490                                     const Symbol* signature,
491                                     TRAPS) const;
492   int  verify_legal_method_signature(const Symbol* methodname,
493                                      const Symbol* signature,
494                                      TRAPS) const;
495   void verify_legal_name_with_signature(const Symbol* name,
496                                         const Symbol* signature,
497                                         TRAPS) const;
498 
499   void verify_class_version(u2 major, u2 minor, Symbol* class_name, TRAPS);
500 
501   void verify_legal_class_modifiers(jint flags, const char* name, bool is_Object, TRAPS) const;
502   void verify_legal_field_modifiers(jint flags,
503                                     AccessFlags class_access_flags,
504                                     TRAPS) const;
505   void verify_legal_method_modifiers(jint flags,
506                                      AccessFlags class_access_flags,
507                                      const Symbol* name,
508                                      TRAPS) const;
509 
510   void check_super_class_access(const InstanceKlass* this_klass,
511                                 TRAPS);
512 
513   void check_super_interface_access(const InstanceKlass* this_klass,
514                                     TRAPS);
515 
516   const char* skip_over_field_signature(const char* signature,
517                                         bool void_ok,
518                                         unsigned int length,
519                                         TRAPS) const;
520 
521   // Wrapper for constantTag.is_klass_[or_]reference.
522   // In older versions of the VM, Klass*s cannot sneak into early phases of
523   // constant pool construction, but in later versions they can.
524   // %%% Let's phase out the old is_klass_reference.
525   bool valid_klass_reference_at(int index) const {
526     return _cp->is_within_bounds(index) &&

544 
545   void copy_method_annotations(ConstMethod* cm,
546                                const u1* runtime_visible_annotations,
547                                int runtime_visible_annotations_length,
548                                const u1* runtime_invisible_annotations,
549                                int runtime_invisible_annotations_length,
550                                const u1* runtime_visible_parameter_annotations,
551                                int runtime_visible_parameter_annotations_length,
552                                const u1* runtime_invisible_parameter_annotations,
553                                int runtime_invisible_parameter_annotations_length,
554                                const u1* runtime_visible_type_annotations,
555                                int runtime_visible_type_annotations_length,
556                                const u1* runtime_invisible_type_annotations,
557                                int runtime_invisible_type_annotations_length,
558                                const u1* annotation_default,
559                                int annotation_default_length,
560                                TRAPS);
561 
562   void update_class_name(Symbol* new_name);
563 
564   // Check if the class file supports inline types
565   bool supports_inline_types() const;
566 
567  public:
568   ClassFileParser(ClassFileStream* stream,
569                   Symbol* name,
570                   ClassLoaderData* loader_data,
571                   const ClassLoadInfo* cl_info,
572                   Publicity pub_level,
573                   TRAPS);
574 
575   ~ClassFileParser();
576 
577   InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, const ClassInstanceInfo& cl_inst_info, TRAPS);
578 
579   const ClassFileStream* clone_stream() const;
580 
581   void set_klass_to_deallocate(InstanceKlass* klass);
582 
583   int static_field_size() const;
584   int total_oop_map_count() const;
585   jint layout_size() const;
586 
587   int vtable_size() const { return _vtable_size; }
588   int itable_size() const { return _itable_size; }
589 
590   u2 this_class_index() const { return _this_class_index; }
591 
592   bool is_hidden() const { return _is_hidden; }
593   bool is_interface() const { return _access_flags.is_interface(); }
594   bool is_inline_type() const { return _access_flags.is_value_class() && !_access_flags.is_interface() && !_access_flags.is_abstract(); }
595   bool is_value_class() const { return _access_flags.is_value_class(); }
596   bool is_abstract_class() const { return _access_flags.is_abstract(); }
597   bool is_identity_class() const { return _access_flags.is_identity_class(); }
598   bool is_value_capable_class() const;
599   bool has_inline_fields() const { return _has_inline_type_fields; }
600   bool carries_identity_modifier() const { return _carries_identity_modifier; }
601   void set_carries_identity_modifier() { _carries_identity_modifier = true; }
602   bool carries_value_modifier() const { return _carries_value_modifier; }
603   void set_carries_value_modifier() { _carries_value_modifier = true; }
604 
605   u2 java_fields_count() const { return _java_fields_count; }
606 
607   ClassLoaderData* loader_data() const { return _loader_data; }
608   const Symbol* class_name() const { return _class_name; }
609   const InstanceKlass* super_klass() const { return _super_klass; }
610 
611   ReferenceType super_reference_type() const;
612   bool is_instance_ref_klass() const;
613   bool is_java_lang_ref_Reference_subclass() const;
614 
615   AccessFlags access_flags() const { return _access_flags; }
616 
617   bool is_internal() const { return INTERNAL == _pub_level; }
618 
619   static bool verify_unqualified_name(const char* name, unsigned int length, int type);
620 
621 #ifdef ASSERT
622   static bool is_internal_format(Symbol* class_name);
623 #endif
624 
625 };
< prev index next >