< prev index next >

src/hotspot/share/oops/instanceKlass.hpp

Print this page




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OOPS_INSTANCEKLASS_HPP
  26 #define SHARE_OOPS_INSTANCEKLASS_HPP
  27 
  28 #include "classfile/classLoaderData.hpp"

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

  56 
  57 
  58 // forward declaration for class -- see below for definition
  59 #if INCLUDE_JVMTI
  60 class BreakpointInfo;
  61 #endif
  62 class ClassFileParser;
  63 class ClassFileStream;
  64 class KlassDepChange;
  65 class DependencyContext;
  66 class fieldDescriptor;
  67 class jniIdMapBase;
  68 class JNIid;
  69 class JvmtiCachedClassFieldMap;
  70 class nmethodBucket;
  71 class OopMapCache;

  72 class InterpreterOopMap;
  73 class PackageEntry;
  74 class ModuleEntry;
  75 
  76 // This is used in iterators below.
  77 class FieldClosure: public StackObj {
  78 public:
  79   virtual void do_field(fieldDescriptor* fd) = 0;
  80 };
  81 
  82 #ifndef PRODUCT
  83 // Print fields.
  84 // If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields.
  85 class FieldPrinter: public FieldClosure {
  86    oop _obj;
  87    outputStream* _st;
  88  public:
  89    FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {}
  90    void do_field(fieldDescriptor* fd);
  91 };
  92 #endif  // !PRODUCT
  93 
  94 // Describes where oops are located in instances of this klass.
  95 class OopMapBlock {
  96  public:
  97   // Byte offset of the first oop mapped by this block.
  98   int offset() const          { return _offset; }
  99   void set_offset(int offset) { _offset = offset; }
 100 
 101   // Number of oops in this block.
 102   uint count() const         { return _count; }
 103   void set_count(uint count) { _count = count; }
 104 












 105   // sizeof(OopMapBlock) in words.
 106   static const int size_in_words() {
 107     return align_up((int)sizeof(OopMapBlock), wordSize) >>
 108       LogBytesPerWord;
 109   }
 110 




 111  private:
 112   int  _offset;
 113   uint _count;
 114 };
 115 
 116 struct JvmtiCachedClassFileData;
 117 






















 118 class InstanceKlass: public Klass {
 119   friend class VMStructs;
 120   friend class JVMCIVMStructs;
 121   friend class ClassFileParser;
 122   friend class CompileReplay;
 123 
 124  public:
 125   static const KlassID ID = InstanceKlassID;
 126 
 127  protected:
 128   InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id = ID);
 129 
 130  public:
 131   InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
 132 
 133   // See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description
 134   // of the class loading & initialization procedure, and the use of the states.
 135   enum ClassState {
 136     allocated,                          // allocated (but not yet linked)
 137     loaded,                             // loaded and inserted in class hierarchy (but not linked yet)
 138     linked,                             // successfully linked/verified (but not initialized yet)
 139     being_initialized,                  // currently running class initializer
 140     fully_initialized,                  // initialized (successfull final state)
 141     initialization_error                // error happened during initialization
 142   };
 143 
 144  private:
 145   static InstanceKlass* allocate_instance_klass(const ClassFileParser& parser, TRAPS);
 146 
 147  protected:
 148   // If you add a new field that points to any metaspace object, you
 149   // must add this field to InstanceKlass::metaspace_pointers_do().
 150 
 151   // Annotations for this class
 152   Annotations*    _annotations;
 153   // Package this class is defined in
 154   PackageEntry*   _package_entry;
 155   // Array classes holding elements of this class.
 156   Klass* volatile _array_klasses;
 157   // Constant pool for this class.
 158   ConstantPool* _constants;
 159   // The InnerClasses attribute and EnclosingMethod attribute. The
 160   // _inner_classes is an array of shorts. If the class has InnerClasses


 165   // last two shorts [class_index, method_index] of the array. If only
 166   // the InnerClasses attribute exists, the _inner_classes array length is
 167   // number_of_inner_classes * 4. If the class has both InnerClasses
 168   // and EnclosingMethod attributes the _inner_classes array length is
 169   // number_of_inner_classes * 4 + enclosing_method_attribute_size.
 170   Array<jushort>* _inner_classes;
 171 
 172   // The NestMembers attribute. An array of shorts, where each is a
 173   // class info index for the class that is a nest member. This data
 174   // has not been validated.
 175   Array<jushort>* _nest_members;
 176 
 177   // The NestHost attribute. The class info index for the class
 178   // that is the nest-host of this class. This data has not been validated.
 179   jushort _nest_host_index;
 180 
 181   // Resolved nest-host klass: either true nest-host or self if we are not nested.
 182   // By always being set it makes nest-member access checks simpler.
 183   InstanceKlass* _nest_host;
 184 


 185   // the source debug extension for this klass, NULL if not specified.
 186   // Specified as UTF-8 string without terminating zero byte in the classfile,
 187   // it is stored in the instanceklass as a NULL-terminated UTF-8 string
 188   const char*     _source_debug_extension;
 189   // Array name derived from this class which needs unreferencing
 190   // if this class is unloaded.
 191   Symbol*         _array_name;
 192 
 193   // Number of heapOopSize words used by non-static fields in this klass
 194   // (including inherited fields but after header_size()).
 195   int             _nonstatic_field_size;
 196   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
 197   // Constant pool index to the utf8 entry of the Generic signature,
 198   // or 0 if none.
 199   u2              _generic_signature_index;
 200   // Constant pool index to the utf8 entry for the name of source file
 201   // containing this klass, 0 if not specified.
 202   u2              _source_file_name_index;
 203   u2              _static_oop_field_count;// number of static oop fields in this klass
 204   u2              _java_fields_count;    // The number of declared Java fields
 205   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
 206 
 207   int             _itable_len;           // length of Java itable (in words)
 208   // _is_marked_dependent can be set concurrently, thus cannot be part of the
 209   // _misc_flags.
 210   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
 211   bool            _is_being_redefined;   // used for locking redefinition
 212 
 213   // The low two bits of _misc_flags contains the kind field.
 214   // This can be used to quickly discriminate among the four kinds of












 215   // InstanceKlass.
 216 
 217   static const unsigned _misc_kind_field_size = 2;
 218   static const unsigned _misc_kind_field_pos  = 0;
 219   static const unsigned _misc_kind_field_mask = (1u << _misc_kind_field_size) - 1u;
 220 
 221   static const unsigned _misc_kind_other        = 0; // concrete InstanceKlass
 222   static const unsigned _misc_kind_reference    = 1; // InstanceRefKlass
 223   static const unsigned _misc_kind_class_loader = 2; // InstanceClassLoaderKlass
 224   static const unsigned _misc_kind_mirror       = 3; // InstanceMirrorKlass

 225 
 226   // Start after _misc_kind field.
 227   enum {
 228     _misc_rewritten                           = 1 << 2,  // methods rewritten.
 229     _misc_has_nonstatic_fields                = 1 << 3,  // for sizing with UseCompressedOops
 230     _misc_should_verify_class                 = 1 << 4,  // allow caching of preverification
 231     _misc_is_unsafe_anonymous                 = 1 << 5,  // has embedded _unsafe_anonymous_host field
 232     _misc_is_contended                        = 1 << 6,  // marked with contended annotation
 233     _misc_has_nonstatic_concrete_methods      = 1 << 7,  // class/superclass/implemented interfaces has non-static, concrete methods
 234     _misc_declares_nonstatic_concrete_methods = 1 << 8,  // directly declares non-static, concrete methods
 235     _misc_has_been_redefined                  = 1 << 9,  // class has been redefined
 236     _misc_has_passed_fingerprint_check        = 1 << 10, // when this class was loaded, the fingerprint computed from its
 237                                                          // code source was found to be matching the value recorded by AOT.
 238     _misc_is_scratch_class                    = 1 << 11, // class is the redefined scratch class
 239     _misc_is_shared_boot_class                = 1 << 12, // defining class loader is boot class loader
 240     _misc_is_shared_platform_class            = 1 << 13, // defining class loader is platform class loader
 241     _misc_is_shared_app_class                 = 1 << 14, // defining class loader is app class loader
 242     _misc_has_resolved_methods                = 1 << 15  // resolved methods table entries added for this class
 243   };
 244   u2 loader_type_bits() {
 245     return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
 246   }
 247   u2              _misc_flags;
 248   u2              _minor_version;        // minor version number of class file
 249   u2              _major_version;        // major version number of class file
 250   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recursive initialization)
 251   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
 252   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
 253   jmethodID*      volatile _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
 254   nmethodBucket*  volatile _dep_context;          // packed DependencyContext structure
 255   uint64_t        volatile _dep_context_last_cleaned;
 256   nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
 257 #if INCLUDE_JVMTI
 258   BreakpointInfo* _breakpoints;          // bpt lists, managed by Method*
 259   // Linked instanceKlasses of previous versions
 260   InstanceKlass* _previous_versions;
 261   // JVMTI fields can be moved to their own structure - see 6315920
 262   // JVMTI: cached class file, before retransformable agent modified it in CFLH


 290   Array<int>*     _method_ordering;
 291   // Int array containing the vtable_indices for default_methods
 292   // offset matches _default_methods offset
 293   Array<int>*     _default_vtable_indices;
 294 
 295   // Instance and static variable information, starts with 6-tuples of shorts
 296   // [access, name index, sig index, initval index, low_offset, high_offset]
 297   // for all fields, followed by the generic signature data at the end of
 298   // the array. Only fields with generic signature attributes have the generic
 299   // signature data set in the array. The fields array looks like following:
 300   //
 301   // f1: [access, name index, sig index, initial value index, low_offset, high_offset]
 302   // f2: [access, name index, sig index, initial value index, low_offset, high_offset]
 303   //      ...
 304   // fn: [access, name index, sig index, initial value index, low_offset, high_offset]
 305   //     [generic signature index]
 306   //     [generic signature index]
 307   //     ...
 308   Array<u2>*      _fields;
 309 


 310   // embedded Java vtable follows here
 311   // embedded Java itables follows here
 312   // embedded static fields follows here
 313   // embedded nonstatic oop-map blocks follows here
 314   // embedded implementor of this interface follows here
 315   //   The embedded implementor only exists if the current klass is an
 316   //   iterface. The possible values of the implementor fall into following
 317   //   three cases:
 318   //     NULL: no implementor.
 319   //     A Klass* that's not itself: one implementor.
 320   //     Itself: more than one implementors.
 321   // embedded unsafe_anonymous_host klass follows here
 322   //   The embedded host klass only exists in an unsafe anonymous class for
 323   //   dynamic language support (JSR 292 enabled). The host class grants
 324   //   its access privileges to this class also. The host class is either
 325   //   named, or a previously loaded unsafe anonymous class. A non-anonymous class
 326   //   or an anonymous class loaded through normal classloading does not
 327   //   have this embedded field.
 328   //
 329 


 344     return (_misc_flags & _misc_is_shared_app_class) != 0;
 345   }
 346 
 347   void clear_class_loader_type() {
 348     _misc_flags &= ~loader_type_bits();
 349   }
 350 
 351   void set_class_loader_type(s2 loader_type);
 352 
 353   bool has_nonstatic_fields() const        {
 354     return (_misc_flags & _misc_has_nonstatic_fields) != 0;
 355   }
 356   void set_has_nonstatic_fields(bool b)    {
 357     if (b) {
 358       _misc_flags |= _misc_has_nonstatic_fields;
 359     } else {
 360       _misc_flags &= ~_misc_has_nonstatic_fields;
 361     }
 362   }
 363 














 364   // field sizes
 365   int nonstatic_field_size() const         { return _nonstatic_field_size; }
 366   void set_nonstatic_field_size(int size)  { _nonstatic_field_size = size; }
 367 
 368   int static_field_size() const            { return _static_field_size; }
 369   void set_static_field_size(int size)     { _static_field_size = size; }
 370 
 371   int static_oop_field_count() const       { return (int)_static_oop_field_count; }
 372   void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
 373 
 374   // Java itable
 375   int  itable_length() const               { return _itable_len; }
 376   void set_itable_length(int len)          { _itable_len = len; }
 377 
 378   // array klasses
 379   Klass* array_klasses() const             { return _array_klasses; }
 380   inline Klass* array_klasses_acquire() const; // load with acquire semantics
 381   void set_array_klasses(Klass* k)         { _array_klasses = k; }
 382   inline void release_set_array_klasses(Klass* k); // store with release semantics
 383 


 406   Array<InstanceKlass*>* local_interfaces() const          { return _local_interfaces; }
 407   void set_local_interfaces(Array<InstanceKlass*>* a)      {
 408     guarantee(_local_interfaces == NULL || a == NULL, "Just checking");
 409     _local_interfaces = a; }
 410 
 411   Array<InstanceKlass*>* transitive_interfaces() const     { return _transitive_interfaces; }
 412   void set_transitive_interfaces(Array<InstanceKlass*>* a) {
 413     guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");
 414     _transitive_interfaces = a;
 415   }
 416 
 417  private:
 418   friend class fieldDescriptor;
 419   FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
 420 
 421  public:
 422   int     field_offset      (int index) const { return field(index)->offset(); }
 423   int     field_access_flags(int index) const { return field(index)->access_flags(); }
 424   Symbol* field_name        (int index) const { return field(index)->name(constants()); }
 425   Symbol* field_signature   (int index) const { return field(index)->signature(constants()); }


 426 
 427   // Number of Java declared fields
 428   int java_fields_count() const           { return (int)_java_fields_count; }
 429 
 430   Array<u2>* fields() const            { return _fields; }
 431   void set_fields(Array<u2>* f, u2 java_fields_count) {
 432     guarantee(_fields == NULL || f == NULL, "Just checking");
 433     _fields = f;
 434     _java_fields_count = java_fields_count;
 435   }
 436 
 437   // inner classes
 438   Array<u2>* inner_classes() const       { return _inner_classes; }
 439   void set_inner_classes(Array<u2>* f)   { _inner_classes = f; }
 440 
 441   // nest members
 442   Array<u2>* nest_members() const     { return _nest_members; }
 443   void set_nest_members(Array<u2>* m) { _nest_members = m; }
 444 
 445   // nest-host index


 505   bool is_reentrant_initialization(Thread *thread)  { return thread == _init_thread; }
 506   ClassState  init_state()                 { return (ClassState)_init_state; }
 507   bool is_rewritten() const                { return (_misc_flags & _misc_rewritten) != 0; }
 508 
 509   // defineClass specified verification
 510   bool should_verify_class() const         {
 511     return (_misc_flags & _misc_should_verify_class) != 0;
 512   }
 513   void set_should_verify_class(bool value) {
 514     if (value) {
 515       _misc_flags |= _misc_should_verify_class;
 516     } else {
 517       _misc_flags &= ~_misc_should_verify_class;
 518     }
 519   }
 520 
 521   // marking
 522   bool is_marked_dependent() const         { return _is_marked_dependent; }
 523   void set_is_marked_dependent(bool value) { _is_marked_dependent = value; }
 524 


 525   // initialization (virtuals from Klass)
 526   bool should_be_initialized() const;  // means that initialize should be called
 527   void initialize(TRAPS);
 528   void link_class(TRAPS);
 529   bool link_class_or_fail(TRAPS); // returns false on failure
 530   void rewrite_class(TRAPS);
 531   void link_methods(TRAPS);
 532   Method* class_initializer() const;
 533 
 534   // set the class to initialized if no static initializer is present
 535   void eager_initialize(Thread *thread);
 536 
 537   // reference type
 538   ReferenceType reference_type() const     { return (ReferenceType)_reference_type; }
 539   void set_reference_type(ReferenceType t) {
 540     assert(t == (u1)t, "overflow");
 541     _reference_type = (u1)t;
 542   }
 543 
 544   // this class cp index
 545   u2 this_class_index() const             { return _this_class_index; }
 546   void set_this_class_index(u2 index)     { _this_class_index = index; }
 547 
 548   static ByteSize reference_type_offset() { return in_ByteSize(offset_of(InstanceKlass, _reference_type)); }
 549 
 550   // find local field, returns true if found
 551   bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 552   // find field in direct superinterfaces, returns the interface in which the field is defined
 553   Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 554   // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
 555   Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 556   // find instance or static fields according to JVM spec 5.4.3.2, returns the klass in which the field is defined
 557   Klass* find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const;
 558 
 559   // find a non-static or static field given its offset within the class.
 560   bool contains_field_offset(int offset) {
 561     return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size());
 562   }
 563 
 564   bool find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
 565   bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
 566 
 567   // find a local method (returns NULL if not found)
 568   Method* find_method(const Symbol* name, const Symbol* signature) const;
 569   static Method* find_method(const Array<Method*>* methods,
 570                              const Symbol* name,
 571                              const Symbol* signature);
 572 
 573   // find a local method, but skip static methods
 574   Method* find_instance_method(const Symbol* name, const Symbol* signature,
 575                                PrivateLookupMode private_mode = find_private) const;
 576   static Method* find_instance_method(const Array<Method*>* methods,
 577                                       const Symbol* name,
 578                                       const Symbol* signature,
 579                                       PrivateLookupMode private_mode = find_private);
 580 
 581   // find a local method (returns NULL if not found)


 698   void set_source_debug_extension(const char* array, int length);
 699 
 700   // symbol unloading support (refcount already added)
 701   Symbol* array_name()                     { return _array_name; }
 702   void set_array_name(Symbol* name)        { assert(_array_name == NULL  || name == NULL, "name already created"); _array_name = name; }
 703 
 704   // nonstatic oop-map blocks
 705   static int nonstatic_oop_map_size(unsigned int oop_map_count) {
 706     return oop_map_count * OopMapBlock::size_in_words();
 707   }
 708   unsigned int nonstatic_oop_map_count() const {
 709     return _nonstatic_oop_map_size / OopMapBlock::size_in_words();
 710   }
 711   int nonstatic_oop_map_size() const { return _nonstatic_oop_map_size; }
 712   void set_nonstatic_oop_map_size(int words) {
 713     _nonstatic_oop_map_size = words;
 714   }
 715 
 716 #if INCLUDE_JVMTI
 717   // Redefinition locking.  Class can only be redefined by one thread at a time.
 718   bool is_being_redefined() const          { return _is_being_redefined; }
 719   void set_is_being_redefined(bool value)  { _is_being_redefined = value; }








 720 
 721   // RedefineClasses() support for previous versions:
 722   void add_previous_version(InstanceKlass* ik, int emcp_method_count);
 723   void purge_previous_version_list();
 724 
 725   InstanceKlass* previous_versions() const { return _previous_versions; }
 726 #else
 727   InstanceKlass* previous_versions() const { return NULL; }
 728 #endif
 729 
 730   InstanceKlass* get_klass_version(int version) {
 731     for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) {
 732       if (ik->constants()->version() == version) {
 733         return ik;
 734       }
 735     }
 736     return NULL;
 737   }
 738 
 739   bool has_been_redefined() const {


 753       _misc_flags &= ~_misc_has_passed_fingerprint_check;
 754     }
 755   }
 756   bool supers_have_passed_fingerprint_checks();
 757 
 758   static bool should_store_fingerprint(bool is_unsafe_anonymous);
 759   bool should_store_fingerprint() const { return should_store_fingerprint(is_unsafe_anonymous()); }
 760   bool has_stored_fingerprint() const;
 761   uint64_t get_stored_fingerprint() const;
 762   void store_fingerprint(uint64_t fingerprint);
 763 
 764   bool is_scratch_class() const {
 765     return (_misc_flags & _misc_is_scratch_class) != 0;
 766   }
 767 
 768   void set_is_scratch_class() {
 769     _misc_flags |= _misc_is_scratch_class;
 770   }
 771 
 772   bool has_resolved_methods() const {
 773     return (_misc_flags & _misc_has_resolved_methods) != 0;
 774   }
 775 
 776   void set_has_resolved_methods() {
 777     _misc_flags |= _misc_has_resolved_methods;
 778   }
 779 private:
 780 
 781   void set_kind(unsigned kind) {
 782     assert(kind <= _misc_kind_field_mask, "Invalid InstanceKlass kind");
 783     unsigned fmask = _misc_kind_field_mask << _misc_kind_field_pos;
 784     unsigned flags = _misc_flags & ~fmask;
 785     _misc_flags = (flags | (kind << _misc_kind_field_pos));
 786   }
 787 
 788   bool is_kind(unsigned desired) const {
 789     unsigned kind = (_misc_flags >> _misc_kind_field_pos) & _misc_kind_field_mask;
 790     return kind == desired;
 791   }
 792 
 793 public:
 794 
 795   // Other is anything that is not one of the more specialized kinds of InstanceKlass.
 796   bool is_other_instance_klass() const        { return is_kind(_misc_kind_other); }
 797   bool is_reference_instance_klass() const    { return is_kind(_misc_kind_reference); }
 798   bool is_mirror_instance_klass() const       { return is_kind(_misc_kind_mirror); }
 799   bool is_class_loader_instance_klass() const { return is_kind(_misc_kind_class_loader); }

 800 
 801 #if INCLUDE_JVMTI
 802 
 803   void init_previous_versions() {
 804     _previous_versions = NULL;
 805   }
 806 
 807  private:
 808   static bool  _has_previous_versions;
 809  public:
 810   static void purge_previous_versions(InstanceKlass* ik) {
 811     if (ik->has_been_redefined()) {
 812       ik->purge_previous_version_list();
 813     }
 814   }
 815 
 816   static bool has_previous_versions_and_reset();
 817   static bool has_previous_versions() { return _has_previous_versions; }
 818 
 819   // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation


 955 
 956   // On-stack replacement support
 957   nmethod* osr_nmethods_head() const         { return _osr_nmethods_head; };
 958   void set_osr_nmethods_head(nmethod* h)     { _osr_nmethods_head = h; };
 959   void add_osr_nmethod(nmethod* n);
 960   bool remove_osr_nmethod(nmethod* n);
 961   int mark_osr_nmethods(const Method* m);
 962   nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const;
 963 
 964 #if INCLUDE_JVMTI
 965   // Breakpoint support (see methods on Method* for details)
 966   BreakpointInfo* breakpoints() const       { return _breakpoints; };
 967   void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; };
 968 #endif
 969 
 970   // support for stub routines
 971   static ByteSize init_state_offset()  { return in_ByteSize(offset_of(InstanceKlass, _init_state)); }
 972   JFR_ONLY(DEFINE_KLASS_TRACE_ID_OFFSET;)
 973   static ByteSize init_thread_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_thread)); }
 974 


 975   // subclass/subinterface checks
 976   bool implements_interface(Klass* k) const;
 977   bool is_same_or_direct_interface(Klass* k) const;
 978 
 979 #ifdef ASSERT
 980   // check whether this class or one of its superclasses was redefined
 981   bool has_redefined_this_or_super() const;
 982 #endif
 983 
 984   // Access to the implementor of an interface.
 985   Klass* implementor() const;
 986   void set_implementor(Klass* k);
 987   int  nof_implementors() const;
 988   void add_implementor(Klass* k);  // k is a new class that implements this interface
 989   void init_implementor();           // initialize
 990 
 991   // link this class into the implementors list of every interface it implements
 992   void process_interfaces(Thread *thread);
 993 
 994   // virtual operations from Klass
 995   bool is_leaf_class() const               { return _subklass == NULL; }
 996   GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
 997                                                   Array<InstanceKlass*>* transitive_interfaces);
 998   bool can_be_primary_super_slow() const;
 999   int oop_size(oop obj)  const             { return size_helper(); }
