< prev index next >

src/hotspot/share/oops/instanceKlass.hpp

Print this page




  24 
  25 #ifndef SHARE_VM_OOPS_INSTANCEKLASS_HPP
  26 #define SHARE_VM_OOPS_INSTANCEKLASS_HPP
  27 
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.hpp"
  30 #include "classfile/moduleEntry.hpp"
  31 #include "classfile/packageEntry.hpp"
  32 #include "memory/referenceType.hpp"
  33 #include "oops/annotations.hpp"
  34 #include "oops/constMethod.hpp"
  35 #include "oops/fieldInfo.hpp"
  36 #include "oops/instanceOop.hpp"
  37 #include "oops/klassVtable.hpp"
  38 #include "runtime/handles.hpp"
  39 #include "runtime/os.hpp"
  40 #include "utilities/accessFlags.hpp"
  41 #include "utilities/align.hpp"
  42 #include "utilities/macros.hpp"
  43 #if INCLUDE_JFR

  44 #include "jfr/support/jfrKlassExtension.hpp"
  45 #endif
  46 
  47 
  48 // An InstanceKlass is the VM level representation of a Java class.
  49 // It contains all information needed for at class at execution runtime.
  50 
  51 //  InstanceKlass embedded field layout (after declared fields):
  52 //    [EMBEDDED Java vtable             ] size in words = vtable_len
  53 //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
  54 //      The embedded nonstatic oop-map blocks are short pairs (offset, length)
  55 //      indicating where oops are located in instances of this klass.
  56 //    [EMBEDDED implementor of the interface] only exist for interface
  57 //    [EMBEDDED unsafe_anonymous_host klass] only exist for an unsafe anonymous class (JSR 292 enabled)
  58 //    [EMBEDDED fingerprint       ] only if should_store_fingerprint()==true
  59 
  60 
  61 // forward declaration for class -- see below for definition
  62 #if INCLUDE_JVMTI
  63 class BreakpointInfo;


 125  protected:
 126   InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id = ID);
 127 
 128  public:
 129   InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
 130 
 131   // See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description
 132   // of the class loading & initialization procedure, and the use of the states.
 133   enum ClassState {
 134     allocated,                          // allocated (but not yet linked)
 135     loaded,                             // loaded and inserted in class hierarchy (but not linked yet)
 136     linked,                             // successfully linked/verified (but not initialized yet)
 137     being_initialized,                  // currently running class initializer
 138     fully_initialized,                  // initialized (successfull final state)
 139     initialization_error                // error happened during initialization
 140   };
 141 
 142  private:
 143   static InstanceKlass* allocate_instance_klass(const ClassFileParser& parser, TRAPS);
 144 





 145  protected:
 146   // If you add a new field that points to any metaspace object, you
 147   // must add this field to InstanceKlass::metaspace_pointers_do().
 148 
 149   // Annotations for this class
 150   Annotations*    _annotations;
 151   // Package this class is defined in
 152   PackageEntry*   _package_entry;
 153   // Array classes holding elements of this class.
 154   Klass* volatile _array_klasses;
 155   // Constant pool for this class.
 156   ConstantPool* _constants;
 157   // The InnerClasses attribute and EnclosingMethod attribute. The
 158   // _inner_classes is an array of shorts. If the class has InnerClasses
 159   // attribute, then the _inner_classes array begins with 4-tuples of shorts
 160   // [inner_class_info_index, outer_class_info_index,
 161   // inner_name_index, inner_class_access_flags] for the InnerClasses
 162   // attribute. If the EnclosingMethod attribute exists, it occupies the
 163   // last two shorts [class_index, method_index] of the array. If only
 164   // the InnerClasses attribute exists, the _inner_classes array length is


 408   // default_methods
 409   Array<Method*>* default_methods() const  { return _default_methods; }
 410   void set_default_methods(Array<Method*>* a) { _default_methods = a; }
 411 
 412   // default method vtable_indices
 413   Array<int>* default_vtable_indices() const { return _default_vtable_indices; }
 414   void set_default_vtable_indices(Array<int>* v) { _default_vtable_indices = v; }
 415   Array<int>* create_new_default_vtable_indices(int len, TRAPS);
 416 
 417   // interfaces
 418   Array<InstanceKlass*>* local_interfaces() const          { return _local_interfaces; }
 419   void set_local_interfaces(Array<InstanceKlass*>* a)      {
 420     guarantee(_local_interfaces == NULL || a == NULL, "Just checking");
 421     _local_interfaces = a; }
 422 
 423   Array<InstanceKlass*>* transitive_interfaces() const     { return _transitive_interfaces; }
 424   void set_transitive_interfaces(Array<InstanceKlass*>* a) {
 425     guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");
 426     _transitive_interfaces = a;
 427   }





 428 
 429  private:
 430   friend class fieldDescriptor;
 431   FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
 432 
 433  public:
 434   int     field_offset      (int index) const { return field(index)->offset(); }
 435   int     field_access_flags(int index) const { return field(index)->access_flags(); }
 436   Symbol* field_name        (int index) const { return field(index)->name(constants()); }
 437   Symbol* field_signature   (int index) const { return field(index)->signature(constants()); }
 438 
 439   // Number of Java declared fields
 440   int java_fields_count() const           { return (int)_java_fields_count; }
 441 
 442   Array<u2>* fields() const            { return _fields; }
 443   void set_fields(Array<u2>* f, u2 java_fields_count) {
 444     guarantee(_fields == NULL || f == NULL, "Just checking");
 445     _fields = f;
 446     _java_fields_count = java_fields_count;
 447   }




  24 
  25 #ifndef SHARE_VM_OOPS_INSTANCEKLASS_HPP
  26 #define SHARE_VM_OOPS_INSTANCEKLASS_HPP
  27 
  28 #include "classfile/classLoader.hpp"
  29 #include "classfile/classLoaderData.hpp"
  30 #include "classfile/moduleEntry.hpp"
  31 #include "classfile/packageEntry.hpp"
  32 #include "memory/referenceType.hpp"
  33 #include "oops/annotations.hpp"
  34 #include "oops/constMethod.hpp"
  35 #include "oops/fieldInfo.hpp"
  36 #include "oops/instanceOop.hpp"
  37 #include "oops/klassVtable.hpp"
  38 #include "runtime/handles.hpp"
  39 #include "runtime/os.hpp"
  40 #include "utilities/accessFlags.hpp"
  41 #include "utilities/align.hpp"
  42 #include "utilities/macros.hpp"
  43 #if INCLUDE_JFR
  44 #include "utilities/ticks.hpp"
  45 #include "jfr/support/jfrKlassExtension.hpp"
  46 #endif
  47 
  48 
  49 // An InstanceKlass is the VM level representation of a Java class.
  50 // It contains all information needed for at class at execution runtime.
  51 
  52 //  InstanceKlass embedded field layout (after declared fields):
  53 //    [EMBEDDED Java vtable             ] size in words = vtable_len
  54 //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
  55 //      The embedded nonstatic oop-map blocks are short pairs (offset, length)
  56 //      indicating where oops are located in instances of this klass.
  57 //    [EMBEDDED implementor of the interface] only exist for interface
  58 //    [EMBEDDED unsafe_anonymous_host klass] only exist for an unsafe anonymous class (JSR 292 enabled)
  59 //    [EMBEDDED fingerprint       ] only if should_store_fingerprint()==true
  60 
  61 
  62 // forward declaration for class -- see below for definition
  63 #if INCLUDE_JVMTI
  64 class BreakpointInfo;


 126  protected:
 127   InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id = ID);
 128 
 129  public:
 130   InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
 131 
 132   // See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description
 133   // of the class loading & initialization procedure, and the use of the states.
 134   enum ClassState {
 135     allocated,                          // allocated (but not yet linked)
 136     loaded,                             // loaded and inserted in class hierarchy (but not linked yet)
 137     linked,                             // successfully linked/verified (but not initialized yet)
 138     being_initialized,                  // currently running class initializer
 139     fully_initialized,                  // initialized (successfull final state)
 140     initialization_error                // error happened during initialization
 141   };
 142 
 143  private:
 144   static InstanceKlass* allocate_instance_klass(const ClassFileParser& parser, TRAPS);
 145 
 146 #if INCLUDE_JFR
 147   // JFR Class unloading timestamp
 148   static Ticks _class_unload_time;
 149 #endif
 150 
 151  protected:
 152   // If you add a new field that points to any metaspace object, you
 153   // must add this field to InstanceKlass::metaspace_pointers_do().
 154 
 155   // Annotations for this class
 156   Annotations*    _annotations;
 157   // Package this class is defined in
 158   PackageEntry*   _package_entry;
 159   // Array classes holding elements of this class.
 160   Klass* volatile _array_klasses;
 161   // Constant pool for this class.
 162   ConstantPool* _constants;
 163   // The InnerClasses attribute and EnclosingMethod attribute. The
 164   // _inner_classes is an array of shorts. If the class has InnerClasses
 165   // attribute, then the _inner_classes array begins with 4-tuples of shorts
 166   // [inner_class_info_index, outer_class_info_index,
 167   // inner_name_index, inner_class_access_flags] for the InnerClasses
 168   // attribute. If the EnclosingMethod attribute exists, it occupies the
 169   // last two shorts [class_index, method_index] of the array. If only
 170   // the InnerClasses attribute exists, the _inner_classes array length is


 414   // default_methods
 415   Array<Method*>* default_methods() const  { return _default_methods; }
 416   void set_default_methods(Array<Method*>* a) { _default_methods = a; }
 417 
 418   // default method vtable_indices
 419   Array<int>* default_vtable_indices() const { return _default_vtable_indices; }
 420   void set_default_vtable_indices(Array<int>* v) { _default_vtable_indices = v; }
 421   Array<int>* create_new_default_vtable_indices(int len, TRAPS);
 422 
 423   // interfaces
 424   Array<InstanceKlass*>* local_interfaces() const          { return _local_interfaces; }
 425   void set_local_interfaces(Array<InstanceKlass*>* a)      {
 426     guarantee(_local_interfaces == NULL || a == NULL, "Just checking");
 427     _local_interfaces = a; }
 428 
 429   Array<InstanceKlass*>* transitive_interfaces() const     { return _transitive_interfaces; }
 430   void set_transitive_interfaces(Array<InstanceKlass*>* a) {
 431     guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");
 432     _transitive_interfaces = a;
 433   }
 434 
 435 #if INCLUDE_JFR
 436   static void set_class_unload_time(Ticks ticks) { _class_unload_time = ticks; }
 437   static Ticks class_unload_time() { return _class_unload_time; }
 438 #endif
 439 
 440  private:
 441   friend class fieldDescriptor;
 442   FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
 443 
 444  public:
 445   int     field_offset      (int index) const { return field(index)->offset(); }
 446   int     field_access_flags(int index) const { return field(index)->access_flags(); }
 447   Symbol* field_name        (int index) const { return field(index)->name(constants()); }
 448   Symbol* field_signature   (int index) const { return field(index)->signature(constants()); }
 449 
 450   // Number of Java declared fields
 451   int java_fields_count() const           { return (int)_java_fields_count; }
 452 
 453   Array<u2>* fields() const            { return _fields; }
 454   void set_fields(Array<u2>* f, u2 java_fields_count) {
 455     guarantee(_fields == NULL || f == NULL, "Just checking");
 456     _fields = f;
 457     _java_fields_count = java_fields_count;
 458   }


< prev index next >