< prev index next >

src/hotspot/share/classfile/classFileParser.hpp

Print this page




  81   const Symbol* _requested_name;
  82   Symbol* _class_name;
  83   mutable ClassLoaderData* _loader_data;
  84   const InstanceKlass* _unsafe_anonymous_host;
  85   GrowableArray<Handle>* _cp_patches; // overrides for CP entries
  86   int _num_patched_klasses;
  87   int _max_num_patched_klasses;
  88   int _orig_cp_size;
  89   int _first_patched_klass_resolved_index;
  90 
  91   // Metadata created before the instance klass is created.  Must be deallocated
  92   // if not transferred to the InstanceKlass upon successful class loading
  93   // in which case these pointers have been set to NULL.
  94   const InstanceKlass* _super_klass;
  95   ConstantPool* _cp;
  96   Array<u2>* _fields;
  97   Array<Method*>* _methods;
  98   Array<u2>* _inner_classes;
  99   Array<u2>* _nest_members;
 100   u2 _nest_host;


 101   Array<InstanceKlass*>* _local_interfaces;
 102   Array<InstanceKlass*>* _transitive_interfaces;
 103   Annotations* _combined_annotations;
 104   AnnotationArray* _annotations;
 105   AnnotationArray* _type_annotations;
 106   Array<AnnotationArray*>* _fields_annotations;
 107   Array<AnnotationArray*>* _fields_type_annotations;
 108   InstanceKlass* _klass;  // InstanceKlass* once created.
 109   InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
 110 
 111   ClassAnnotationCollector* _parsed_annotations;
 112   FieldAllocationCount* _fac;
 113   FieldLayoutInfo* _field_info;
 114   const intArray* _method_ordering;
 115   GrowableArray<Method*>* _all_mirandas;
 116 
 117   enum { fixed_buffer_size = 128 };
 118   u_char _linenumbertable_buffer[fixed_buffer_size];
 119 
 120   // Size of Java vtable (in words)


 135   // in regular class files.  For class file version >= 53, a CFE cannot be thrown
 136   // immediately when these are seen because a NCDFE must be thrown if the class's
 137   // access_flags have ACC_MODULE set.  But, the access_flags haven't been looked
 138   // at yet.  So, the bad constant pool item is cached here.  A value of zero
 139   // means that no constant pool item 19 or 20 was found.
 140   short _bad_constant_seen;
 141 
 142   // class attributes parsed before the instance klass is created:
 143   bool _synthetic_flag;
 144   int _sde_length;
 145   const char* _sde_buffer;
 146   u2 _sourcefile_index;
 147   u2 _generic_signature_index;
 148 
 149   u2 _major_version;
 150   u2 _minor_version;
 151   u2 _this_class_index;
 152   u2 _super_class_index;
 153   u2 _itfs_len;
 154   u2 _java_fields_count;

 155 
 156   bool _need_verify;
 157   bool _relax_verify;
 158 
 159   bool _has_nonstatic_concrete_methods;
 160   bool _declares_nonstatic_concrete_methods;
 161   bool _has_final_method;
 162 
 163   // precomputed flags
 164   bool _has_finalizer;
 165   bool _has_empty_finalizer;
 166   bool _has_vanilla_constructor;
 167   int _max_bootstrap_specifier_index;  // detects BSS values
 168 
 169   void parse_stream(const ClassFileStream* const stream, TRAPS);
 170 
 171   void post_process_parsed_stream(const ClassFileStream* const stream,
 172                                   ConstantPool* cp,
 173                                   TRAPS);
 174 
 175   void prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS);
 176   void fix_unsafe_anonymous_class_name(TRAPS);
 177 
 178   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS);
 179   void set_klass(InstanceKlass* instance);
 180 
 181   void set_class_bad_constant_seen(short bad_constant);
 182   short class_bad_constant_seen() { return  _bad_constant_seen; }
 183   void set_class_synthetic_flag(bool x)        { _synthetic_flag = x; }
 184   void set_class_sourcefile_index(u2 x)        { _sourcefile_index = x; }
 185   void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
 186   void set_class_sde_buffer(const char* x, int len)  { _sde_buffer = x; _sde_length = len; }
 187 
 188   void create_combined_annotations(TRAPS);
 189   void apply_parsed_class_attributes(InstanceKlass* k);  // update k
 190   void apply_parsed_class_metadata(InstanceKlass* k, int fields_count, TRAPS);
 191   void clear_class_metadata();
 192 
 193   // Constant pool parsing
 194   void parse_constant_pool_entries(const ClassFileStream* const stream,
 195                                    ConstantPool* cp,
 196                                    const int length,
 197                                    TRAPS);
 198 
 199   void parse_constant_pool(const ClassFileStream* const cfs,
 200                            ConstantPool* const cp,
 201                            const int length,
 202                            TRAPS);
 203 
 204   // Interface parsing
 205   void parse_interfaces(const ClassFileStream* const stream,
 206                         const int itfs_len,
 207                         ConstantPool* const cp,
 208                         bool* has_nonstatic_concrete_methods,
 209                         TRAPS);
 210 


 270                                             TRAPS);
 271 
 272   // Classfile attribute parsing
 273   u2 parse_generic_signature_attribute(const ClassFileStream* const cfs, TRAPS);
 274   void parse_classfile_sourcefile_attribute(const ClassFileStream* const cfs, TRAPS);
 275   void parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs,
 276                                                         int length,
 277                                                         TRAPS);
 278 
 279   u2   parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs,
 280                                                const u1* const inner_classes_attribute_start,
 281                                                bool parsed_enclosingmethod_attribute,
 282                                                u2 enclosing_method_class_index,
 283                                                u2 enclosing_method_method_index,
 284                                                TRAPS);
 285 
 286   u2 parse_classfile_nest_members_attribute(const ClassFileStream* const cfs,
 287                                             const u1* const nest_members_attribute_start,
 288                                             TRAPS);
 289 










 290   void parse_classfile_attributes(const ClassFileStream* const cfs,
 291                                   ConstantPool* cp,
 292                                   ClassAnnotationCollector* parsed_annotations,
 293                                   TRAPS);
 294 
 295   void parse_classfile_synthetic_attribute(TRAPS);
 296   void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
 297   void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
 298                                                    ConstantPool* cp,
 299                                                    u4 attribute_length,
 300                                                    TRAPS);
 301 
 302   // Annotations handling
 303   AnnotationArray* assemble_annotations(const u1* const runtime_visible_annotations,
 304                                         int runtime_visible_annotations_length,
 305                                         const u1* const runtime_invisible_annotations,
 306                                         int runtime_invisible_annotations_length,
 307                                         TRAPS);
 308 
 309   void set_precomputed_flags(InstanceKlass* k);


 469                                const u1* runtime_invisible_annotations,
 470                                int runtime_invisible_annotations_length,
 471                                const u1* runtime_visible_parameter_annotations,
 472                                int runtime_visible_parameter_annotations_length,
 473                                const u1* runtime_invisible_parameter_annotations,
 474                                int runtime_invisible_parameter_annotations_length,
 475                                const u1* runtime_visible_type_annotations,
 476                                int runtime_visible_type_annotations_length,
 477                                const u1* runtime_invisible_type_annotations,
 478                                int runtime_invisible_type_annotations_length,
 479                                const u1* annotation_default,
 480                                int annotation_default_length,
 481                                TRAPS);
 482 
 483   // lays out fields in class and returns the total oopmap count
 484   void layout_fields(ConstantPool* cp,
 485                      const FieldAllocationCount* fac,
 486                      const ClassAnnotationCollector* parsed_annotations,
 487                      FieldLayoutInfo* info,
 488                      TRAPS);



 489 
 490    void update_class_name(Symbol* new_name);
 491 
 492  public:
 493   ClassFileParser(ClassFileStream* stream,
 494                   Symbol* name,
 495                   ClassLoaderData* loader_data,
 496                   Handle protection_domain,
 497                   const InstanceKlass* unsafe_anonymous_host,
 498                   GrowableArray<Handle>* cp_patches,
 499                   Publicity pub_level,
 500                   TRAPS);
 501 
 502   ~ClassFileParser();
 503 
 504   InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, TRAPS);
 505 
 506   const ClassFileStream* clone_stream() const;
 507 
 508   void set_klass_to_deallocate(InstanceKlass* klass);




  81   const Symbol* _requested_name;
  82   Symbol* _class_name;
  83   mutable ClassLoaderData* _loader_data;
  84   const InstanceKlass* _unsafe_anonymous_host;
  85   GrowableArray<Handle>* _cp_patches; // overrides for CP entries
  86   int _num_patched_klasses;
  87   int _max_num_patched_klasses;
  88   int _orig_cp_size;
  89   int _first_patched_klass_resolved_index;
  90 
  91   // Metadata created before the instance klass is created.  Must be deallocated
  92   // if not transferred to the InstanceKlass upon successful class loading
  93   // in which case these pointers have been set to NULL.
  94   const InstanceKlass* _super_klass;
  95   ConstantPool* _cp;
  96   Array<u2>* _fields;
  97   Array<Method*>* _methods;
  98   Array<u2>* _inner_classes;
  99   Array<u2>* _nest_members;
 100   u2 _nest_host;
 101   Array<u2>* _record_params;
 102   Array<u2>* _permitted_subtypes;
 103   Array<InstanceKlass*>* _local_interfaces;
 104   Array<InstanceKlass*>* _transitive_interfaces;
 105   Annotations* _combined_annotations;
 106   AnnotationArray* _annotations;
 107   AnnotationArray* _type_annotations;
 108   Array<AnnotationArray*>* _fields_annotations;
 109   Array<AnnotationArray*>* _fields_type_annotations;
 110   InstanceKlass* _klass;  // InstanceKlass* once created.
 111   InstanceKlass* _klass_to_deallocate; // an InstanceKlass* to be destroyed
 112 
 113   ClassAnnotationCollector* _parsed_annotations;
 114   FieldAllocationCount* _fac;
 115   FieldLayoutInfo* _field_info;
 116   const intArray* _method_ordering;
 117   GrowableArray<Method*>* _all_mirandas;
 118 
 119   enum { fixed_buffer_size = 128 };
 120   u_char _linenumbertable_buffer[fixed_buffer_size];
 121 
 122   // Size of Java vtable (in words)


 137   // in regular class files.  For class file version >= 53, a CFE cannot be thrown
 138   // immediately when these are seen because a NCDFE must be thrown if the class's
 139   // access_flags have ACC_MODULE set.  But, the access_flags haven't been looked
 140   // at yet.  So, the bad constant pool item is cached here.  A value of zero
 141   // means that no constant pool item 19 or 20 was found.
 142   short _bad_constant_seen;
 143 
 144   // class attributes parsed before the instance klass is created:
 145   bool _synthetic_flag;
 146   int _sde_length;
 147   const char* _sde_buffer;
 148   u2 _sourcefile_index;
 149   u2 _generic_signature_index;
 150 
 151   u2 _major_version;
 152   u2 _minor_version;
 153   u2 _this_class_index;
 154   u2 _super_class_index;
 155   u2 _itfs_len;
 156   u2 _java_fields_count;
 157   int _record_params_count;
 158 
 159   bool _need_verify;
 160   bool _relax_verify;
 161 
 162   bool _has_nonstatic_concrete_methods;
 163   bool _declares_nonstatic_concrete_methods;
 164   bool _has_final_method;
 165 
 166   // precomputed flags
 167   bool _has_finalizer;
 168   bool _has_empty_finalizer;
 169   bool _has_vanilla_constructor;
 170   int _max_bootstrap_specifier_index;  // detects BSS values
 171 
 172   void parse_stream(const ClassFileStream* const stream, TRAPS);
 173 
 174   void post_process_parsed_stream(const ClassFileStream* const stream,
 175                                   ConstantPool* cp,
 176                                   TRAPS);
 177 
 178   void prepend_host_package_name(const InstanceKlass* unsafe_anonymous_host, TRAPS);
 179   void fix_unsafe_anonymous_class_name(TRAPS);
 180 
 181   void fill_instance_klass(InstanceKlass* ik, bool cf_changed_in_CFLH, TRAPS);
 182   void set_klass(InstanceKlass* instance);
 183 
 184   void set_class_bad_constant_seen(short bad_constant);
 185   short class_bad_constant_seen() { return  _bad_constant_seen; }
 186   void set_class_synthetic_flag(bool x)        { _synthetic_flag = x; }
 187   void set_class_sourcefile_index(u2 x)        { _sourcefile_index = x; }
 188   void set_class_generic_signature_index(u2 x) { _generic_signature_index = x; }
 189   void set_class_sde_buffer(const char* x, int len)  { _sde_buffer = x; _sde_length = len; }
 190 
 191   void create_combined_annotations(TRAPS);
 192   void apply_parsed_class_attributes(InstanceKlass* k);  // update k
 193   void apply_parsed_class_metadata(InstanceKlass* k, int fields_count, int record_params_count, TRAPS);
 194   void clear_class_metadata();
 195 
 196   // Constant pool parsing
 197   void parse_constant_pool_entries(const ClassFileStream* const stream,
 198                                    ConstantPool* cp,
 199                                    const int length,
 200                                    TRAPS);
 201 
 202   void parse_constant_pool(const ClassFileStream* const cfs,
 203                            ConstantPool* const cp,
 204                            const int length,
 205                            TRAPS);
 206 
 207   // Interface parsing
 208   void parse_interfaces(const ClassFileStream* const stream,
 209                         const int itfs_len,
 210                         ConstantPool* const cp,
 211                         bool* has_nonstatic_concrete_methods,
 212                         TRAPS);
 213 


 273                                             TRAPS);
 274 
 275   // Classfile attribute parsing
 276   u2 parse_generic_signature_attribute(const ClassFileStream* const cfs, TRAPS);
 277   void parse_classfile_sourcefile_attribute(const ClassFileStream* const cfs, TRAPS);
 278   void parse_classfile_source_debug_extension_attribute(const ClassFileStream* const cfs,
 279                                                         int length,
 280                                                         TRAPS);
 281 
 282   u2   parse_classfile_inner_classes_attribute(const ClassFileStream* const cfs,
 283                                                const u1* const inner_classes_attribute_start,
 284                                                bool parsed_enclosingmethod_attribute,
 285                                                u2 enclosing_method_class_index,
 286                                                u2 enclosing_method_method_index,
 287                                                TRAPS);
 288 
 289   u2 parse_classfile_nest_members_attribute(const ClassFileStream* const cfs,
 290                                             const u1* const nest_members_attribute_start,
 291                                             TRAPS);
 292 
 293   u2 parse_classfile_permitted_subtypes_attribute(const ClassFileStream* const cfs,
 294                                             const u1* const permitted_subtypes_attribute_start,
 295                                             TRAPS);
 296 
 297   void parse_classfile_record_attribute(const ClassFileStream* const cfs,
 298                                         const u1* const record_attribute_start,
 299                                         ConstantPool* cp,
 300                                         int* const record_params_count_ptr,
 301                                         TRAPS);
 302 
 303   void parse_classfile_attributes(const ClassFileStream* const cfs,
 304                                   ConstantPool* cp,
 305                                   ClassAnnotationCollector* parsed_annotations,
 306                                   TRAPS);
 307 
 308   void parse_classfile_synthetic_attribute(TRAPS);
 309   void parse_classfile_signature_attribute(const ClassFileStream* const cfs, TRAPS);
 310   void parse_classfile_bootstrap_methods_attribute(const ClassFileStream* const cfs,
 311                                                    ConstantPool* cp,
 312                                                    u4 attribute_length,
 313                                                    TRAPS);
 314 
 315   // Annotations handling
 316   AnnotationArray* assemble_annotations(const u1* const runtime_visible_annotations,
 317                                         int runtime_visible_annotations_length,
 318                                         const u1* const runtime_invisible_annotations,
 319                                         int runtime_invisible_annotations_length,
 320                                         TRAPS);
 321 
 322   void set_precomputed_flags(InstanceKlass* k);


 482                                const u1* runtime_invisible_annotations,
 483                                int runtime_invisible_annotations_length,
 484                                const u1* runtime_visible_parameter_annotations,
 485                                int runtime_visible_parameter_annotations_length,
 486                                const u1* runtime_invisible_parameter_annotations,
 487                                int runtime_invisible_parameter_annotations_length,
 488                                const u1* runtime_visible_type_annotations,
 489                                int runtime_visible_type_annotations_length,
 490                                const u1* runtime_invisible_type_annotations,
 491                                int runtime_invisible_type_annotations_length,
 492                                const u1* annotation_default,
 493                                int annotation_default_length,
 494                                TRAPS);
 495 
 496   // lays out fields in class and returns the total oopmap count
 497   void layout_fields(ConstantPool* cp,
 498                      const FieldAllocationCount* fac,
 499                      const ClassAnnotationCollector* parsed_annotations,
 500                      FieldLayoutInfo* info,
 501                      TRAPS);
 502 
 503    // check that the current class is not extending a final class or interface
 504    void check_subtyping(TRAPS);
 505 
 506    void update_class_name(Symbol* new_name);
 507 
 508  public:
 509   ClassFileParser(ClassFileStream* stream,
 510                   Symbol* name,
 511                   ClassLoaderData* loader_data,
 512                   Handle protection_domain,
 513                   const InstanceKlass* unsafe_anonymous_host,
 514                   GrowableArray<Handle>* cp_patches,
 515                   Publicity pub_level,
 516                   TRAPS);
 517 
 518   ~ClassFileParser();
 519 
 520   InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, TRAPS);
 521 
 522   const ClassFileStream* clone_stream() const;
 523 
 524   void set_klass_to_deallocate(InstanceKlass* klass);


< prev index next >