1000   // slow because it's a virtual call and used for verifying the layout_helper.
1001   // Using the layout_helper bits, we can call is_instance_klass without a virtual call.
1002   DEBUG_ONLY(bool is_instance_klass_slow() const      { return true; })
1003 
1004   // Iterators
1005   void do_local_static_fields(FieldClosure* cl);
1006   void do_nonstatic_fields(FieldClosure* cl); // including inherited fields
1007   void do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle, TRAPS);
1008 
1009   void methods_do(void f(Method* method));
1010   void array_klasses_do(void f(Klass* k));
1011   void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);
1012 
1013   static InstanceKlass* cast(Klass* k) {
1014     return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1015   }
1016 
1017   static const InstanceKlass* cast(const Klass* k) {
1018     assert(k != NULL, "k should not be null");
1019     assert(k->is_instance_klass(), "cast to InstanceKlass");
1020     return static_cast<const InstanceKlass*>(k);
1021   }
1022 
1023   virtual InstanceKlass* java_super() const {
1024     return (super() == NULL) ? NULL : cast(super());
1025   }
1026 
1027   // Sizing (in words)
1028   static int header_size()            { return sizeof(InstanceKlass)/wordSize; }
1029 
1030   static int size(int vtable_length, int itable_length,
1031                   int nonstatic_oop_map_size,
1032                   bool is_interface, bool is_unsafe_anonymous, bool has_stored_fingerprint) {

1033     return align_metadata_size(header_size() +
1034            vtable_length +
1035            itable_length +
1036            nonstatic_oop_map_size +
1037            (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1038            (is_unsafe_anonymous ? (int)sizeof(Klass*)/wordSize : 0) +
1039            (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0));


1040   }
1041   int size() const                    { return size(vtable_length(),
1042                                                itable_length(),
1043                                                nonstatic_oop_map_size(),
1044                                                is_interface(),
1045                                                is_unsafe_anonymous(),
1046                                                has_stored_fingerprint());


1047   }
1048 #if INCLUDE_SERVICES
1049   virtual void collect_statistics(KlassSizeStats *sz) const;
1050 #endif
1051 
1052   intptr_t* start_of_itable()   const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1053   intptr_t* end_of_itable()     const { return start_of_itable() + itable_length(); }
1054 
1055   int  itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1056 
1057   oop static_field_base_raw() { return java_mirror(); }
1058 


1059   OopMapBlock* start_of_nonstatic_oop_maps() const {
1060     return (OopMapBlock*)(start_of_itable() + itable_length());
1061   }
1062 
1063   Klass** end_of_nonstatic_oop_maps() const {
1064     return (Klass**)(start_of_nonstatic_oop_maps() +
1065                      nonstatic_oop_map_count());
1066   }
1067 
1068   Klass* volatile* adr_implementor() const {
1069     if (is_interface()) {
1070       return (Klass* volatile*)end_of_nonstatic_oop_maps();
1071     } else {
1072       return NULL;
1073     }
1074   };
1075 
1076   InstanceKlass** adr_unsafe_anonymous_host() const {
1077     if (is_unsafe_anonymous()) {
1078       InstanceKlass** adr_impl = (InstanceKlass**)adr_implementor();


1087   }
1088 
1089   address adr_fingerprint() const {
1090     if (has_stored_fingerprint()) {
1091       InstanceKlass** adr_host = adr_unsafe_anonymous_host();
1092       if (adr_host != NULL) {
1093         return (address)(adr_host + 1);
1094       }
1095 
1096       Klass* volatile* adr_impl = adr_implementor();
1097       if (adr_impl != NULL) {
1098         return (address)(adr_impl + 1);
1099       }
1100 
1101       return (address)end_of_nonstatic_oop_maps();
1102     } else {
1103       return NULL;
1104     }
1105   }
1106 













































1107   // Use this to return the size of an instance in heap words:
1108   int size_helper() const {
1109     return layout_helper_to_size_helper(layout_helper());
1110   }
1111 
1112   // This bit is initialized in classFileParser.cpp.
1113   // It is false under any of the following conditions:
1114   //  - the class is abstract (including any interface)
1115   //  - the class has a finalizer (if !RegisterFinalizersAtInit)
1116   //  - the class size is larger than FastAllocateSizeLimit
1117   //  - the class is java/lang/Class, which cannot be allocated directly
1118   bool can_be_fastpath_allocated() const {
1119     return !layout_helper_needs_slow_path(layout_helper());
1120   }
1121 
1122   // Java itable
1123   klassItable itable() const;        // return klassItable wrapper
1124   Method* method_at_itable(Klass* holder, int index, TRAPS);
1125 
1126 #if INCLUDE_JVMTI
1127   void adjust_default_methods(bool* trace_name_printed);
1128 #endif // INCLUDE_JVMTI


1137   // For RedefineClasses and class file parsing errors, we need to deallocate
1138   // instanceKlasses and the metadata they point to.
1139   void deallocate_contents(ClassLoaderData* loader_data);
1140   static void deallocate_methods(ClassLoaderData* loader_data,
1141                                  Array<Method*>* methods);
1142   void static deallocate_interfaces(ClassLoaderData* loader_data,
1143                                     const Klass* super_klass,
1144                                     Array<InstanceKlass*>* local_interfaces,
1145                                     Array<InstanceKlass*>* transitive_interfaces);
1146 
1147   // The constant pool is on stack if any of the methods are executing or
1148   // referenced by handles.
1149   bool on_stack() const { return _constants->on_stack(); }
1150 
1151   // callbacks for actions during class unloading
1152   static void unload_class(InstanceKlass* ik);
1153   static void release_C_heap_structures(InstanceKlass* ik);
1154 
1155   // Naming
1156   const char* signature_name() const;

1157   static Symbol* package_from_name(const Symbol* name, TRAPS);
1158 
1159   // Oop fields (and metadata) iterators
1160   //
1161   // The InstanceKlass iterators also visits the Object's klass.
1162 
1163   // Forward iteration
1164  public:
1165   // Iterate over all oop fields in the oop maps.
1166   template <typename T, class OopClosureType>
1167   inline void oop_oop_iterate_oop_maps(oop obj, OopClosureType* closure);
1168 
1169   // Iterate over all oop fields and metadata.
1170   template <typename T, class OopClosureType>
1171   inline void oop_oop_iterate(oop obj, OopClosureType* closure);
1172 
1173   // Iterate over all oop fields in one oop map.
1174   template <typename T, class OopClosureType>
1175   inline void oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure);
1176 


1230   inline jmethodID* methods_jmethod_ids_acquire() const;
1231   inline void release_set_methods_jmethod_ids(jmethodID* jmeths);
1232 
1233   // Lock during initialization
1234 public:
1235   // Lock for (1) initialization; (2) access to the ConstantPool of this class.
1236   // Must be one per class and it has to be a VM internal object so java code
1237   // cannot lock it (like the mirror).
1238   // It has to be an object not a Mutex because it's held through java calls.
1239   oop init_lock() const;
1240 private:
1241   void fence_and_clear_init_lock();
1242 
1243   bool link_class_impl                           (TRAPS);
1244   bool verify_code                               (TRAPS);
1245   void initialize_impl                           (TRAPS);
1246   void initialize_super_interfaces               (TRAPS);
1247   void eager_initialize_impl                     ();
1248   /* jni_id_for_impl for jfieldID only */
1249   JNIid* jni_id_for_impl                         (int offset);
1250 
1251   // Returns the array class for the n'th dimension
1252   Klass* array_klass_impl(bool or_null, int n, TRAPS);
1253 
1254   // Returns the array class with this class as element type
1255   Klass* array_klass_impl(bool or_null, TRAPS);


1256 
1257   // find a local method (returns NULL if not found)
1258   Method* find_method_impl(const Symbol* name,
1259                            const Symbol* signature,
1260                            OverpassLookupMode overpass_mode,
1261                            StaticLookupMode static_mode,
1262                            PrivateLookupMode private_mode) const;
1263 
1264   static Method* find_method_impl(const Array<Method*>* methods,
1265                                   const Symbol* name,
1266                                   const Symbol* signature,
1267                                   OverpassLookupMode overpass_mode,
1268                                   StaticLookupMode static_mode,
1269                                   PrivateLookupMode private_mode);
1270 
1271   // Free CHeap allocated fields.
1272   void release_C_heap_structures();
1273 
1274 #if INCLUDE_JVMTI
1275   // RedefineClasses support




   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OOPS_INSTANCEKLASS_HPP
  26 #define SHARE_OOPS_INSTANCEKLASS_HPP
  27 
  28 #include "classfile/classLoaderData.hpp"
  29 #include "code/vmreg.hpp"
  30 #include "memory/referenceType.hpp"
  31 #include "oops/annotations.hpp"
  32 #include "oops/constMethod.hpp"
  33 #include "oops/fieldInfo.hpp"
  34 #include "oops/instanceOop.hpp"
  35 #include "oops/klassVtable.hpp"
  36 #include "runtime/handles.hpp"
  37 #include "runtime/os.hpp"
  38 #include "utilities/accessFlags.hpp"
  39 #include "utilities/align.hpp"
  40 #include "utilities/macros.hpp"
  41 #if INCLUDE_JFR
  42 #include "jfr/support/jfrKlassExtension.hpp"
  43 #endif
  44 
  45 
  46 // An InstanceKlass is the VM level representation of a Java class.
  47 // It contains all information needed for at class at execution runtime.
  48 
  49 //  InstanceKlass embedded field layout (after declared fields):
  50 //    [EMBEDDED Java vtable             ] size in words = vtable_len
  51 //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
  52 //      The embedded nonstatic oop-map blocks are short pairs (offset, length)
  53 //      indicating where oops are located in instances of this klass.
  54 //    [EMBEDDED implementor of the interface] only exist for interface
  55 //    [EMBEDDED unsafe_anonymous_host klass] only exist for an unsafe anonymous class (JSR 292 enabled)
  56 //    [EMBEDDED fingerprint       ] only if should_store_fingerprint()==true
  57 //    [EMBEDDED ValueKlassFixedBlock] only if is a ValueKlass instance
  58 
  59 
  60 // forward declaration for class -- see below for definition
  61 #if INCLUDE_JVMTI
  62 class BreakpointInfo;
  63 #endif
  64 class ClassFileParser;
  65 class ClassFileStream;
  66 class KlassDepChange;
  67 class DependencyContext;
  68 class fieldDescriptor;
  69 class jniIdMapBase;
  70 class JNIid;
  71 class JvmtiCachedClassFieldMap;
  72 class nmethodBucket;
  73 class OopMapCache;
  74 class BufferedValueTypeBlob;
  75 class InterpreterOopMap;
  76 class PackageEntry;
  77 class ModuleEntry;
  78 
  79 // This is used in iterators below.
  80 class FieldClosure: public StackObj {
  81 public:
  82   virtual void do_field(fieldDescriptor* fd) = 0;
  83 };
  84 
  85 #ifndef PRODUCT
  86 // Print fields.
  87 // If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields.
  88 class FieldPrinter: public FieldClosure {
  89    oop _obj;
  90    outputStream* _st;
  91  public:
  92    FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {}
  93    void do_field(fieldDescriptor* fd);
  94 };
  95 #endif  // !PRODUCT
  96 
  97 // Describes where oops are located in instances of this klass.
  98 class OopMapBlock {
  99  public:
 100   // Byte offset of the first oop mapped by this block.
 101   int offset() const          { return _offset; }
 102   void set_offset(int offset) { _offset = offset; }
 103 
 104   // Number of oops in this block.
 105   uint count() const         { return _count; }
 106   void set_count(uint count) { _count = count; }
 107 
 108   void increment_count(int diff)     { _count += diff; }
 109 
 110   int offset_span() const { return _count * heapOopSize; }
 111 
 112   int end_offset() const {
 113     return offset() + offset_span();
 114   }
 115 
 116   bool is_contiguous(int another_offset) const {
 117     return another_offset == end_offset();
 118   }
 119 
 120   // sizeof(OopMapBlock) in words.
 121   static const int size_in_words() {
 122     return align_up((int)sizeof(OopMapBlock), wordSize) >>
 123       LogBytesPerWord;
 124   }
 125 
 126   static int compare_offset(const OopMapBlock* a, const OopMapBlock* b) {
 127     return a->offset() - b->offset();
 128   }
 129 
 130  private:
 131   int  _offset;
 132   uint _count;
 133 };
 134 
 135 struct JvmtiCachedClassFileData;
 136 
 137 class SigEntry;
 138 
 139 class ValueKlassFixedBlock {
 140   Array<SigEntry>** _extended_sig;
 141   Array<VMRegPair>** _return_regs;
 142   address* _pack_handler;
 143   address* _unpack_handler;
 144   int* _default_value_offset;
 145   Klass** _value_array_klass;
 146   int _alignment;
 147   int _first_field_offset;
 148   int _exact_size_in_bytes;
 149 
 150   friend class ValueKlass;
 151 };
 152 
 153 class ValueTypes {
 154 public:
 155   u2 _class_info_index;
 156   Symbol* _class_name;
 157 };
 158 
 159 class InstanceKlass: public Klass {
 160   friend class VMStructs;
 161   friend class JVMCIVMStructs;
 162   friend class ClassFileParser;
 163   friend class CompileReplay;
 164 
 165  public:
 166   static const KlassID ID = InstanceKlassID;
 167 
 168  protected:
 169   InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id = ID);
 170 
 171  public:
 172   InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
 173 
 174   // See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description
 175   // of the class loading & initialization procedure, and the use of the states.
 176   enum ClassState {
 177     allocated,                          // allocated (but not yet linked)
 178     loaded,                             // loaded and inserted in class hierarchy (but not linked yet)
 179     linked,                             // successfully linked/verified (but not initialized yet)
 180     being_initialized,                  // currently running class initializer
 181     fully_initialized,                  // initialized (successful final state)
 182     initialization_error                // error happened during initialization
 183   };
 184 
 185  private:
 186   static InstanceKlass* allocate_instance_klass(const ClassFileParser& parser, TRAPS);
 187 
 188  protected:
 189   // If you add a new field that points to any metaspace object, you
 190   // must add this field to InstanceKlass::metaspace_pointers_do().
 191 
 192   // Annotations for this class
 193   Annotations*    _annotations;
 194   // Package this class is defined in
 195   PackageEntry*   _package_entry;
 196   // Array classes holding elements of this class.
 197   Klass* volatile _array_klasses;
 198   // Constant pool for this class.
 199   ConstantPool* _constants;
 200   // The InnerClasses attribute and EnclosingMethod attribute. The
 201   // _inner_classes is an array of shorts. If the class has InnerClasses


 206   // last two shorts [class_index, method_index] of the array. If only
 207   // the InnerClasses attribute exists, the _inner_classes array length is
 208   // number_of_inner_classes * 4. If the class has both InnerClasses
 209   // and EnclosingMethod attributes the _inner_classes array length is
 210   // number_of_inner_classes * 4 + enclosing_method_attribute_size.
 211   Array<jushort>* _inner_classes;
 212 
 213   // The NestMembers attribute. An array of shorts, where each is a
 214   // class info index for the class that is a nest member. This data
 215   // has not been validated.
 216   Array<jushort>* _nest_members;
 217 
 218   // The NestHost attribute. The class info index for the class
 219   // that is the nest-host of this class. This data has not been validated.
 220   jushort _nest_host_index;
 221 
 222   // Resolved nest-host klass: either true nest-host or self if we are not nested.
 223   // By always being set it makes nest-member access checks simpler.
 224   InstanceKlass* _nest_host;
 225 
 226   Array<ValueTypes>* _value_types;
 227 
 228   // the source debug extension for this klass, NULL if not specified.
 229   // Specified as UTF-8 string without terminating zero byte in the classfile,
 230   // it is stored in the instanceklass as a NULL-terminated UTF-8 string
 231   const char*     _source_debug_extension;
 232   // Array name derived from this class which needs unreferencing
 233   // if this class is unloaded.
 234   Symbol*         _array_name;
 235 
 236   // Number of heapOopSize words used by non-static fields in this klass
 237   // (including inherited fields but after header_size()).
 238   int             _nonstatic_field_size;
 239   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
 240   // Constant pool index to the utf8 entry of the Generic signature,
 241   // or 0 if none.
 242   u2              _generic_signature_index;
 243   // Constant pool index to the utf8 entry for the name of source file
 244   // containing this klass, 0 if not specified.
 245   u2              _source_file_name_index;
 246   u2              _static_oop_field_count;// number of static oop fields in this klass
 247   u2              _java_fields_count;    // The number of declared Java fields
 248   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
 249 
 250   int             _itable_len;           // length of Java itable (in words)
 251   // _is_marked_dependent can be set concurrently, thus cannot be part of the
 252   // _misc_flags.
 253   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization

 254 
 255  public:
 256   enum {
 257     _extra_is_being_redefined   = 1 << 0, // used for locking redefinition
 258     _extra_has_resolved_methods = 1 << 1, // resolved methods table entries added for this class
 259     _extra_has_value_fields     = 1 << 2, // has value fields and related embedded section is not empty
 260     _extra_is_bufferable        = 1 << 3, // value can be buffered out side of the Java heap
 261     _extra_is_empty_value       = 1 << 4  // empty value type
 262   };
 263 
 264  protected:
 265   u1              _extra_flags;
 266 
 267   // The low three bits of _misc_flags contains the kind field.
 268   // This can be used to quickly discriminate among the five kinds of
 269   // InstanceKlass.
 270 
 271   static const unsigned _misc_kind_field_size = 3;
 272   static const unsigned _misc_kind_field_pos  = 0;
 273   static const unsigned _misc_kind_field_mask = (1u << _misc_kind_field_size) - 1u;
 274 
 275   static const unsigned _misc_kind_other        = 0; // concrete InstanceKlass
 276   static const unsigned _misc_kind_reference    = 1; // InstanceRefKlass
 277   static const unsigned _misc_kind_class_loader = 2; // InstanceClassLoaderKlass
 278   static const unsigned _misc_kind_mirror       = 3; // InstanceMirrorKlass
 279   static const unsigned _misc_kind_value_type   = 4; // ValueKlass
 280 
 281   // Start after _misc_kind field.
 282   enum {
 283     _misc_rewritten                           = 1 << 3,  // methods rewritten.
 284     _misc_has_nonstatic_fields                = 1 << 4,  // for sizing with UseCompressedOops
 285     _misc_should_verify_class                 = 1 << 5,  // allow caching of preverification
 286     _misc_is_unsafe_anonymous                 = 1 << 6,  // has embedded _unsafe_anonymous_host field
 287     _misc_is_contended                        = 1 << 7,  // marked with contended annotation
 288     _misc_has_nonstatic_concrete_methods      = 1 << 8,  // class/superclass/implemented interfaces has non-static, concrete methods
 289     _misc_declares_nonstatic_concrete_methods = 1 << 9,  // directly declares non-static, concrete methods
 290     _misc_has_been_redefined                  = 1 << 10,  // class has been redefined
 291     _misc_has_passed_fingerprint_check        = 1 << 11, // when this class was loaded, the fingerprint computed from its
 292                                                          // code source was found to be matching the value recorded by AOT.
 293     _misc_is_scratch_class                    = 1 << 12, // class is the redefined scratch class
 294     _misc_is_shared_boot_class                = 1 << 13, // defining class loader is boot class loader
 295     _misc_is_shared_platform_class            = 1 << 14, // defining class loader is platform class loader
 296     _misc_is_shared_app_class                 = 1 << 15  // defining class loader is app class loader
 297     // u2 _misc_flags full (see _extra_flags)
 298   };
 299   u2 loader_type_bits() {
 300     return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
 301   }
 302   u2              _misc_flags;
 303   u2              _minor_version;        // minor version number of class file
 304   u2              _major_version;        // major version number of class file
 305   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recursive initialization)
 306   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
 307   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
 308   jmethodID*      volatile _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
 309   nmethodBucket*  volatile _dep_context;          // packed DependencyContext structure
 310   uint64_t        volatile _dep_context_last_cleaned;
 311   nmethod*        _osr_nmethods_head;    // Head of list of on-stack replacement nmethods for this class
 312 #if INCLUDE_JVMTI
 313   BreakpointInfo* _breakpoints;          // bpt lists, managed by Method*
 314   // Linked instanceKlasses of previous versions
 315   InstanceKlass* _previous_versions;
 316   // JVMTI fields can be moved to their own structure - see 6315920
 317   // JVMTI: cached class file, before retransformable agent modified it in CFLH


 345   Array<int>*     _method_ordering;
 346   // Int array containing the vtable_indices for default_methods
 347   // offset matches _default_methods offset
 348   Array<int>*     _default_vtable_indices;
 349 
 350   // Instance and static variable information, starts with 6-tuples of shorts
 351   // [access, name index, sig index, initval index, low_offset, high_offset]
 352   // for all fields, followed by the generic signature data at the end of
 353   // the array. Only fields with generic signature attributes have the generic
 354   // signature data set in the array. The fields array looks like following:
 355   //
 356   // f1: [access, name index, sig index, initial value index, low_offset, high_offset]
 357   // f2: [access, name index, sig index, initial value index, low_offset, high_offset]
 358   //      ...
 359   // fn: [access, name index, sig index, initial value index, low_offset, high_offset]
 360   //     [generic signature index]
 361   //     [generic signature index]
 362   //     ...
 363   Array<u2>*      _fields;
 364 
 365   const ValueKlassFixedBlock* _adr_valueklass_fixed_block;
 366 
 367   // embedded Java vtable follows here
 368   // embedded Java itables follows here
 369   // embedded static fields follows here
 370   // embedded nonstatic oop-map blocks follows here
 371   // embedded implementor of this interface follows here
 372   //   The embedded implementor only exists if the current klass is an
 373   //   iterface. The possible values of the implementor fall into following
 374   //   three cases:
 375   //     NULL: no implementor.
 376   //     A Klass* that's not itself: one implementor.
 377   //     Itself: more than one implementors.
 378   // embedded unsafe_anonymous_host klass follows here
 379   //   The embedded host klass only exists in an unsafe anonymous class for
 380   //   dynamic language support (JSR 292 enabled). The host class grants
 381   //   its access privileges to this class also. The host class is either
 382   //   named, or a previously loaded unsafe anonymous class. A non-anonymous class
 383   //   or an anonymous class loaded through normal classloading does not
 384   //   have this embedded field.
 385   //
 386 


 401     return (_misc_flags & _misc_is_shared_app_class) != 0;
 402   }
 403 
 404   void clear_class_loader_type() {
 405     _misc_flags &= ~loader_type_bits();
 406   }
 407 
 408   void set_class_loader_type(s2 loader_type);
 409 
 410   bool has_nonstatic_fields() const        {
 411     return (_misc_flags & _misc_has_nonstatic_fields) != 0;
 412   }
 413   void set_has_nonstatic_fields(bool b)    {
 414     if (b) {
 415       _misc_flags |= _misc_has_nonstatic_fields;
 416     } else {
 417       _misc_flags &= ~_misc_has_nonstatic_fields;
 418     }
 419   }
 420 
 421   bool has_value_fields() const          {
 422     return (_extra_flags & _extra_has_value_fields) != 0;
 423   }
 424   void set_has_value_fields()  {
 425     _extra_flags |= _extra_has_value_fields;
 426   }
 427 
 428   bool is_empty_value() const {
 429     return (_extra_flags & _extra_is_empty_value) != 0;
 430   }
 431   void set_is_empty_value() {
 432     _extra_flags |= _extra_is_empty_value;
 433   }
 434 
 435   // field sizes
 436   int nonstatic_field_size() const         { return _nonstatic_field_size; }
 437   void set_nonstatic_field_size(int size)  { _nonstatic_field_size = size; }
 438 
 439   int static_field_size() const            { return _static_field_size; }
 440   void set_static_field_size(int size)     { _static_field_size = size; }
 441 
 442   int static_oop_field_count() const       { return (int)_static_oop_field_count; }
 443   void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
 444 
 445   // Java itable
 446   int  itable_length() const               { return _itable_len; }
 447   void set_itable_length(int len)          { _itable_len = len; }
 448 
 449   // array klasses
 450   Klass* array_klasses() const             { return _array_klasses; }
 451   inline Klass* array_klasses_acquire() const; // load with acquire semantics
 452   void set_array_klasses(Klass* k)         { _array_klasses = k; }
 453   inline void release_set_array_klasses(Klass* k); // store with release semantics
 454 


 477   Array<InstanceKlass*>* local_interfaces() const          { return _local_interfaces; }
 478   void set_local_interfaces(Array<InstanceKlass*>* a)      {
 479     guarantee(_local_interfaces == NULL || a == NULL, "Just checking");
 480     _local_interfaces = a; }
 481 
 482   Array<InstanceKlass*>* transitive_interfaces() const     { return _transitive_interfaces; }
 483   void set_transitive_interfaces(Array<InstanceKlass*>* a) {
 484     guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");
 485     _transitive_interfaces = a;
 486   }
 487 
 488  private:
 489   friend class fieldDescriptor;
 490   FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
 491 
 492  public:
 493   int     field_offset      (int index) const { return field(index)->offset(); }
 494   int     field_access_flags(int index) const { return field(index)->access_flags(); }
 495   Symbol* field_name        (int index) const { return field(index)->name(constants()); }
 496   Symbol* field_signature   (int index) const { return field(index)->signature(constants()); }
 497   bool    field_is_flattened(int index) const { return field(index)->is_flattened(); }
 498   bool    field_is_flattenable(int index) const { return field(index)->is_flattenable(); }
 499 
 500   // Number of Java declared fields
 501   int java_fields_count() const           { return (int)_java_fields_count; }
 502 
 503   Array<u2>* fields() const            { return _fields; }
 504   void set_fields(Array<u2>* f, u2 java_fields_count) {
 505     guarantee(_fields == NULL || f == NULL, "Just checking");
 506     _fields = f;
 507     _java_fields_count = java_fields_count;
 508   }
 509 
 510   // inner classes
 511   Array<u2>* inner_classes() const       { return _inner_classes; }
 512   void set_inner_classes(Array<u2>* f)   { _inner_classes = f; }
 513 
 514   // nest members
 515   Array<u2>* nest_members() const     { return _nest_members; }
 516   void set_nest_members(Array<u2>* m) { _nest_members = m; }
 517 
 518   // nest-host index


 578   bool is_reentrant_initialization(Thread *thread)  { return thread == _init_thread; }
 579   ClassState  init_state()                 { return (ClassState)_init_state; }
 580   bool is_rewritten() const                { return (_misc_flags & _misc_rewritten) != 0; }
 581 
 582   // defineClass specified verification
 583   bool should_verify_class() const         {
 584     return (_misc_flags & _misc_should_verify_class) != 0;
 585   }
 586   void set_should_verify_class(bool value) {
 587     if (value) {
 588       _misc_flags |= _misc_should_verify_class;
 589     } else {
 590       _misc_flags &= ~_misc_should_verify_class;
 591     }
 592   }
 593 
 594   // marking
 595   bool is_marked_dependent() const         { return _is_marked_dependent; }
 596   void set_is_marked_dependent(bool value) { _is_marked_dependent = value; }
 597 
 598   static ByteSize extra_flags_offset() { return in_ByteSize(offset_of(InstanceKlass, _extra_flags)); }
 599 
 600   // initialization (virtuals from Klass)
 601   bool should_be_initialized() const;  // means that initialize should be called
 602   void initialize(TRAPS);
 603   void link_class(TRAPS);
 604   bool link_class_or_fail(TRAPS); // returns false on failure
 605   void rewrite_class(TRAPS);
 606   void link_methods(TRAPS);
 607   Method* class_initializer() const;
 608 
 609   // set the class to initialized if no static initializer is present
 610   void eager_initialize(Thread *thread);
 611 
 612   // reference type
 613   ReferenceType reference_type() const     { return (ReferenceType)_reference_type; }
 614   void set_reference_type(ReferenceType t) {
 615     assert(t == (u1)t, "overflow");
 616     _reference_type = (u1)t;
 617   }
 618 
 619   // this class cp index
 620   u2 this_class_index() const             { return _this_class_index; }
 621   void set_this_class_index(u2 index)     { _this_class_index = index; }
 622 
 623   static ByteSize reference_type_offset() { return in_ByteSize(offset_of(InstanceKlass, _reference_type)); }
 624 
 625   // find local field, returns true if found
 626   bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 627   // find field in direct superinterfaces, returns the interface in which the field is defined
 628   Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 629   // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
 630   Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 631   // find instance or static fields according to JVM spec 5.4.3.2, returns the klass in which the field is defined
 632   Klass* find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const;
 633 
 634   // find a non-static or static field given its offset within the class.
 635   bool contains_field_offset(int offset) {
 636     return instanceOopDesc::contains_field_offset(offset, nonstatic_field_size(), is_value());
 637   }
 638 
 639   bool find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
 640   bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
 641 
 642   // find a local method (returns NULL if not found)
 643   Method* find_method(const Symbol* name, const Symbol* signature) const;
 644   static Method* find_method(const Array<Method*>* methods,
 645                              const Symbol* name,
 646                              const Symbol* signature);
 647 
 648   // find a local method, but skip static methods
 649   Method* find_instance_method(const Symbol* name, const Symbol* signature,
 650                                PrivateLookupMode private_mode = find_private) const;
 651   static Method* find_instance_method(const Array<Method*>* methods,
 652                                       const Symbol* name,
 653                                       const Symbol* signature,
 654                                       PrivateLookupMode private_mode = find_private);
 655 
 656   // find a local method (returns NULL if not found)


 773   void set_source_debug_extension(const char* array, int length);
 774 
 775   // symbol unloading support (refcount already added)
 776   Symbol* array_name()                     { return _array_name; }
 777   void set_array_name(Symbol* name)        { assert(_array_name == NULL  || name == NULL, "name already created"); _array_name = name; }
 778 
 779   // nonstatic oop-map blocks
 780   static int nonstatic_oop_map_size(unsigned int oop_map_count) {
 781     return oop_map_count * OopMapBlock::size_in_words();
 782   }
 783   unsigned int nonstatic_oop_map_count() const {
 784     return _nonstatic_oop_map_size / OopMapBlock::size_in_words();
 785   }
 786   int nonstatic_oop_map_size() const { return _nonstatic_oop_map_size; }
 787   void set_nonstatic_oop_map_size(int words) {
 788     _nonstatic_oop_map_size = words;
 789   }
 790 
 791 #if INCLUDE_JVMTI
 792   // Redefinition locking.  Class can only be redefined by one thread at a time.
 793   bool is_being_redefined() const          {
 794     return (_extra_flags & _extra_is_being_redefined);
 795   }
 796   void set_is_being_redefined(bool value)  {
 797     if (value) {
 798       _extra_flags |= _extra_is_being_redefined;
 799     } else {
 800       _extra_flags &= ~_extra_is_being_redefined;
 801     }
 802   }
 803 
 804   // RedefineClasses() support for previous versions:
 805   void add_previous_version(InstanceKlass* ik, int emcp_method_count);
 806   void purge_previous_version_list();
 807 
 808   InstanceKlass* previous_versions() const { return _previous_versions; }
 809 #else
 810   InstanceKlass* previous_versions() const { return NULL; }
 811 #endif
 812 
 813   InstanceKlass* get_klass_version(int version) {
 814     for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) {
 815       if (ik->constants()->version() == version) {
 816         return ik;
 817       }
 818     }
 819     return NULL;
 820   }
 821 
 822   bool has_been_redefined() const {


 836       _misc_flags &= ~_misc_has_passed_fingerprint_check;
 837     }
 838   }
 839   bool supers_have_passed_fingerprint_checks();
 840 
 841   static bool should_store_fingerprint(bool is_unsafe_anonymous);
 842   bool should_store_fingerprint() const { return should_store_fingerprint(is_unsafe_anonymous()); }
 843   bool has_stored_fingerprint() const;
 844   uint64_t get_stored_fingerprint() const;
 845   void store_fingerprint(uint64_t fingerprint);
 846 
 847   bool is_scratch_class() const {
 848     return (_misc_flags & _misc_is_scratch_class) != 0;
 849   }
 850 
 851   void set_is_scratch_class() {
 852     _misc_flags |= _misc_is_scratch_class;
 853   }
 854 
 855   bool has_resolved_methods() const {
 856     return (_extra_flags & _extra_has_resolved_methods) != 0;
 857   }
 858 
 859   void set_has_resolved_methods() {
 860     _extra_flags |= _extra_has_resolved_methods;
 861   }
 862 private:
 863 
 864   void set_kind(unsigned kind) {
 865     assert(kind <= _misc_kind_field_mask, "Invalid InstanceKlass kind");
 866     unsigned fmask = _misc_kind_field_mask << _misc_kind_field_pos;
 867     unsigned flags = _misc_flags & ~fmask;
 868     _misc_flags = (flags | (kind << _misc_kind_field_pos));
 869   }
 870 
 871   bool is_kind(unsigned desired) const {
 872     unsigned kind = (_misc_flags >> _misc_kind_field_pos) & _misc_kind_field_mask;
 873     return kind == desired;
 874   }
 875 
 876 public:
 877 
 878   // Other is anything that is not one of the more specialized kinds of InstanceKlass.
 879   bool is_other_instance_klass() const        { return is_kind(_misc_kind_other); }
 880   bool is_reference_instance_klass() const    { return is_kind(_misc_kind_reference); }
 881   bool is_mirror_instance_klass() const       { return is_kind(_misc_kind_mirror); }
 882   bool is_class_loader_instance_klass() const { return is_kind(_misc_kind_class_loader); }
 883   bool is_value_type_klass()            const { return is_kind(_misc_kind_value_type); }
 884 
 885 #if INCLUDE_JVMTI
 886 
 887   void init_previous_versions() {
 888     _previous_versions = NULL;
 889   }
 890 
 891  private:
 892   static bool  _has_previous_versions;
 893  public:
 894   static void purge_previous_versions(InstanceKlass* ik) {
 895     if (ik->has_been_redefined()) {
 896       ik->purge_previous_version_list();
 897     }
 898   }
 899 
 900   static bool has_previous_versions_and_reset();
 901   static bool has_previous_versions() { return _has_previous_versions; }
 902 
 903   // JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation


