< prev index next >

src/hotspot/share/classfile/classFileParser.hpp

Print this page




  61   // It is used to control which subsystems (if any)
  62   // will observe the parsing (logging, events, tracing).
  63   // Default level is "BROADCAST", which is equivalent to
  64   // a "public" parsing attempt.
  65   //
  66   // "INTERNAL" level should be entirely private to the
  67   // caller - this allows for internal reuse of ClassFileParser
  68   //
  69   enum Publicity {
  70     INTERNAL,
  71     BROADCAST
  72   };
  73 
  74   enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
  75 
  76  private:
  77   // Potentially unaligned pointer to various 16-bit entries in the class file
  78   typedef void unsafe_u2;
  79 
  80   const ClassFileStream* _stream; // Actual input stream
  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;


 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 


 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);
 509 
 510   int static_field_size() const;
 511   int total_oop_map_count() const;
 512   jint layout_size() const;
 513 
 514   int vtable_size() const { return _vtable_size; }
 515   int itable_size() const { return _itable_size; }
 516 
 517   u2 this_class_index() const { return _this_class_index; }
 518 
 519   bool is_unsafe_anonymous() const { return _unsafe_anonymous_host != NULL; }

 520   bool is_interface() const { return _access_flags.is_interface(); }
 521 
 522   const InstanceKlass* unsafe_anonymous_host() const { return _unsafe_anonymous_host; }
 523   const GrowableArray<Handle>* cp_patches() const { return _cp_patches; }
 524   ClassLoaderData* loader_data() const { return _loader_data; }
 525   const Symbol* class_name() const { return _class_name; }
 526   const InstanceKlass* super_klass() const { return _super_klass; }
 527 
 528   ReferenceType reference_type() const { return _rt; }
 529   AccessFlags access_flags() const { return _access_flags; }
 530 
 531   bool is_internal() const { return INTERNAL == _pub_level; }
 532 
 533   static bool verify_unqualified_name(const char* name, unsigned int length, int type);
 534 
 535 #ifdef ASSERT
 536   static bool is_internal_format(Symbol* class_name);
 537 #endif
 538 
 539 };


  61   // It is used to control which subsystems (if any)
  62   // will observe the parsing (logging, events, tracing).
  63   // Default level is "BROADCAST", which is equivalent to
  64   // a "public" parsing attempt.
  65   //
  66   // "INTERNAL" level should be entirely private to the
  67   // caller - this allows for internal reuse of ClassFileParser
  68   //
  69   enum Publicity {
  70     INTERNAL,
  71     BROADCAST
  72   };
  73 
  74   enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
  75 
  76  private:
  77   // Potentially unaligned pointer to various 16-bit entries in the class file
  78   typedef void unsafe_u2;
  79 
  80   const ClassFileStream* _stream; // Actual input stream

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


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


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


 494  public:
 495   ClassFileParser(ClassFileStream* stream,
 496                   Symbol* name,
 497                   ClassLoaderData* loader_data,
 498                   Handle protection_domain,
 499                   const InstanceKlass* unsafe_anonymous_host,
 500                   GrowableArray<Handle>* cp_patches,
 501                   const bool is_nonfindable,
 502                   const bool can_access_vm_annotations,
 503                   Publicity pub_level,
 504                   TRAPS);
 505 
 506   ~ClassFileParser();
 507 
 508   InstanceKlass* create_instance_klass(bool cf_changed_in_CFLH, InstanceKlass* dynamic_nest_host, Handle classData, TRAPS);
 509 
 510   const ClassFileStream* clone_stream() const;
 511 
 512   void set_klass_to_deallocate(InstanceKlass* klass);
 513 
 514   int static_field_size() const;
 515   int total_oop_map_count() const;
 516   jint layout_size() const;
 517 
 518   int vtable_size() const { return _vtable_size; }
 519   int itable_size() const { return _itable_size; }
 520 
 521   u2 this_class_index() const { return _this_class_index; }
 522 
 523   bool is_unsafe_anonymous() const { return _unsafe_anonymous_host != NULL; }
 524   bool is_nonfindable() const { return _is_nonfindable; }
 525   bool is_interface() const { return _access_flags.is_interface(); }
 526 
 527   const InstanceKlass* unsafe_anonymous_host() const { return _unsafe_anonymous_host; }
 528   const GrowableArray<Handle>* cp_patches() const { return _cp_patches; }
 529   ClassLoaderData* loader_data() const { return _loader_data; }
 530   const Symbol* class_name() const { return _class_name; }
 531   const InstanceKlass* super_klass() const { return _super_klass; }
 532 
 533   ReferenceType reference_type() const { return _rt; }
 534   AccessFlags access_flags() const { return _access_flags; }
 535 
 536   bool is_internal() const { return INTERNAL == _pub_level; }
 537 
 538   static bool verify_unqualified_name(const char* name, unsigned int length, int type);
 539 
 540 #ifdef ASSERT
 541   static bool is_internal_format(Symbol* class_name);
 542 #endif
 543 
 544 };
< prev index next >