< 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_final_method;
191   bool _has_contended_fields;
192 








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

220   void apply_parsed_class_attributes(InstanceKlass* k);  // update k
221   void apply_parsed_class_metadata(InstanceKlass* k, int fields_count);
222   void clear_class_metadata();
223 
224   // Constant pool parsing
225   void parse_constant_pool_entries(const ClassFileStream* const stream,
226                                    ConstantPool* cp,
227                                    const int length,
228                                    TRAPS);
229 
230   void parse_constant_pool(const ClassFileStream* const cfs,
231                            ConstantPool* const cp,
232                            const int length,
233                            TRAPS);
234 
235   // Interface parsing
236   void parse_interfaces(const ClassFileStream* const stream,
237                         const int itfs_len,
238                         ConstantPool* const cp,
239                         bool* has_nonstatic_concrete_methods,

240                         TRAPS);
241 
242   const InstanceKlass* parse_super_class(ConstantPool* const cp,
243                                          const int super_class_index,
244                                          const bool need_verify,
245                                          TRAPS);
246 
247   // Field parsing
248   void parse_field_attributes(const ClassFileStream* const cfs,
249                               u2 attributes_count,
250                               bool is_static,
251                               u2 signature_index,
252                               u2* const constantvalue_index_addr,
253                               bool* const is_synthetic_addr,
254                               u2* const generic_signature_index_addr,
255                               FieldAnnotationCollector* parsed_annotations,
256                               TRAPS);
257 
258   void parse_fields(const ClassFileStream* const cfs,
259                     bool is_interface,
260                     FieldAllocationCount* const fac,
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                        AccessFlags* const promoted_flags,
271                        TRAPS);
272 
273   void parse_methods(const ClassFileStream* const cfs,
274                      bool is_interface,


275                      AccessFlags* const promoted_flags,
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   u2 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* assemble_annotations(const u1* const runtime_visible_annotations,
348                                         int runtime_visible_annotations_length,

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





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


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

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



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












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

 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_final_method;
200   bool _has_contended_fields;
201 
202   bool _has_inline_type_fields;
203   bool _has_nonstatic_fields;
204   bool _is_empty_inline_type;
205   bool _is_naturally_atomic;
206   bool _is_declared_atomic;
207   bool _carries_value_modifier;      // Has ACC_VALUE mddifier or one of its super types has
208   bool _carries_identity_modifier;   // Has ACC_IDENTITY modifier or one of its super types has
209 
210   // precomputed flags
211   bool _has_finalizer;
212   bool _has_empty_finalizer;
213   bool _has_vanilla_constructor;
214   int _max_bootstrap_specifier_index;  // detects BSS values
215 
216   void parse_stream(const ClassFileStream* const stream, TRAPS);
217 
218   void mangle_hidden_class_name(InstanceKlass* const ik);
219 
220   void post_process_parsed_stream(const ClassFileStream* const stream,
221                                   ConstantPool* cp,
222                                   TRAPS);
223 
224   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH,
225                            const ClassInstanceInfo& cl_inst_info, TRAPS);
226 
227   void set_klass(InstanceKlass* instance);
228 
229   void set_class_bad_constant_seen(short bad_constant);

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

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

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

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