1039 
1040   // On-stack replacement support
1041   nmethod* osr_nmethods_head() const         { return _osr_nmethods_head; };
1042   void set_osr_nmethods_head(nmethod* h)     { _osr_nmethods_head = h; };
1043   void add_osr_nmethod(nmethod* n);
1044   bool remove_osr_nmethod(nmethod* n);
1045   int mark_osr_nmethods(const Method* m);
1046   nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const;
1047 
1048 #if INCLUDE_JVMTI
1049   // Breakpoint support (see methods on Method* for details)
1050   BreakpointInfo* breakpoints() const       { return _breakpoints; };
1051   void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; };
1052 #endif
1053 
1054   // support for stub routines
1055   static ByteSize init_state_offset()  { return in_ByteSize(offset_of(InstanceKlass, _init_state)); }
1056   JFR_ONLY(DEFINE_KLASS_TRACE_ID_OFFSET;)
1057   static ByteSize init_thread_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_thread)); }
1058 
1059   static ByteSize adr_valueklass_fixed_block_offset() { return in_ByteSize(offset_of(InstanceKlass, _adr_valueklass_fixed_block)); }
1060 
1061   // subclass/subinterface checks
1062   bool implements_interface(Klass* k) const;
1063   bool is_same_or_direct_interface(Klass* k) const;
1064 
1065 #ifdef ASSERT
1066   // check whether this class or one of its superclasses was redefined
1067   bool has_redefined_this_or_super() const;
1068 #endif
1069 
1070   // Access to the implementor of an interface.
1071   Klass* implementor() const;
1072   void set_implementor(Klass* k);
1073   int  nof_implementors() const;
1074   void add_implementor(Klass* k);  // k is a new class that implements this interface
1075   void init_implementor();           // initialize
1076 
1077   // link this class into the implementors list of every interface it implements
1078   void process_interfaces(Thread *thread);
1079 
1080   // virtual operations from Klass
1081   bool is_leaf_class() const               { return _subklass == NULL; }
1082   GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,
1083                                                   Array<InstanceKlass*>* transitive_interfaces);
1084   bool can_be_primary_super_slow() const;
1085   int oop_size(oop obj)  const             { return size_helper(); }
1086   // slow because it's a virtual call and used for verifying the layout_helper.
1087   // Using the layout_helper bits, we can call is_instance_klass without a virtual call.
1088   DEBUG_ONLY(bool is_instance_klass_slow() const      { return true; })
1089 
1090   // Iterators
1091   void do_local_static_fields(FieldClosure* cl);
1092   void do_nonstatic_fields(FieldClosure* cl); // including inherited fields
1093   void do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle, TRAPS);
1094 
1095   void methods_do(void f(Method* method));
1096   virtual void array_klasses_do(void f(Klass* k));

