Path: blob/master/src/hotspot/share/oops/instanceKlass.hpp
40951 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_OOPS_INSTANCEKLASS_HPP25#define SHARE_OOPS_INSTANCEKLASS_HPP2627#include "memory/referenceType.hpp"28#include "oops/annotations.hpp"29#include "oops/constMethod.hpp"30#include "oops/fieldInfo.hpp"31#include "oops/instanceOop.hpp"32#include "runtime/handles.hpp"33#include "utilities/accessFlags.hpp"34#include "utilities/align.hpp"35#include "utilities/macros.hpp"36#if INCLUDE_JFR37#include "jfr/support/jfrKlassExtension.hpp"38#endif3940class klassItable;41class RecordComponent;4243// An InstanceKlass is the VM level representation of a Java class.44// It contains all information needed for at class at execution runtime.4546// InstanceKlass embedded field layout (after declared fields):47// [EMBEDDED Java vtable ] size in words = vtable_len48// [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size49// The embedded nonstatic oop-map blocks are short pairs (offset, length)50// indicating where oops are located in instances of this klass.51// [EMBEDDED implementor of the interface] only exist for interface525354// forward declaration for class -- see below for definition55#if INCLUDE_JVMTI56class BreakpointInfo;57#endif58class ClassFileParser;59class ClassFileStream;60class KlassDepChange;61class DependencyContext;62class fieldDescriptor;63class jniIdMapBase;64class JNIid;65class JvmtiCachedClassFieldMap;66class nmethodBucket;67class OopMapCache;68class InterpreterOopMap;69class PackageEntry;70class ModuleEntry;7172// This is used in iterators below.73class FieldClosure: public StackObj {74public:75virtual void do_field(fieldDescriptor* fd) = 0;76};7778#ifndef PRODUCT79// Print fields.80// If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields.81class FieldPrinter: public FieldClosure {82oop _obj;83outputStream* _st;84public:85FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {}86void do_field(fieldDescriptor* fd);87};88#endif // !PRODUCT8990// Describes where oops are located in instances of this klass.91class OopMapBlock {92public:93// Byte offset of the first oop mapped by this block.94int offset() const { return _offset; }95void set_offset(int offset) { _offset = offset; }9697// Number of oops in this block.98uint count() const { return _count; }99void set_count(uint count) { _count = count; }100101void increment_count(int diff) { _count += diff; }102103int offset_span() const { return _count * heapOopSize; }104105int end_offset() const {106return offset() + offset_span();107}108109bool is_contiguous(int another_offset) const {110return another_offset == end_offset();111}112113// sizeof(OopMapBlock) in words.114static const int size_in_words() {115return align_up((int)sizeof(OopMapBlock), wordSize) >>116LogBytesPerWord;117}118119static int compare_offset(const OopMapBlock* a, const OopMapBlock* b) {120return a->offset() - b->offset();121}122123private:124int _offset;125uint _count;126};127128struct JvmtiCachedClassFileData;129130class InstanceKlass: public Klass {131friend class VMStructs;132friend class JVMCIVMStructs;133friend class ClassFileParser;134friend class CompileReplay;135136public:137static const KlassID ID = InstanceKlassID;138139protected:140InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id = ID);141142public:143InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }144145// See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description146// of the class loading & initialization procedure, and the use of the states.147enum ClassState {148allocated, // allocated (but not yet linked)149loaded, // loaded and inserted in class hierarchy (but not linked yet)150linked, // successfully linked/verified (but not initialized yet)151being_initialized, // currently running class initializer152fully_initialized, // initialized (successfull final state)153initialization_error // error happened during initialization154};155156private:157static InstanceKlass* allocate_instance_klass(const ClassFileParser& parser, TRAPS);158159protected:160// If you add a new field that points to any metaspace object, you161// must add this field to InstanceKlass::metaspace_pointers_do().162163// Annotations for this class164Annotations* _annotations;165// Package this class is defined in166PackageEntry* _package_entry;167// Array classes holding elements of this class.168ObjArrayKlass* volatile _array_klasses;169// Constant pool for this class.170ConstantPool* _constants;171// The InnerClasses attribute and EnclosingMethod attribute. The172// _inner_classes is an array of shorts. If the class has InnerClasses173// attribute, then the _inner_classes array begins with 4-tuples of shorts174// [inner_class_info_index, outer_class_info_index,175// inner_name_index, inner_class_access_flags] for the InnerClasses176// attribute. If the EnclosingMethod attribute exists, it occupies the177// last two shorts [class_index, method_index] of the array. If only178// the InnerClasses attribute exists, the _inner_classes array length is179// number_of_inner_classes * 4. If the class has both InnerClasses180// and EnclosingMethod attributes the _inner_classes array length is181// number_of_inner_classes * 4 + enclosing_method_attribute_size.182Array<jushort>* _inner_classes;183184// The NestMembers attribute. An array of shorts, where each is a185// class info index for the class that is a nest member. This data186// has not been validated.187Array<jushort>* _nest_members;188189// Resolved nest-host klass: either true nest-host or self if we are not190// nested, or an error occurred resolving or validating the nominated191// nest-host. Can also be set directly by JDK API's that establish nest192// relationships.193// By always being set it makes nest-member access checks simpler.194InstanceKlass* _nest_host;195196// The PermittedSubclasses attribute. An array of shorts, where each is a197// class info index for the class that is a permitted subclass.198Array<jushort>* _permitted_subclasses;199200// The contents of the Record attribute.201Array<RecordComponent*>* _record_components;202203// the source debug extension for this klass, NULL if not specified.204// Specified as UTF-8 string without terminating zero byte in the classfile,205// it is stored in the instanceklass as a NULL-terminated UTF-8 string206const char* _source_debug_extension;207208// Number of heapOopSize words used by non-static fields in this klass209// (including inherited fields but after header_size()).210int _nonstatic_field_size;211int _static_field_size; // number words used by static fields (oop and non-oop) in this klass212213int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks214int _itable_len; // length of Java itable (in words)215216// The NestHost attribute. The class info index for the class217// that is the nest-host of this class. This data has not been validated.218u2 _nest_host_index;219u2 _this_class_index; // constant pool entry220221u2 _static_oop_field_count;// number of static oop fields in this klass222u2 _java_fields_count; // The number of declared Java fields223224volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change225226// _is_marked_dependent can be set concurrently, thus cannot be part of the227// _misc_flags.228bool _is_marked_dependent; // used for marking during flushing and deoptimization229230// Class states are defined as ClassState (see above).231// Place the _init_state here to utilize the unused 2-byte after232// _idnum_allocated_count.233u1 _init_state; // state of class234235// This can be used to quickly discriminate among the four kinds of236// InstanceKlass. This should be an enum (?)237static const unsigned _kind_other = 0; // concrete InstanceKlass238static const unsigned _kind_reference = 1; // InstanceRefKlass239static const unsigned _kind_class_loader = 2; // InstanceClassLoaderKlass240static const unsigned _kind_mirror = 3; // InstanceMirrorKlass241242u1 _reference_type; // reference type243u1 _kind; // kind of InstanceKlass244245enum {246_misc_rewritten = 1 << 0, // methods rewritten.247_misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops248_misc_should_verify_class = 1 << 2, // allow caching of preverification249_misc_unused = 1 << 3, // not currently used250_misc_is_contended = 1 << 4, // marked with contended annotation251_misc_has_nonstatic_concrete_methods = 1 << 5, // class/superclass/implemented interfaces has non-static, concrete methods252_misc_declares_nonstatic_concrete_methods = 1 << 6, // directly declares non-static, concrete methods253_misc_has_been_redefined = 1 << 7, // class has been redefined254_unused = 1 << 8, //255_misc_is_scratch_class = 1 << 9, // class is the redefined scratch class256_misc_is_shared_boot_class = 1 << 10, // defining class loader is boot class loader257_misc_is_shared_platform_class = 1 << 11, // defining class loader is platform class loader258_misc_is_shared_app_class = 1 << 12, // defining class loader is app class loader259_misc_has_resolved_methods = 1 << 13, // resolved methods table entries added for this class260_misc_is_being_redefined = 1 << 14, // used for locking redefinition261_misc_has_contended_annotations = 1 << 15 // has @Contended annotation262};263u2 shared_loader_type_bits() const {264return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;265}266u2 _misc_flags; // There is more space in access_flags for more flags.267268Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization)269OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)270JNIid* _jni_ids; // First JNI identifier for static fields in this class271jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none272nmethodBucket* volatile _dep_context; // packed DependencyContext structure273uint64_t volatile _dep_context_last_cleaned;274nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class275#if INCLUDE_JVMTI276BreakpointInfo* _breakpoints; // bpt lists, managed by Method*277// Linked instanceKlasses of previous versions278InstanceKlass* _previous_versions;279// JVMTI fields can be moved to their own structure - see 6315920280// JVMTI: cached class file, before retransformable agent modified it in CFLH281JvmtiCachedClassFileData* _cached_class_file;282#endif283284#if INCLUDE_JVMTI285JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration286#endif287288NOT_PRODUCT(int _verify_count;) // to avoid redundant verifies289290// Method array.291Array<Method*>* _methods;292// Default Method Array, concrete methods inherited from interfaces293Array<Method*>* _default_methods;294// Interfaces (InstanceKlass*s) this class declares locally to implement.295Array<InstanceKlass*>* _local_interfaces;296// Interfaces (InstanceKlass*s) this class implements transitively.297Array<InstanceKlass*>* _transitive_interfaces;298// Int array containing the original order of method in the class file (for JVMTI).299Array<int>* _method_ordering;300// Int array containing the vtable_indices for default_methods301// offset matches _default_methods offset302Array<int>* _default_vtable_indices;303304// Instance and static variable information, starts with 6-tuples of shorts305// [access, name index, sig index, initval index, low_offset, high_offset]306// for all fields, followed by the generic signature data at the end of307// the array. Only fields with generic signature attributes have the generic308// signature data set in the array. The fields array looks like following:309//310// f1: [access, name index, sig index, initial value index, low_offset, high_offset]311// f2: [access, name index, sig index, initial value index, low_offset, high_offset]312// ...313// fn: [access, name index, sig index, initial value index, low_offset, high_offset]314// [generic signature index]315// [generic signature index]316// ...317Array<u2>* _fields;318319// embedded Java vtable follows here320// embedded Java itables follows here321// embedded static fields follows here322// embedded nonstatic oop-map blocks follows here323// embedded implementor of this interface follows here324// The embedded implementor only exists if the current klass is an325// interface. The possible values of the implementor fall into following326// three cases:327// NULL: no implementor.328// A Klass* that's not itself: one implementor.329// Itself: more than one implementors.330//331332friend class SystemDictionary;333334static bool _disable_method_binary_search;335336public:337// The three BUILTIN class loader types338bool is_shared_boot_class() const {339return (_misc_flags & _misc_is_shared_boot_class) != 0;340}341bool is_shared_platform_class() const {342return (_misc_flags & _misc_is_shared_platform_class) != 0;343}344bool is_shared_app_class() const {345return (_misc_flags & _misc_is_shared_app_class) != 0;346}347// The UNREGISTERED class loader type348bool is_shared_unregistered_class() const {349return (_misc_flags & shared_loader_type_bits()) == 0;350}351352// Check if the class can be shared in CDS353bool is_shareable() const;354355void clear_shared_class_loader_type() {356_misc_flags &= ~shared_loader_type_bits();357}358359void set_shared_class_loader_type(s2 loader_type);360361void assign_class_loader_type();362363bool has_nonstatic_fields() const {364return (_misc_flags & _misc_has_nonstatic_fields) != 0;365}366void set_has_nonstatic_fields(bool b) {367if (b) {368_misc_flags |= _misc_has_nonstatic_fields;369} else {370_misc_flags &= ~_misc_has_nonstatic_fields;371}372}373374// field sizes375int nonstatic_field_size() const { return _nonstatic_field_size; }376void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; }377378int static_field_size() const { return _static_field_size; }379void set_static_field_size(int size) { _static_field_size = size; }380381int static_oop_field_count() const { return (int)_static_oop_field_count; }382void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }383384// Java itable385int itable_length() const { return _itable_len; }386void set_itable_length(int len) { _itable_len = len; }387388// array klasses389ObjArrayKlass* array_klasses() const { return _array_klasses; }390inline ObjArrayKlass* array_klasses_acquire() const; // load with acquire semantics391void set_array_klasses(ObjArrayKlass* k) { _array_klasses = k; }392inline void release_set_array_klasses(ObjArrayKlass* k); // store with release semantics393394// methods395Array<Method*>* methods() const { return _methods; }396void set_methods(Array<Method*>* a) { _methods = a; }397Method* method_with_idnum(int idnum);398Method* method_with_orig_idnum(int idnum);399Method* method_with_orig_idnum(int idnum, int version);400401// method ordering402Array<int>* method_ordering() const { return _method_ordering; }403void set_method_ordering(Array<int>* m) { _method_ordering = m; }404void copy_method_ordering(const intArray* m, TRAPS);405406// default_methods407Array<Method*>* default_methods() const { return _default_methods; }408void set_default_methods(Array<Method*>* a) { _default_methods = a; }409410// default method vtable_indices411Array<int>* default_vtable_indices() const { return _default_vtable_indices; }412void set_default_vtable_indices(Array<int>* v) { _default_vtable_indices = v; }413Array<int>* create_new_default_vtable_indices(int len, TRAPS);414415// interfaces416Array<InstanceKlass*>* local_interfaces() const { return _local_interfaces; }417void set_local_interfaces(Array<InstanceKlass*>* a) {418guarantee(_local_interfaces == NULL || a == NULL, "Just checking");419_local_interfaces = a; }420421Array<InstanceKlass*>* transitive_interfaces() const { return _transitive_interfaces; }422void set_transitive_interfaces(Array<InstanceKlass*>* a) {423guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");424_transitive_interfaces = a;425}426427private:428friend class fieldDescriptor;429FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }430431public:432int field_offset (int index) const { return field(index)->offset(); }433int field_access_flags(int index) const { return field(index)->access_flags(); }434Symbol* field_name (int index) const { return field(index)->name(constants()); }435Symbol* field_signature (int index) const { return field(index)->signature(constants()); }436437// Number of Java declared fields438int java_fields_count() const { return (int)_java_fields_count; }439440Array<u2>* fields() const { return _fields; }441void set_fields(Array<u2>* f, u2 java_fields_count) {442guarantee(_fields == NULL || f == NULL, "Just checking");443_fields = f;444_java_fields_count = java_fields_count;445}446447// inner classes448Array<u2>* inner_classes() const { return _inner_classes; }449void set_inner_classes(Array<u2>* f) { _inner_classes = f; }450451// nest members452Array<u2>* nest_members() const { return _nest_members; }453void set_nest_members(Array<u2>* m) { _nest_members = m; }454455// nest-host index456jushort nest_host_index() const { return _nest_host_index; }457void set_nest_host_index(u2 i) { _nest_host_index = i; }458// dynamic nest member support459void set_nest_host(InstanceKlass* host);460461// record components462Array<RecordComponent*>* record_components() const { return _record_components; }463void set_record_components(Array<RecordComponent*>* record_components) {464_record_components = record_components;465}466bool is_record() const;467468// permitted subclasses469Array<u2>* permitted_subclasses() const { return _permitted_subclasses; }470void set_permitted_subclasses(Array<u2>* s) { _permitted_subclasses = s; }471472private:473// Called to verify that k is a member of this nest - does not look at k's nest-host,474// nor does it resolve any CP entries or load any classes.475bool has_nest_member(JavaThread* current, InstanceKlass* k) const;476477public:478// Used to construct informative IllegalAccessError messages at a higher level,479// if there was an issue resolving or validating the nest host.480// Returns NULL if there was no error.481const char* nest_host_error();482// Returns nest-host class, resolving and validating it if needed.483// Returns NULL if resolution is not possible from the calling context.484InstanceKlass* nest_host(TRAPS);485// Check if this klass is a nestmate of k - resolves this nest-host and k's486bool has_nestmate_access_to(InstanceKlass* k, TRAPS);487488// Called to verify that k is a permitted subclass of this class489bool has_as_permitted_subclass(const InstanceKlass* k) const;490491enum InnerClassAttributeOffset {492// From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814493inner_class_inner_class_info_offset = 0,494inner_class_outer_class_info_offset = 1,495inner_class_inner_name_offset = 2,496inner_class_access_flags_offset = 3,497inner_class_next_offset = 4498};499500enum EnclosingMethodAttributeOffset {501enclosing_method_class_index_offset = 0,502enclosing_method_method_index_offset = 1,503enclosing_method_attribute_size = 2504};505506// package507PackageEntry* package() const { return _package_entry; }508ModuleEntry* module() const;509bool in_unnamed_package() const { return (_package_entry == NULL); }510void set_package(ClassLoaderData* loader_data, PackageEntry* pkg_entry, TRAPS);511// If the package for the InstanceKlass is in the boot loader's package entry512// table then sets the classpath_index field so that513// get_system_package() will know to return a non-null value for the514// package's location. And, so that the package will be added to the list of515// packages returned by get_system_packages().516// For packages whose classes are loaded from the boot loader class path, the517// classpath_index indicates which entry on the boot loader class path.518void set_classpath_index(s2 path_index);519bool is_same_class_package(const Klass* class2) const;520bool is_same_class_package(oop other_class_loader, const Symbol* other_class_name) const;521522// find an enclosing class523InstanceKlass* compute_enclosing_class(bool* inner_is_member, TRAPS) const;524525// Find InnerClasses attribute and return outer_class_info_index & inner_name_index.526bool find_inner_classes_attr(int* ooff, int* noff, TRAPS) const;527528private:529// Check prohibited package ("java/" only loadable by boot or platform loaders)530static void check_prohibited_package(Symbol* class_name,531ClassLoaderData* loader_data,532TRAPS);533public:534// initialization state535bool is_loaded() const { return _init_state >= loaded; }536bool is_linked() const { return _init_state >= linked; }537bool is_initialized() const { return _init_state == fully_initialized; }538bool is_not_initialized() const { return _init_state < being_initialized; }539bool is_being_initialized() const { return _init_state == being_initialized; }540bool is_in_error_state() const { return _init_state == initialization_error; }541bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; }542ClassState init_state() { return (ClassState)_init_state; }543bool is_rewritten() const { return (_misc_flags & _misc_rewritten) != 0; }544545// is this a sealed class546bool is_sealed() const;547548// defineClass specified verification549bool should_verify_class() const {550return (_misc_flags & _misc_should_verify_class) != 0;551}552void set_should_verify_class(bool value) {553if (value) {554_misc_flags |= _misc_should_verify_class;555} else {556_misc_flags &= ~_misc_should_verify_class;557}558}559560// marking561bool is_marked_dependent() const { return _is_marked_dependent; }562void set_is_marked_dependent(bool value) { _is_marked_dependent = value; }563564// initialization (virtuals from Klass)565bool should_be_initialized() const; // means that initialize should be called566void initialize(TRAPS);567void link_class(TRAPS);568bool link_class_or_fail(TRAPS); // returns false on failure569void rewrite_class(TRAPS);570void link_methods(TRAPS);571Method* class_initializer() const;572573// set the class to initialized if no static initializer is present574void eager_initialize(Thread *thread);575576// reference type577ReferenceType reference_type() const { return (ReferenceType)_reference_type; }578void set_reference_type(ReferenceType t) {579assert(t == (u1)t, "overflow");580_reference_type = (u1)t;581}582583// this class cp index584u2 this_class_index() const { return _this_class_index; }585void set_this_class_index(u2 index) { _this_class_index = index; }586587static ByteSize reference_type_offset() { return in_ByteSize(offset_of(InstanceKlass, _reference_type)); }588589// find local field, returns true if found590bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;591// find field in direct superinterfaces, returns the interface in which the field is defined592Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;593// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined594Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;595// find instance or static fields according to JVM spec 5.4.3.2, returns the klass in which the field is defined596Klass* find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const;597598// find a non-static or static field given its offset within the class.599bool contains_field_offset(int offset);600601bool find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;602bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;603604private:605inline static int quick_search(const Array<Method*>* methods, const Symbol* name);606607public:608static void disable_method_binary_search() {609_disable_method_binary_search = true;610}611612// find a local method (returns NULL if not found)613Method* find_method(const Symbol* name, const Symbol* signature) const;614static Method* find_method(const Array<Method*>* methods,615const Symbol* name,616const Symbol* signature);617618// find a local method, but skip static methods619Method* find_instance_method(const Symbol* name, const Symbol* signature,620PrivateLookupMode private_mode) const;621static Method* find_instance_method(const Array<Method*>* methods,622const Symbol* name,623const Symbol* signature,624PrivateLookupMode private_mode);625626// find a local method (returns NULL if not found)627Method* find_local_method(const Symbol* name,628const Symbol* signature,629OverpassLookupMode overpass_mode,630StaticLookupMode static_mode,631PrivateLookupMode private_mode) const;632633// find a local method from given methods array (returns NULL if not found)634static Method* find_local_method(const Array<Method*>* methods,635const Symbol* name,636const Symbol* signature,637OverpassLookupMode overpass_mode,638StaticLookupMode static_mode,639PrivateLookupMode private_mode);640641// find a local method index in methods or default_methods (returns -1 if not found)642static int find_method_index(const Array<Method*>* methods,643const Symbol* name,644const Symbol* signature,645OverpassLookupMode overpass_mode,646StaticLookupMode static_mode,647PrivateLookupMode private_mode);648649// lookup operation (returns NULL if not found)650Method* uncached_lookup_method(const Symbol* name,651const Symbol* signature,652OverpassLookupMode overpass_mode,653PrivateLookupMode private_mode = PrivateLookupMode::find) const;654655// lookup a method in all the interfaces that this class implements656// (returns NULL if not found)657Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, DefaultsLookupMode defaults_mode) const;658659// lookup a method in local defaults then in all interfaces660// (returns NULL if not found)661Method* lookup_method_in_ordered_interfaces(Symbol* name, Symbol* signature) const;662663// Find method indices by name. If a method with the specified name is664// found the index to the first method is returned, and 'end' is filled in665// with the index of first non-name-matching method. If no method is found666// -1 is returned.667int find_method_by_name(const Symbol* name, int* end) const;668static int find_method_by_name(const Array<Method*>* methods,669const Symbol* name, int* end);670671// constant pool672ConstantPool* constants() const { return _constants; }673void set_constants(ConstantPool* c) { _constants = c; }674675// protection domain676oop protection_domain() const;677678// signers679objArrayOop signers() const;680681bool is_contended() const {682return (_misc_flags & _misc_is_contended) != 0;683}684void set_is_contended(bool value) {685if (value) {686_misc_flags |= _misc_is_contended;687} else {688_misc_flags &= ~_misc_is_contended;689}690}691692// source file name693Symbol* source_file_name() const { return _constants->source_file_name(); }694u2 source_file_name_index() const { return _constants->source_file_name_index(); }695void set_source_file_name_index(u2 sourcefile_index) { _constants->set_source_file_name_index(sourcefile_index); }696697// minor and major version numbers of class file698u2 minor_version() const { return _constants->minor_version(); }699void set_minor_version(u2 minor_version) { _constants->set_minor_version(minor_version); }700u2 major_version() const { return _constants->major_version(); }701void set_major_version(u2 major_version) { _constants->set_major_version(major_version); }702703// source debug extension704const char* source_debug_extension() const { return _source_debug_extension; }705void set_source_debug_extension(const char* array, int length);706707// nonstatic oop-map blocks708static int nonstatic_oop_map_size(unsigned int oop_map_count) {709return oop_map_count * OopMapBlock::size_in_words();710}711unsigned int nonstatic_oop_map_count() const {712return _nonstatic_oop_map_size / OopMapBlock::size_in_words();713}714int nonstatic_oop_map_size() const { return _nonstatic_oop_map_size; }715void set_nonstatic_oop_map_size(int words) {716_nonstatic_oop_map_size = words;717}718719bool has_contended_annotations() const {720return ((_misc_flags & _misc_has_contended_annotations) != 0);721}722void set_has_contended_annotations(bool value) {723if (value) {724_misc_flags |= _misc_has_contended_annotations;725} else {726_misc_flags &= ~_misc_has_contended_annotations;727}728}729730#if INCLUDE_JVMTI731// Redefinition locking. Class can only be redefined by one thread at a time.732bool is_being_redefined() const {733return ((_misc_flags & _misc_is_being_redefined) != 0);734}735void set_is_being_redefined(bool value) {736if (value) {737_misc_flags |= _misc_is_being_redefined;738} else {739_misc_flags &= ~_misc_is_being_redefined;740}741}742743// RedefineClasses() support for previous versions:744void add_previous_version(InstanceKlass* ik, int emcp_method_count);745void purge_previous_version_list();746747InstanceKlass* previous_versions() const { return _previous_versions; }748#else749InstanceKlass* previous_versions() const { return NULL; }750#endif751752InstanceKlass* get_klass_version(int version) {753for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) {754if (ik->constants()->version() == version) {755return ik;756}757}758return NULL;759}760761bool has_been_redefined() const {762return (_misc_flags & _misc_has_been_redefined) != 0;763}764void set_has_been_redefined() {765_misc_flags |= _misc_has_been_redefined;766}767768bool is_scratch_class() const {769return (_misc_flags & _misc_is_scratch_class) != 0;770}771772void set_is_scratch_class() {773_misc_flags |= _misc_is_scratch_class;774}775776bool has_resolved_methods() const {777return (_misc_flags & _misc_has_resolved_methods) != 0;778}779780void set_has_resolved_methods() {781_misc_flags |= _misc_has_resolved_methods;782}783private:784785void set_kind(unsigned kind) {786_kind = (u1)kind;787}788789bool is_kind(unsigned desired) const {790return _kind == (u1)desired;791}792793public:794795// Other is anything that is not one of the more specialized kinds of InstanceKlass.796bool is_other_instance_klass() const { return is_kind(_kind_other); }797bool is_reference_instance_klass() const { return is_kind(_kind_reference); }798bool is_mirror_instance_klass() const { return is_kind(_kind_mirror); }799bool is_class_loader_instance_klass() const { return is_kind(_kind_class_loader); }800801#if INCLUDE_JVMTI802803void init_previous_versions() {804_previous_versions = NULL;805}806807private:808static bool _has_previous_versions;809public:810static void purge_previous_versions(InstanceKlass* ik) {811if (ik->has_been_redefined()) {812ik->purge_previous_version_list();813}814}815816static bool has_previous_versions_and_reset();817static bool has_previous_versions() { return _has_previous_versions; }818819// JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation820void set_cached_class_file(JvmtiCachedClassFileData *data) {821_cached_class_file = data;822}823JvmtiCachedClassFileData * get_cached_class_file();824jint get_cached_class_file_len();825unsigned char * get_cached_class_file_bytes();826827// JVMTI: Support for caching of field indices, types, and offsets828void set_jvmti_cached_class_field_map(JvmtiCachedClassFieldMap* descriptor) {829_jvmti_cached_class_field_map = descriptor;830}831JvmtiCachedClassFieldMap* jvmti_cached_class_field_map() const {832return _jvmti_cached_class_field_map;833}834#else // INCLUDE_JVMTI835836static void purge_previous_versions(InstanceKlass* ik) { return; };837static bool has_previous_versions_and_reset() { return false; }838839void set_cached_class_file(JvmtiCachedClassFileData *data) {840assert(data == NULL, "unexpected call with JVMTI disabled");841}842JvmtiCachedClassFileData * get_cached_class_file() { return (JvmtiCachedClassFileData *)NULL; }843844#endif // INCLUDE_JVMTI845846bool has_nonstatic_concrete_methods() const {847return (_misc_flags & _misc_has_nonstatic_concrete_methods) != 0;848}849void set_has_nonstatic_concrete_methods(bool b) {850if (b) {851_misc_flags |= _misc_has_nonstatic_concrete_methods;852} else {853_misc_flags &= ~_misc_has_nonstatic_concrete_methods;854}855}856857bool declares_nonstatic_concrete_methods() const {858return (_misc_flags & _misc_declares_nonstatic_concrete_methods) != 0;859}860void set_declares_nonstatic_concrete_methods(bool b) {861if (b) {862_misc_flags |= _misc_declares_nonstatic_concrete_methods;863} else {864_misc_flags &= ~_misc_declares_nonstatic_concrete_methods;865}866}867868// for adding methods, ConstMethod::UNSET_IDNUM means no more ids available869inline u2 next_method_idnum();870void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; }871872// generics support873Symbol* generic_signature() const { return _constants->generic_signature(); }874u2 generic_signature_index() const { return _constants->generic_signature_index(); }875void set_generic_signature_index(u2 sig_index) { _constants->set_generic_signature_index(sig_index); }876877u2 enclosing_method_data(int offset) const;878u2 enclosing_method_class_index() const {879return enclosing_method_data(enclosing_method_class_index_offset);880}881u2 enclosing_method_method_index() {882return enclosing_method_data(enclosing_method_method_index_offset);883}884void set_enclosing_method_indices(u2 class_index,885u2 method_index);886887// jmethodID support888jmethodID get_jmethod_id(const methodHandle& method_h);889jmethodID get_jmethod_id_fetch_or_update(size_t idnum,890jmethodID new_id, jmethodID* new_jmeths,891jmethodID* to_dealloc_id_p,892jmethodID** to_dealloc_jmeths_p);893static void get_jmethod_id_length_value(jmethodID* cache, size_t idnum,894size_t *length_p, jmethodID* id_p);895void ensure_space_for_methodids(int start_offset = 0);896jmethodID jmethod_id_or_null(Method* method);897898// annotations support899Annotations* annotations() const { return _annotations; }900void set_annotations(Annotations* anno) { _annotations = anno; }901902AnnotationArray* class_annotations() const {903return (_annotations != NULL) ? _annotations->class_annotations() : NULL;904}905Array<AnnotationArray*>* fields_annotations() const {906return (_annotations != NULL) ? _annotations->fields_annotations() : NULL;907}908AnnotationArray* class_type_annotations() const {909return (_annotations != NULL) ? _annotations->class_type_annotations() : NULL;910}911Array<AnnotationArray*>* fields_type_annotations() const {912return (_annotations != NULL) ? _annotations->fields_type_annotations() : NULL;913}914// allocation915instanceOop allocate_instance(TRAPS);916static instanceOop allocate_instance(oop cls, TRAPS);917918// additional member function to return a handle919instanceHandle allocate_instance_handle(TRAPS);920921objArrayOop allocate_objArray(int n, int length, TRAPS);922// Helper function923static instanceOop register_finalizer(instanceOop i, TRAPS);924925// Check whether reflection/jni/jvm code is allowed to instantiate this class;926// if not, throw either an Error or an Exception.927virtual void check_valid_for_instantiation(bool throwError, TRAPS);928929// initialization930void call_class_initializer(TRAPS);931void set_initialization_state_and_notify(ClassState state, TRAPS);932933// OopMapCache support934OopMapCache* oop_map_cache() { return _oop_map_cache; }935void set_oop_map_cache(OopMapCache *cache) { _oop_map_cache = cache; }936void mask_for(const methodHandle& method, int bci, InterpreterOopMap* entry);937938// JNI identifier support (for static fields - for jni performance)939JNIid* jni_ids() { return _jni_ids; }940void set_jni_ids(JNIid* ids) { _jni_ids = ids; }941JNIid* jni_id_for(int offset);942943// maintenance of deoptimization dependencies944inline DependencyContext dependencies();945int mark_dependent_nmethods(KlassDepChange& changes);946void add_dependent_nmethod(nmethod* nm);947void remove_dependent_nmethod(nmethod* nm);948void clean_dependency_context();949950// On-stack replacement support951nmethod* osr_nmethods_head() const { return _osr_nmethods_head; };952void set_osr_nmethods_head(nmethod* h) { _osr_nmethods_head = h; };953void add_osr_nmethod(nmethod* n);954bool remove_osr_nmethod(nmethod* n);955int mark_osr_nmethods(const Method* m);956nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const;957958#if INCLUDE_JVMTI959// Breakpoint support (see methods on Method* for details)960BreakpointInfo* breakpoints() const { return _breakpoints; };961void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; };962#endif963964// support for stub routines965static ByteSize init_state_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_state)); }966JFR_ONLY(DEFINE_KLASS_TRACE_ID_OFFSET;)967static ByteSize init_thread_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_thread)); }968969// subclass/subinterface checks970bool implements_interface(Klass* k) const;971bool is_same_or_direct_interface(Klass* k) const;972973#ifdef ASSERT974// check whether this class or one of its superclasses was redefined975bool has_redefined_this_or_super() const;976#endif977978// Access to the implementor of an interface.979InstanceKlass* implementor() const;980void set_implementor(InstanceKlass* ik);981int nof_implementors() const;982void add_implementor(InstanceKlass* ik); // ik is a new class that implements this interface983void init_implementor(); // initialize984985// link this class into the implementors list of every interface it implements986void process_interfaces();987988// virtual operations from Klass989GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,990Array<InstanceKlass*>* transitive_interfaces);991bool can_be_primary_super_slow() const;992int oop_size(oop obj) const { return size_helper(); }993// slow because it's a virtual call and used for verifying the layout_helper.994// Using the layout_helper bits, we can call is_instance_klass without a virtual call.995DEBUG_ONLY(bool is_instance_klass_slow() const { return true; })996997// Iterators998void do_local_static_fields(FieldClosure* cl);999void do_nonstatic_fields(FieldClosure* cl); // including inherited fields1000void do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle, TRAPS);10011002void methods_do(void f(Method* method));1003void array_klasses_do(void f(Klass* k));1004void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);10051006static InstanceKlass* cast(Klass* k) {1007return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));1008}10091010static const InstanceKlass* cast(const Klass* k) {1011assert(k != NULL, "k should not be null");1012assert(k->is_instance_klass(), "cast to InstanceKlass");1013return static_cast<const InstanceKlass*>(k);1014}10151016virtual InstanceKlass* java_super() const {1017return (super() == NULL) ? NULL : cast(super());1018}10191020// Sizing (in words)1021static int header_size() { return sizeof(InstanceKlass)/wordSize; }10221023static int size(int vtable_length, int itable_length,1024int nonstatic_oop_map_size,1025bool is_interface) {1026return align_metadata_size(header_size() +1027vtable_length +1028itable_length +1029nonstatic_oop_map_size +1030(is_interface ? (int)sizeof(Klass*)/wordSize : 0));1031}10321033int size() const { return size(vtable_length(),1034itable_length(),1035nonstatic_oop_map_size(),1036is_interface());1037}103810391040inline intptr_t* start_of_itable() const;1041inline intptr_t* end_of_itable() const;1042inline int itable_offset_in_words() const;1043inline oop static_field_base_raw();10441045inline OopMapBlock* start_of_nonstatic_oop_maps() const;1046inline Klass** end_of_nonstatic_oop_maps() const;10471048inline InstanceKlass* volatile* adr_implementor() const;10491050// Use this to return the size of an instance in heap words:1051int size_helper() const {1052return layout_helper_to_size_helper(layout_helper());1053}10541055// This bit is initialized in classFileParser.cpp.1056// It is false under any of the following conditions:1057// - the class is abstract (including any interface)1058// - the class has a finalizer (if !RegisterFinalizersAtInit)1059// - the class size is larger than FastAllocateSizeLimit1060// - the class is java/lang/Class, which cannot be allocated directly1061bool can_be_fastpath_allocated() const {1062return !layout_helper_needs_slow_path(layout_helper());1063}10641065// Java itable1066klassItable itable() const; // return klassItable wrapper1067Method* method_at_itable(InstanceKlass* holder, int index, TRAPS);1068Method* method_at_itable_or_null(InstanceKlass* holder, int index, bool& itable_entry_found);1069int vtable_index_of_interface_method(Method* method);10701071#if INCLUDE_JVMTI1072void adjust_default_methods(bool* trace_name_printed);1073#endif // INCLUDE_JVMTI10741075void clean_weak_instanceklass_links();1076private:1077void clean_implementors_list();1078void clean_method_data();10791080public:1081// Explicit metaspace deallocation of fields1082// For RedefineClasses and class file parsing errors, we need to deallocate1083// instanceKlasses and the metadata they point to.1084void deallocate_contents(ClassLoaderData* loader_data);1085static void deallocate_methods(ClassLoaderData* loader_data,1086Array<Method*>* methods);1087void static deallocate_interfaces(ClassLoaderData* loader_data,1088const Klass* super_klass,1089Array<InstanceKlass*>* local_interfaces,1090Array<InstanceKlass*>* transitive_interfaces);1091void static deallocate_record_components(ClassLoaderData* loader_data,1092Array<RecordComponent*>* record_component);10931094// The constant pool is on stack if any of the methods are executing or1095// referenced by handles.1096bool on_stack() const { return _constants->on_stack(); }10971098// callbacks for actions during class unloading1099static void unload_class(InstanceKlass* ik);11001101virtual void release_C_heap_structures();11021103// Naming1104const char* signature_name() const;11051106// Oop fields (and metadata) iterators1107//1108// The InstanceKlass iterators also visits the Object's klass.11091110// Forward iteration1111public:1112// Iterate over all oop fields in the oop maps.1113template <typename T, class OopClosureType>1114inline void oop_oop_iterate_oop_maps(oop obj, OopClosureType* closure);11151116// Iterate over all oop fields and metadata.1117template <typename T, class OopClosureType>1118inline void oop_oop_iterate(oop obj, OopClosureType* closure);11191120// Iterate over all oop fields in one oop map.1121template <typename T, class OopClosureType>1122inline void oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure);112311241125// Reverse iteration1126// Iterate over all oop fields and metadata.1127template <typename T, class OopClosureType>1128inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure);11291130private:1131// Iterate over all oop fields in the oop maps.1132template <typename T, class OopClosureType>1133inline void oop_oop_iterate_oop_maps_reverse(oop obj, OopClosureType* closure);11341135// Iterate over all oop fields in one oop map.1136template <typename T, class OopClosureType>1137inline void oop_oop_iterate_oop_map_reverse(OopMapBlock* map, oop obj, OopClosureType* closure);113811391140// Bounded range iteration1141public:1142// Iterate over all oop fields in the oop maps.1143template <typename T, class OopClosureType>1144inline void oop_oop_iterate_oop_maps_bounded(oop obj, OopClosureType* closure, MemRegion mr);11451146// Iterate over all oop fields and metadata.1147template <typename T, class OopClosureType>1148inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr);11491150private:1151// Iterate over all oop fields in one oop map.1152template <typename T, class OopClosureType>1153inline void oop_oop_iterate_oop_map_bounded(OopMapBlock* map, oop obj, OopClosureType* closure, MemRegion mr);115411551156public:1157u2 idnum_allocated_count() const { return _idnum_allocated_count; }11581159private:1160// initialization state1161void set_init_state(ClassState state);1162void set_rewritten() { _misc_flags |= _misc_rewritten; }1163void set_init_thread(Thread *thread) { _init_thread = thread; }11641165// The RedefineClasses() API can cause new method idnums to be needed1166// which will cause the caches to grow. Safety requires different1167// cache management logic if the caches can grow instead of just1168// going from NULL to non-NULL.1169bool idnum_can_increment() const { return has_been_redefined(); }1170inline jmethodID* methods_jmethod_ids_acquire() const;1171inline void release_set_methods_jmethod_ids(jmethodID* jmeths);11721173// Lock during initialization1174public:1175// Lock for (1) initialization; (2) access to the ConstantPool of this class.1176// Must be one per class and it has to be a VM internal object so java code1177// cannot lock it (like the mirror).1178// It has to be an object not a Mutex because it's held through java calls.1179oop init_lock() const;11801181// Returns the array class for the n'th dimension1182virtual Klass* array_klass(int n, TRAPS);1183virtual Klass* array_klass_or_null(int n);11841185// Returns the array class with this class as element type1186virtual Klass* array_klass(TRAPS);1187virtual Klass* array_klass_or_null();11881189private:1190void fence_and_clear_init_lock();11911192bool link_class_impl (TRAPS);1193bool verify_code (TRAPS);1194void initialize_impl (TRAPS);1195void initialize_super_interfaces (TRAPS);1196void eager_initialize_impl ();1197/* jni_id_for_impl for jfieldID only */1198JNIid* jni_id_for_impl (int offset);11991200// find a local method (returns NULL if not found)1201Method* find_method_impl(const Symbol* name,1202const Symbol* signature,1203OverpassLookupMode overpass_mode,1204StaticLookupMode static_mode,1205PrivateLookupMode private_mode) const;12061207static Method* find_method_impl(const Array<Method*>* methods,1208const Symbol* name,1209const Symbol* signature,1210OverpassLookupMode overpass_mode,1211StaticLookupMode static_mode,1212PrivateLookupMode private_mode);12131214// Free CHeap allocated fields.1215void release_C_heap_structures_internal();12161217#if INCLUDE_JVMTI1218// RedefineClasses support1219void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }1220void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);1221#endif1222// log class name to classlist1223void log_to_classlist() const;1224public:1225// CDS support - remove and restore oops from metadata. Oops are not shared.1226virtual void remove_unshareable_info();1227virtual void remove_java_mirror();1228void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);1229void init_shared_package_entry();1230bool can_be_verified_at_dumptime() const;12311232jint compute_modifier_flags() const;12331234public:1235// JVMTI support1236jint jvmti_class_status() const;12371238virtual void metaspace_pointers_do(MetaspaceClosure* iter);12391240public:1241// Printing1242#ifndef PRODUCT1243void print_on(outputStream* st) const;1244#endif1245void print_value_on(outputStream* st) const;12461247void oop_print_value_on(oop obj, outputStream* st);12481249#ifndef PRODUCT1250void oop_print_on (oop obj, outputStream* st);12511252void print_dependent_nmethods(bool verbose = false);1253bool is_dependent_nmethod(nmethod* nm);1254bool verify_itable_index(int index);1255#endif12561257const char* internal_name() const;12581259// Verification1260void verify_on(outputStream* st);12611262void oop_verify_on(oop obj, outputStream* st);12631264// Logging1265void print_class_load_logging(ClassLoaderData* loader_data,1266const ModuleEntry* module_entry,1267const ClassFileStream* cfs) const;1268};12691270// for adding methods1271// UNSET_IDNUM return means no more ids available1272inline u2 InstanceKlass::next_method_idnum() {1273if (_idnum_allocated_count == ConstMethod::MAX_IDNUM) {1274return ConstMethod::UNSET_IDNUM; // no more ids available1275} else {1276return _idnum_allocated_count++;1277}1278}127912801281/* JNIid class for jfieldIDs only */1282class JNIid: public CHeapObj<mtClass> {1283friend class VMStructs;1284private:1285Klass* _holder;1286JNIid* _next;1287int _offset;1288#ifdef ASSERT1289bool _is_static_field_id;1290#endif12911292public:1293// Accessors1294Klass* holder() const { return _holder; }1295int offset() const { return _offset; }1296JNIid* next() { return _next; }1297// Constructor1298JNIid(Klass* holder, int offset, JNIid* next);1299// Identifier lookup1300JNIid* find(int offset);13011302bool find_local_field(fieldDescriptor* fd) {1303return InstanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd);1304}13051306static void deallocate(JNIid* id);1307// Debugging1308#ifdef ASSERT1309bool is_static_field_id() const { return _is_static_field_id; }1310void set_is_static_field_id() { _is_static_field_id = true; }1311#endif1312void verify(Klass* holder);1313};13141315// An iterator that's used to access the inner classes indices in the1316// InstanceKlass::_inner_classes array.1317class InnerClassesIterator : public StackObj {1318private:1319Array<jushort>* _inner_classes;1320int _length;1321int _idx;1322public:13231324InnerClassesIterator(const InstanceKlass* k) {1325_inner_classes = k->inner_classes();1326if (k->inner_classes() != NULL) {1327_length = _inner_classes->length();1328// The inner class array's length should be the multiple of1329// inner_class_next_offset if it only contains the InnerClasses1330// attribute data, or it should be1331// n*inner_class_next_offset+enclosing_method_attribute_size1332// if it also contains the EnclosingMethod data.1333assert((_length % InstanceKlass::inner_class_next_offset == 0 ||1334_length % InstanceKlass::inner_class_next_offset == InstanceKlass::enclosing_method_attribute_size),1335"just checking");1336// Remove the enclosing_method portion if exists.1337if (_length % InstanceKlass::inner_class_next_offset == InstanceKlass::enclosing_method_attribute_size) {1338_length -= InstanceKlass::enclosing_method_attribute_size;1339}1340} else {1341_length = 0;1342}1343_idx = 0;1344}13451346int length() const {1347return _length;1348}13491350void next() {1351_idx += InstanceKlass::inner_class_next_offset;1352}13531354bool done() const {1355return (_idx >= _length);1356}13571358u2 inner_class_info_index() const {1359return _inner_classes->at(1360_idx + InstanceKlass::inner_class_inner_class_info_offset);1361}13621363void set_inner_class_info_index(u2 index) {1364_inner_classes->at_put(1365_idx + InstanceKlass::inner_class_inner_class_info_offset, index);1366}13671368u2 outer_class_info_index() const {1369return _inner_classes->at(1370_idx + InstanceKlass::inner_class_outer_class_info_offset);1371}13721373void set_outer_class_info_index(u2 index) {1374_inner_classes->at_put(1375_idx + InstanceKlass::inner_class_outer_class_info_offset, index);1376}13771378u2 inner_name_index() const {1379return _inner_classes->at(1380_idx + InstanceKlass::inner_class_inner_name_offset);1381}13821383void set_inner_name_index(u2 index) {1384_inner_classes->at_put(1385_idx + InstanceKlass::inner_class_inner_name_offset, index);1386}13871388u2 inner_access_flags() const {1389return _inner_classes->at(1390_idx + InstanceKlass::inner_class_access_flags_offset);1391}1392};13931394// Iterator over class hierarchy under a particular class. Implements depth-first pre-order traversal.1395// Usage:1396// for (ClassHierarchyIterator iter(root_klass); !iter.done(); iter.next()) {1397// Klass* k = iter.klass();1398// ...1399// }1400class ClassHierarchyIterator : public StackObj {1401private:1402InstanceKlass* _root;1403Klass* _current;1404bool _visit_subclasses;14051406public:1407ClassHierarchyIterator(InstanceKlass* root) : _root(root), _current(root), _visit_subclasses(true) {1408assert(_root == _current, "required"); // initial state1409}14101411bool done() {1412return (_current == NULL);1413}14141415// Make a step iterating over the class hierarchy under the root class.1416// Skips subclasses if requested.1417void next();14181419Klass* klass() {1420assert(!done(), "sanity");1421return _current;1422}14231424// Skip subclasses of the current class.1425void skip_subclasses() {1426_visit_subclasses = false;1427}1428};14291430#endif // SHARE_OOPS_INSTANCEKLASS_HPP143114321433