1097 
1098   static InstanceKlass* cast(Klass* k) {
1099     return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1100   }
1101 
1102   static const InstanceKlass* cast(const Klass* k) {
1103     assert(k != NULL, "k should not be null");
1104     assert(k->is_instance_klass(), "cast to InstanceKlass");
1105     return static_cast<const InstanceKlass*>(k);
1106   }
1107 
1108   virtual InstanceKlass* java_super() const {
1109     return (super() == NULL) ? NULL : cast(super());
1110   }
1111 
1112   // Sizing (in words)
1113   static int header_size()            { return sizeof(InstanceKlass)/wordSize; }
1114 
1115   static int size(int vtable_length, int itable_length,
1116                   int nonstatic_oop_map_size,
1117                   bool is_interface, bool is_unsafe_anonymous, bool has_stored_fingerprint,
1118                   int java_fields, bool is_value_type) {
1119     return align_metadata_size(header_size() +
1120            vtable_length +
1121            itable_length +
1122            nonstatic_oop_map_size +
1123            (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1124            (is_unsafe_anonymous ? (int)sizeof(Klass*)/wordSize : 0) +
1125            (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0) +
1126            (java_fields * (int)sizeof(Klass*)/wordSize) +
1127            (is_value_type ? (int)sizeof(ValueKlassFixedBlock) : 0));
1128   }
1129   int size() const                    { return size(vtable_length(),
1130                                                itable_length(),
1131                                                nonstatic_oop_map_size(),
1132                                                is_interface(),
1133                                                is_unsafe_anonymous(),
1134                                                has_stored_fingerprint(),
1135                                                has_value_fields() ? java_fields_count() : 0,
1136                                                is_value());
1137   }
1138 #if INCLUDE_SERVICES
1139   virtual void collect_statistics(KlassSizeStats *sz) const;
1140 #endif
1141 
1142   intptr_t* start_of_itable()   const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1143   intptr_t* end_of_itable()     const { return start_of_itable() + itable_length(); }
1144 
1145   int  itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1146 
1147   oop static_field_base_raw() { return java_mirror(); }
1148 
1149   bool bounds_check(address addr, bool edge_ok = false, intptr_t size_in_bytes = -1) const PRODUCT_RETURN0;
1150 
1151   OopMapBlock* start_of_nonstatic_oop_maps() const {
1152     return (OopMapBlock*)(start_of_itable() + itable_length());
1153   }
1154 
1155   Klass** end_of_nonstatic_oop_maps() const {
1156     return (Klass**)(start_of_nonstatic_oop_maps() +
1157                      nonstatic_oop_map_count());
1158   }
1159 
1160   Klass* volatile* adr_implementor() const {
1161     if (is_interface()) {
1162       return (Klass* volatile*)end_of_nonstatic_oop_maps();
1163     } else {
1164       return NULL;
1165     }
1166   };
1167 
1168   InstanceKlass** adr_unsafe_anonymous_host() const {
1169     if (is_unsafe_anonymous()) {
1170       InstanceKlass** adr_impl = (InstanceKlass**)adr_implementor();


1179   }
1180 
1181   address adr_fingerprint() const {
1182     if (has_stored_fingerprint()) {
1183       InstanceKlass** adr_host = adr_unsafe_anonymous_host();
1184       if (adr_host != NULL) {
1185         return (address)(adr_host + 1);
1186       }
1187 
1188       Klass* volatile* adr_impl = adr_implementor();
1189       if (adr_impl != NULL) {
1190         return (address)(adr_impl + 1);
1191       }
1192 
1193       return (address)end_of_nonstatic_oop_maps();
1194     } else {
1195       return NULL;
1196     }
1197   }
1198 
1199   address adr_value_fields_klasses() const {
1200     if (has_value_fields()) {
1201       address adr_fing = adr_fingerprint();
1202       if (adr_fing != NULL) {
1203         return adr_fingerprint() + sizeof(u8);
1204       }
1205 
1206       InstanceKlass** adr_host = adr_unsafe_anonymous_host();
1207       if (adr_host != NULL) {
1208         return (address)(adr_host + 1);
1209       }
1210 
1211       Klass* volatile* adr_impl = adr_implementor();
1212       if (adr_impl != NULL) {
1213         return (address)(adr_impl + 1);
1214       }
1215 
1216       return (address)end_of_nonstatic_oop_maps();
1217     } else {
1218       return NULL;
1219     }
1220   }
1221 
1222   Klass* get_value_field_klass(int idx) const {
1223     assert(has_value_fields(), "Sanity checking");
1224     Klass* k = ((Klass**)adr_value_fields_klasses())[idx];
1225     assert(k != NULL, "Should always be set before being read");
1226     assert(k->is_value(), "Must be a value type");
1227     return k;
1228   }
1229 
1230   Klass* get_value_field_klass_or_null(int idx) const {
1231     assert(has_value_fields(), "Sanity checking");
1232     Klass* k = ((Klass**)adr_value_fields_klasses())[idx];
1233     assert(k == NULL || k->is_value(), "Must be a value type");
1234     return k;
1235   }
1236 
1237   void set_value_field_klass(int idx, Klass* k) {
1238     assert(has_value_fields(), "Sanity checking");
1239     assert(k != NULL, "Should not be set to NULL");
1240     assert(((Klass**)adr_value_fields_klasses())[idx] == NULL, "Should not be set twice");
1241     ((Klass**)adr_value_fields_klasses())[idx] = k;
1242   }
1243 
1244   // Use this to return the size of an instance in heap words:
1245   virtual int size_helper() const {
1246     return layout_helper_to_size_helper(layout_helper());
1247   }
1248 
1249   // This bit is initialized in classFileParser.cpp.
1250   // It is false under any of the following conditions:
1251   //  - the class is abstract (including any interface)
1252   //  - the class has a finalizer (if !RegisterFinalizersAtInit)
1253   //  - the class size is larger than FastAllocateSizeLimit
1254   //  - the class is java/lang/Class, which cannot be allocated directly
1255   bool can_be_fastpath_allocated() const {
1256     return !layout_helper_needs_slow_path(layout_helper());
1257   }
1258 
1259   // Java itable
1260   klassItable itable() const;        // return klassItable wrapper
1261   Method* method_at_itable(Klass* holder, int index, TRAPS);
1262 
1263 #if INCLUDE_JVMTI
1264   void adjust_default_methods(bool* trace_name_printed);
1265 #endif // INCLUDE_JVMTI


1274   // For RedefineClasses and class file parsing errors, we need to deallocate
1275   // instanceKlasses and the metadata they point to.
1276   void deallocate_contents(ClassLoaderData* loader_data);
1277   static void deallocate_methods(ClassLoaderData* loader_data,
1278                                  Array<Method*>* methods);
1279   void static deallocate_interfaces(ClassLoaderData* loader_data,
1280                                     const Klass* super_klass,
1281                                     Array<InstanceKlass*>* local_interfaces,
1282                                     Array<InstanceKlass*>* transitive_interfaces);
1283 
1284   // The constant pool is on stack if any of the methods are executing or
1285   // referenced by handles.
1286   bool on_stack() const { return _constants->on_stack(); }
1287 
1288   // callbacks for actions during class unloading
1289   static void unload_class(InstanceKlass* ik);
1290   static void release_C_heap_structures(InstanceKlass* ik);
1291 
1292   // Naming
1293   const char* signature_name() const;
1294   const char* signature_name_of(char c) const;
1295   static Symbol* package_from_name(const Symbol* name, TRAPS);
1296 
1297   // Oop fields (and metadata) iterators
1298   //
1299   // The InstanceKlass iterators also visits the Object's klass.
1300 
1301   // Forward iteration
1302  public:
1303   // Iterate over all oop fields in the oop maps.
1304   template <typename T, class OopClosureType>
1305   inline void oop_oop_iterate_oop_maps(oop obj, OopClosureType* closure);
1306 
1307   // Iterate over all oop fields and metadata.
1308   template <typename T, class OopClosureType>
1309   inline void oop_oop_iterate(oop obj, OopClosureType* closure);
1310 
1311   // Iterate over all oop fields in one oop map.
1312   template <typename T, class OopClosureType>
1313   inline void oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure);
1314 


1368   inline jmethodID* methods_jmethod_ids_acquire() const;
1369   inline void release_set_methods_jmethod_ids(jmethodID* jmeths);
1370 
1371   // Lock during initialization
1372 public:
1373   // Lock for (1) initialization; (2) access to the ConstantPool of this class.
1374   // Must be one per class and it has to be a VM internal object so java code
1375   // cannot lock it (like the mirror).
1376   // It has to be an object not a Mutex because it's held through java calls.
1377   oop init_lock() const;
1378 private:
1379   void fence_and_clear_init_lock();
1380 
1381   bool link_class_impl                           (TRAPS);
1382   bool verify_code                               (TRAPS);
1383   void initialize_impl                           (TRAPS);
1384   void initialize_super_interfaces               (TRAPS);
1385   void eager_initialize_impl                     ();
1386   /* jni_id_for_impl for jfieldID only */
1387   JNIid* jni_id_for_impl                         (int offset);
1388 protected:
1389   // Returns the array class for the n'th dimension
1390   virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int n, TRAPS);
1391 
1392   // Returns the array class with this class as element type
1393   virtual Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS);
1394 
1395 private:
1396 
1397   // find a local method (returns NULL if not found)
1398   Method* find_method_impl(const Symbol* name,
1399                            const Symbol* signature,
1400                            OverpassLookupMode overpass_mode,
1401                            StaticLookupMode static_mode,
1402                            PrivateLookupMode private_mode) const;
1403 
1404   static Method* find_method_impl(const Array<Method*>* methods,
1405                                   const Symbol* name,
1406                                   const Symbol* signature,
1407                                   OverpassLookupMode overpass_mode,
1408                                   StaticLookupMode static_mode,
1409                                   PrivateLookupMode private_mode);
1410 
1411   // Free CHeap allocated fields.
1412   void release_C_heap_structures();
1413 
1414 #if INCLUDE_JVMTI
1415   // RedefineClasses support


< prev index next >