Path: blob/master/src/hotspot/share/oops/instanceKlass.hpp
64440 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// Print fields.79// If "obj" argument to constructor is NULL, prints static fields, otherwise prints non-static fields.80class FieldPrinter: public FieldClosure {81oop _obj;82outputStream* _st;83public:84FieldPrinter(outputStream* st, oop obj = NULL) : _obj(obj), _st(st) {}85void do_field(fieldDescriptor* fd);86};8788// Describes where oops are located in instances of this klass.89class OopMapBlock {90public:91// Byte offset of the first oop mapped by this block.92int offset() const { return _offset; }93void set_offset(int offset) { _offset = offset; }9495// Number of oops in this block.96uint count() const { return _count; }97void set_count(uint count) { _count = count; }9899void increment_count(int diff) { _count += diff; }100101int offset_span() const { return _count * heapOopSize; }102103int end_offset() const {104return offset() + offset_span();105}106107bool is_contiguous(int another_offset) const {108return another_offset == end_offset();109}110111// sizeof(OopMapBlock) in words.112static const int size_in_words() {113return align_up((int)sizeof(OopMapBlock), wordSize) >>114LogBytesPerWord;115}116117static int compare_offset(const OopMapBlock* a, const OopMapBlock* b) {118return a->offset() - b->offset();119}120121private:122int _offset;123uint _count;124};125126struct JvmtiCachedClassFileData;127128class InstanceKlass: public Klass {129friend class VMStructs;130friend class JVMCIVMStructs;131friend class ClassFileParser;132friend class CompileReplay;133134public:135static const KlassID ID = InstanceKlassID;136137protected:138InstanceKlass(const ClassFileParser& parser, unsigned kind, KlassID id = ID);139140public:141InstanceKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }142143// See "The Java Virtual Machine Specification" section 2.16.2-5 for a detailed description144// of the class loading & initialization procedure, and the use of the states.145enum ClassState {146allocated, // allocated (but not yet linked)147loaded, // loaded and inserted in class hierarchy (but not linked yet)148linked, // successfully linked/verified (but not initialized yet)149being_initialized, // currently running class initializer150fully_initialized, // initialized (successfull final state)151initialization_error // error happened during initialization152};153154private:155static InstanceKlass* allocate_instance_klass(const ClassFileParser& parser, TRAPS);156157protected:158// If you add a new field that points to any metaspace object, you159// must add this field to InstanceKlass::metaspace_pointers_do().160161// Annotations for this class162Annotations* _annotations;163// Package this class is defined in164PackageEntry* _package_entry;165// Array classes holding elements of this class.166ObjArrayKlass* volatile _array_klasses;167// Constant pool for this class.168ConstantPool* _constants;169// The InnerClasses attribute and EnclosingMethod attribute. The170// _inner_classes is an array of shorts. If the class has InnerClasses171// attribute, then the _inner_classes array begins with 4-tuples of shorts172// [inner_class_info_index, outer_class_info_index,173// inner_name_index, inner_class_access_flags] for the InnerClasses174// attribute. If the EnclosingMethod attribute exists, it occupies the175// last two shorts [class_index, method_index] of the array. If only176// the InnerClasses attribute exists, the _inner_classes array length is177// number_of_inner_classes * 4. If the class has both InnerClasses178// and EnclosingMethod attributes the _inner_classes array length is179// number_of_inner_classes * 4 + enclosing_method_attribute_size.180Array<jushort>* _inner_classes;181182// The NestMembers attribute. An array of shorts, where each is a183// class info index for the class that is a nest member. This data184// has not been validated.185Array<jushort>* _nest_members;186187// Resolved nest-host klass: either true nest-host or self if we are not188// nested, or an error occurred resolving or validating the nominated189// nest-host. Can also be set directly by JDK API's that establish nest190// relationships.191// By always being set it makes nest-member access checks simpler.192InstanceKlass* _nest_host;193194// The PermittedSubclasses attribute. An array of shorts, where each is a195// class info index for the class that is a permitted subclass.196Array<jushort>* _permitted_subclasses;197198// The contents of the Record attribute.199Array<RecordComponent*>* _record_components;200201// the source debug extension for this klass, NULL if not specified.202// Specified as UTF-8 string without terminating zero byte in the classfile,203// it is stored in the instanceklass as a NULL-terminated UTF-8 string204const char* _source_debug_extension;205206// Number of heapOopSize words used by non-static fields in this klass207// (including inherited fields but after header_size()).208int _nonstatic_field_size;209int _static_field_size; // number words used by static fields (oop and non-oop) in this klass210int _nonstatic_oop_map_size; // size in words of nonstatic oop map blocks211int _itable_len; // length of Java itable (in words)212213// The NestHost attribute. The class info index for the class214// that is the nest-host of this class. This data has not been validated.215u2 _nest_host_index;216u2 _this_class_index; // constant pool entry217u2 _static_oop_field_count; // number of static oop fields in this klass218u2 _java_fields_count; // The number of declared Java fields219220volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change221222// _is_marked_dependent can be set concurrently, thus cannot be part of the223// _misc_flags.224bool _is_marked_dependent; // used for marking during flushing and deoptimization225226// Class states are defined as ClassState (see above).227// Place the _init_state here to utilize the unused 2-byte after228// _idnum_allocated_count.229u1 _init_state; // state of class230231// This can be used to quickly discriminate among the four kinds of232// InstanceKlass. This should be an enum (?)233static const unsigned _kind_other = 0; // concrete InstanceKlass234static const unsigned _kind_reference = 1; // InstanceRefKlass235static const unsigned _kind_class_loader = 2; // InstanceClassLoaderKlass236static const unsigned _kind_mirror = 3; // InstanceMirrorKlass237238u1 _reference_type; // reference type239u1 _kind; // kind of InstanceKlass240241enum {242_misc_rewritten = 1 << 0, // methods rewritten.243_misc_has_nonstatic_fields = 1 << 1, // for sizing with UseCompressedOops244_misc_should_verify_class = 1 << 2, // allow caching of preverification245_misc_unused = 1 << 3, // not currently used246_misc_is_contended = 1 << 4, // marked with contended annotation247_misc_has_nonstatic_concrete_methods = 1 << 5, // class/superclass/implemented interfaces has non-static, concrete methods248_misc_declares_nonstatic_concrete_methods = 1 << 6, // directly declares non-static, concrete methods249_misc_has_been_redefined = 1 << 7, // class has been redefined250_misc_shared_loading_failed = 1 << 8, // class has been loaded from shared archive251_misc_is_scratch_class = 1 << 9, // class is the redefined scratch class252_misc_is_shared_boot_class = 1 << 10, // defining class loader is boot class loader253_misc_is_shared_platform_class = 1 << 11, // defining class loader is platform class loader254_misc_is_shared_app_class = 1 << 12, // defining class loader is app class loader255_misc_has_resolved_methods = 1 << 13, // resolved methods table entries added for this class256_misc_has_contended_annotations = 1 << 14 // has @Contended annotation257};258u2 shared_loader_type_bits() const {259return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;260}261u2 _misc_flags; // There is more space in access_flags for more flags.262263Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization)264OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)265JNIid* _jni_ids; // First JNI identifier for static fields in this class266jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none267nmethodBucket* volatile _dep_context; // packed DependencyContext structure268uint64_t volatile _dep_context_last_cleaned;269nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class270#if INCLUDE_JVMTI271BreakpointInfo* _breakpoints; // bpt lists, managed by Method*272// Linked instanceKlasses of previous versions273InstanceKlass* _previous_versions;274// JVMTI fields can be moved to their own structure - see 6315920275// JVMTI: cached class file, before retransformable agent modified it in CFLH276JvmtiCachedClassFileData* _cached_class_file;277#endif278279#if INCLUDE_JVMTI280JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration281#endif282283NOT_PRODUCT(int _verify_count;) // to avoid redundant verifies284285// Method array.286Array<Method*>* _methods;287// Default Method Array, concrete methods inherited from interfaces288Array<Method*>* _default_methods;289// Interfaces (InstanceKlass*s) this class declares locally to implement.290Array<InstanceKlass*>* _local_interfaces;291// Interfaces (InstanceKlass*s) this class implements transitively.292Array<InstanceKlass*>* _transitive_interfaces;293// Int array containing the original order of method in the class file (for JVMTI).294Array<int>* _method_ordering;295// Int array containing the vtable_indices for default_methods296// offset matches _default_methods offset297Array<int>* _default_vtable_indices;298299// Instance and static variable information, starts with 6-tuples of shorts300// [access, name index, sig index, initval index, low_offset, high_offset]301// for all fields, followed by the generic signature data at the end of302// the array. Only fields with generic signature attributes have the generic303// signature data set in the array. The fields array looks like following:304//305// f1: [access, name index, sig index, initial value index, low_offset, high_offset]306// f2: [access, name index, sig index, initial value index, low_offset, high_offset]307// ...308// fn: [access, name index, sig index, initial value index, low_offset, high_offset]309// [generic signature index]310// [generic signature index]311// ...312Array<u2>* _fields;313314// embedded Java vtable follows here315// embedded Java itables follows here316// embedded static fields follows here317// embedded nonstatic oop-map blocks follows here318// embedded implementor of this interface follows here319// The embedded implementor only exists if the current klass is an320// interface. The possible values of the implementor fall into following321// three cases:322// NULL: no implementor.323// A Klass* that's not itself: one implementor.324// Itself: more than one implementors.325//326327friend class SystemDictionary;328329static bool _disable_method_binary_search;330331public:332// The three BUILTIN class loader types333bool is_shared_boot_class() const {334return (_misc_flags & _misc_is_shared_boot_class) != 0;335}336bool is_shared_platform_class() const {337return (_misc_flags & _misc_is_shared_platform_class) != 0;338}339bool is_shared_app_class() const {340return (_misc_flags & _misc_is_shared_app_class) != 0;341}342// The UNREGISTERED class loader type343bool is_shared_unregistered_class() const {344return (_misc_flags & shared_loader_type_bits()) == 0;345}346347// Check if the class can be shared in CDS348bool is_shareable() const;349350void clear_shared_class_loader_type() {351_misc_flags &= ~shared_loader_type_bits();352}353354bool shared_loading_failed() const {355return (_misc_flags & _misc_shared_loading_failed) != 0;356}357358void set_shared_loading_failed() {359_misc_flags |= _misc_shared_loading_failed;360}361362void clear_shared_loading_failed() {363_misc_flags &= ~_misc_shared_loading_failed;364}365366void set_shared_class_loader_type(s2 loader_type);367368void assign_class_loader_type();369370bool has_nonstatic_fields() const {371return (_misc_flags & _misc_has_nonstatic_fields) != 0;372}373void set_has_nonstatic_fields(bool b) {374if (b) {375_misc_flags |= _misc_has_nonstatic_fields;376} else {377_misc_flags &= ~_misc_has_nonstatic_fields;378}379}380381// field sizes382int nonstatic_field_size() const { return _nonstatic_field_size; }383void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; }384385int static_field_size() const { return _static_field_size; }386void set_static_field_size(int size) { _static_field_size = size; }387388int static_oop_field_count() const { return (int)_static_oop_field_count; }389void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }390391// Java itable392int itable_length() const { return _itable_len; }393void set_itable_length(int len) { _itable_len = len; }394395// array klasses396ObjArrayKlass* array_klasses() const { return _array_klasses; }397inline ObjArrayKlass* array_klasses_acquire() const; // load with acquire semantics398void set_array_klasses(ObjArrayKlass* k) { _array_klasses = k; }399inline void release_set_array_klasses(ObjArrayKlass* k); // store with release semantics400401// methods402Array<Method*>* methods() const { return _methods; }403void set_methods(Array<Method*>* a) { _methods = a; }404Method* method_with_idnum(int idnum);405Method* method_with_orig_idnum(int idnum);406Method* method_with_orig_idnum(int idnum, int version);407408// method ordering409Array<int>* method_ordering() const { return _method_ordering; }410void set_method_ordering(Array<int>* m) { _method_ordering = m; }411void copy_method_ordering(const intArray* m, TRAPS);412413// default_methods414Array<Method*>* default_methods() const { return _default_methods; }415void set_default_methods(Array<Method*>* a) { _default_methods = a; }416417// default method vtable_indices418Array<int>* default_vtable_indices() const { return _default_vtable_indices; }419void set_default_vtable_indices(Array<int>* v) { _default_vtable_indices = v; }420Array<int>* create_new_default_vtable_indices(int len, TRAPS);421422// interfaces423Array<InstanceKlass*>* local_interfaces() const { return _local_interfaces; }424void set_local_interfaces(Array<InstanceKlass*>* a) {425guarantee(_local_interfaces == NULL || a == NULL, "Just checking");426_local_interfaces = a; }427428Array<InstanceKlass*>* transitive_interfaces() const { return _transitive_interfaces; }429void set_transitive_interfaces(Array<InstanceKlass*>* a) {430guarantee(_transitive_interfaces == NULL || a == NULL, "Just checking");431_transitive_interfaces = a;432}433434private:435friend class fieldDescriptor;436FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }437438public:439int field_offset (int index) const { return field(index)->offset(); }440int field_access_flags(int index) const { return field(index)->access_flags(); }441Symbol* field_name (int index) const { return field(index)->name(constants()); }442Symbol* field_signature (int index) const { return field(index)->signature(constants()); }443444// Number of Java declared fields445int java_fields_count() const { return (int)_java_fields_count; }446447Array<u2>* fields() const { return _fields; }448void set_fields(Array<u2>* f, u2 java_fields_count) {449guarantee(_fields == NULL || f == NULL, "Just checking");450_fields = f;451_java_fields_count = java_fields_count;452}453454// inner classes455Array<u2>* inner_classes() const { return _inner_classes; }456void set_inner_classes(Array<u2>* f) { _inner_classes = f; }457458// nest members459Array<u2>* nest_members() const { return _nest_members; }460void set_nest_members(Array<u2>* m) { _nest_members = m; }461462// nest-host index463jushort nest_host_index() const { return _nest_host_index; }464void set_nest_host_index(u2 i) { _nest_host_index = i; }465// dynamic nest member support466void set_nest_host(InstanceKlass* host);467468// record components469Array<RecordComponent*>* record_components() const { return _record_components; }470void set_record_components(Array<RecordComponent*>* record_components) {471_record_components = record_components;472}473bool is_record() const;474475// permitted subclasses476Array<u2>* permitted_subclasses() const { return _permitted_subclasses; }477void set_permitted_subclasses(Array<u2>* s) { _permitted_subclasses = s; }478479private:480// Called to verify that k is a member of this nest - does not look at k's nest-host,481// nor does it resolve any CP entries or load any classes.482bool has_nest_member(JavaThread* current, InstanceKlass* k) const;483484public:485// Used to construct informative IllegalAccessError messages at a higher level,486// if there was an issue resolving or validating the nest host.487// Returns NULL if there was no error.488const char* nest_host_error();489// Returns nest-host class, resolving and validating it if needed.490// Returns NULL if resolution is not possible from the calling context.491InstanceKlass* nest_host(TRAPS);492// Check if this klass is a nestmate of k - resolves this nest-host and k's493bool has_nestmate_access_to(InstanceKlass* k, TRAPS);494495// Called to verify that k is a permitted subclass of this class496bool has_as_permitted_subclass(const InstanceKlass* k) const;497498enum InnerClassAttributeOffset {499// From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814500inner_class_inner_class_info_offset = 0,501inner_class_outer_class_info_offset = 1,502inner_class_inner_name_offset = 2,503inner_class_access_flags_offset = 3,504inner_class_next_offset = 4505};506507enum EnclosingMethodAttributeOffset {508enclosing_method_class_index_offset = 0,509enclosing_method_method_index_offset = 1,510enclosing_method_attribute_size = 2511};512513// package514PackageEntry* package() const { return _package_entry; }515ModuleEntry* module() const;516bool in_unnamed_package() const { return (_package_entry == NULL); }517void set_package(ClassLoaderData* loader_data, PackageEntry* pkg_entry, TRAPS);518// If the package for the InstanceKlass is in the boot loader's package entry519// table then sets the classpath_index field so that520// get_system_package() will know to return a non-null value for the521// package's location. And, so that the package will be added to the list of522// packages returned by get_system_packages().523// For packages whose classes are loaded from the boot loader class path, the524// classpath_index indicates which entry on the boot loader class path.525void set_classpath_index(s2 path_index);526bool is_same_class_package(const Klass* class2) const;527bool is_same_class_package(oop other_class_loader, const Symbol* other_class_name) const;528529// find an enclosing class530InstanceKlass* compute_enclosing_class(bool* inner_is_member, TRAPS) const;531532// Find InnerClasses attribute and return outer_class_info_index & inner_name_index.533bool find_inner_classes_attr(int* ooff, int* noff, TRAPS) const;534535private:536// Check prohibited package ("java/" only loadable by boot or platform loaders)537static void check_prohibited_package(Symbol* class_name,538ClassLoaderData* loader_data,539TRAPS);540public:541// initialization state542bool is_loaded() const { return _init_state >= loaded; }543bool is_linked() const { return _init_state >= linked; }544bool is_initialized() const { return _init_state == fully_initialized; }545bool is_not_initialized() const { return _init_state < being_initialized; }546bool is_being_initialized() const { return _init_state == being_initialized; }547bool is_in_error_state() const { return _init_state == initialization_error; }548bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; }549ClassState init_state() { return (ClassState)_init_state; }550bool is_rewritten() const { return (_misc_flags & _misc_rewritten) != 0; }551552// is this a sealed class553bool is_sealed() const;554555// defineClass specified verification556bool should_verify_class() const {557return (_misc_flags & _misc_should_verify_class) != 0;558}559void set_should_verify_class(bool value) {560if (value) {561_misc_flags |= _misc_should_verify_class;562} else {563_misc_flags &= ~_misc_should_verify_class;564}565}566567// marking568bool is_marked_dependent() const { return _is_marked_dependent; }569void set_is_marked_dependent(bool value) { _is_marked_dependent = value; }570571// initialization (virtuals from Klass)572bool should_be_initialized() const; // means that initialize should be called573void initialize(TRAPS);574void link_class(TRAPS);575bool link_class_or_fail(TRAPS); // returns false on failure576void rewrite_class(TRAPS);577void link_methods(TRAPS);578Method* class_initializer() const;579580// set the class to initialized if no static initializer is present581void eager_initialize(Thread *thread);582583// reference type584ReferenceType reference_type() const { return (ReferenceType)_reference_type; }585void set_reference_type(ReferenceType t) {586assert(t == (u1)t, "overflow");587_reference_type = (u1)t;588}589590// this class cp index591u2 this_class_index() const { return _this_class_index; }592void set_this_class_index(u2 index) { _this_class_index = index; }593594static ByteSize reference_type_offset() { return in_ByteSize(offset_of(InstanceKlass, _reference_type)); }595596// find local field, returns true if found597bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;598// find field in direct superinterfaces, returns the interface in which the field is defined599Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;600// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined601Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;602// find instance or static fields according to JVM spec 5.4.3.2, returns the klass in which the field is defined603Klass* find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const;604605// find a non-static or static field given its offset within the class.606bool contains_field_offset(int offset);607608bool find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;609bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;610611private:612inline static int quick_search(const Array<Method*>* methods, const Symbol* name);613614public:615static void disable_method_binary_search() {616_disable_method_binary_search = true;617}618619// find a local method (returns NULL if not found)620Method* find_method(const Symbol* name, const Symbol* signature) const;621static Method* find_method(const Array<Method*>* methods,622const Symbol* name,623const Symbol* signature);624625// find a local method, but skip static methods626Method* find_instance_method(const Symbol* name, const Symbol* signature,627PrivateLookupMode private_mode) const;628static Method* find_instance_method(const Array<Method*>* methods,629const Symbol* name,630const Symbol* signature,631PrivateLookupMode private_mode);632633// find a local method (returns NULL if not found)634Method* find_local_method(const Symbol* name,635const Symbol* signature,636OverpassLookupMode overpass_mode,637StaticLookupMode static_mode,638PrivateLookupMode private_mode) const;639640// find a local method from given methods array (returns NULL if not found)641static Method* find_local_method(const Array<Method*>* methods,642const Symbol* name,643const Symbol* signature,644OverpassLookupMode overpass_mode,645StaticLookupMode static_mode,646PrivateLookupMode private_mode);647648// find a local method index in methods or default_methods (returns -1 if not found)649static int find_method_index(const Array<Method*>* methods,650const Symbol* name,651const Symbol* signature,652OverpassLookupMode overpass_mode,653StaticLookupMode static_mode,654PrivateLookupMode private_mode);655656// lookup operation (returns NULL if not found)657Method* uncached_lookup_method(const Symbol* name,658const Symbol* signature,659OverpassLookupMode overpass_mode,660PrivateLookupMode private_mode = PrivateLookupMode::find) const;661662// lookup a method in all the interfaces that this class implements663// (returns NULL if not found)664Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, DefaultsLookupMode defaults_mode) const;665666// lookup a method in local defaults then in all interfaces667// (returns NULL if not found)668Method* lookup_method_in_ordered_interfaces(Symbol* name, Symbol* signature) const;669670// Find method indices by name. If a method with the specified name is671// found the index to the first method is returned, and 'end' is filled in672// with the index of first non-name-matching method. If no method is found673// -1 is returned.674int find_method_by_name(const Symbol* name, int* end) const;675static int find_method_by_name(const Array<Method*>* methods,676const Symbol* name, int* end);677678// constant pool679ConstantPool* constants() const { return _constants; }680void set_constants(ConstantPool* c) { _constants = c; }681682// protection domain683oop protection_domain() const;684685// signers686objArrayOop signers() const;687688bool is_contended() const {689return (_misc_flags & _misc_is_contended) != 0;690}691void set_is_contended(bool value) {692if (value) {693_misc_flags |= _misc_is_contended;694} else {695_misc_flags &= ~_misc_is_contended;696}697}698699// source file name700Symbol* source_file_name() const { return _constants->source_file_name(); }701u2 source_file_name_index() const { return _constants->source_file_name_index(); }702void set_source_file_name_index(u2 sourcefile_index) { _constants->set_source_file_name_index(sourcefile_index); }703704// minor and major version numbers of class file705u2 minor_version() const { return _constants->minor_version(); }706void set_minor_version(u2 minor_version) { _constants->set_minor_version(minor_version); }707u2 major_version() const { return _constants->major_version(); }708void set_major_version(u2 major_version) { _constants->set_major_version(major_version); }709710// source debug extension711const char* source_debug_extension() const { return _source_debug_extension; }712void set_source_debug_extension(const char* array, int length);713714// nonstatic oop-map blocks715static int nonstatic_oop_map_size(unsigned int oop_map_count) {716return oop_map_count * OopMapBlock::size_in_words();717}718unsigned int nonstatic_oop_map_count() const {719return _nonstatic_oop_map_size / OopMapBlock::size_in_words();720}721int nonstatic_oop_map_size() const { return _nonstatic_oop_map_size; }722void set_nonstatic_oop_map_size(int words) {723_nonstatic_oop_map_size = words;724}725726bool has_contended_annotations() const {727return ((_misc_flags & _misc_has_contended_annotations) != 0);728}729void set_has_contended_annotations(bool value) {730if (value) {731_misc_flags |= _misc_has_contended_annotations;732} else {733_misc_flags &= ~_misc_has_contended_annotations;734}735}736737#if INCLUDE_JVMTI738// Redefinition locking. Class can only be redefined by one thread at a time.739// The flag is in access_flags so that it can be set and reset using atomic740// operations, and not be reset by other misc_flag settings.741bool is_being_redefined() const {742return _access_flags.is_being_redefined();743}744void set_is_being_redefined(bool value) {745if (value) {746_access_flags.set_is_being_redefined();747} else {748_access_flags.clear_is_being_redefined();749}750}751752// RedefineClasses() support for previous versions:753void add_previous_version(InstanceKlass* ik, int emcp_method_count);754void purge_previous_version_list();755756InstanceKlass* previous_versions() const { return _previous_versions; }757#else758InstanceKlass* previous_versions() const { return NULL; }759#endif760761InstanceKlass* get_klass_version(int version) {762for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) {763if (ik->constants()->version() == version) {764return ik;765}766}767return NULL;768}769770bool has_been_redefined() const {771return (_misc_flags & _misc_has_been_redefined) != 0;772}773void set_has_been_redefined() {774_misc_flags |= _misc_has_been_redefined;775}776777bool is_scratch_class() const {778return (_misc_flags & _misc_is_scratch_class) != 0;779}780781void set_is_scratch_class() {782_misc_flags |= _misc_is_scratch_class;783}784785bool has_resolved_methods() const {786return (_misc_flags & _misc_has_resolved_methods) != 0;787}788789void set_has_resolved_methods() {790_misc_flags |= _misc_has_resolved_methods;791}792private:793794void set_kind(unsigned kind) {795_kind = (u1)kind;796}797798bool is_kind(unsigned desired) const {799return _kind == (u1)desired;800}801802public:803804// Other is anything that is not one of the more specialized kinds of InstanceKlass.805bool is_other_instance_klass() const { return is_kind(_kind_other); }806bool is_reference_instance_klass() const { return is_kind(_kind_reference); }807bool is_mirror_instance_klass() const { return is_kind(_kind_mirror); }808bool is_class_loader_instance_klass() const { return is_kind(_kind_class_loader); }809810#if INCLUDE_JVMTI811812void init_previous_versions() {813_previous_versions = NULL;814}815816private:817static bool _has_previous_versions;818public:819static void purge_previous_versions(InstanceKlass* ik) {820if (ik->has_been_redefined()) {821ik->purge_previous_version_list();822}823}824825static bool has_previous_versions_and_reset();826static bool has_previous_versions() { return _has_previous_versions; }827828// JVMTI: Support for caching a class file before it is modified by an agent that can do retransformation829void set_cached_class_file(JvmtiCachedClassFileData *data) {830_cached_class_file = data;831}832JvmtiCachedClassFileData * get_cached_class_file();833jint get_cached_class_file_len();834unsigned char * get_cached_class_file_bytes();835836// JVMTI: Support for caching of field indices, types, and offsets837void set_jvmti_cached_class_field_map(JvmtiCachedClassFieldMap* descriptor) {838_jvmti_cached_class_field_map = descriptor;839}840JvmtiCachedClassFieldMap* jvmti_cached_class_field_map() const {841return _jvmti_cached_class_field_map;842}843#else // INCLUDE_JVMTI844845static void purge_previous_versions(InstanceKlass* ik) { return; };846static bool has_previous_versions_and_reset() { return false; }847848void set_cached_class_file(JvmtiCachedClassFileData *data) {849assert(data == NULL, "unexpected call with JVMTI disabled");850}851JvmtiCachedClassFileData * get_cached_class_file() { return (JvmtiCachedClassFileData *)NULL; }852853#endif // INCLUDE_JVMTI854855bool has_nonstatic_concrete_methods() const {856return (_misc_flags & _misc_has_nonstatic_concrete_methods) != 0;857}858void set_has_nonstatic_concrete_methods(bool b) {859if (b) {860_misc_flags |= _misc_has_nonstatic_concrete_methods;861} else {862_misc_flags &= ~_misc_has_nonstatic_concrete_methods;863}864}865866bool declares_nonstatic_concrete_methods() const {867return (_misc_flags & _misc_declares_nonstatic_concrete_methods) != 0;868}869void set_declares_nonstatic_concrete_methods(bool b) {870if (b) {871_misc_flags |= _misc_declares_nonstatic_concrete_methods;872} else {873_misc_flags &= ~_misc_declares_nonstatic_concrete_methods;874}875}876877// for adding methods, ConstMethod::UNSET_IDNUM means no more ids available878inline u2 next_method_idnum();879void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; }880881// generics support882Symbol* generic_signature() const { return _constants->generic_signature(); }883u2 generic_signature_index() const { return _constants->generic_signature_index(); }884void set_generic_signature_index(u2 sig_index) { _constants->set_generic_signature_index(sig_index); }885886u2 enclosing_method_data(int offset) const;887u2 enclosing_method_class_index() const {888return enclosing_method_data(enclosing_method_class_index_offset);889}890u2 enclosing_method_method_index() {891return enclosing_method_data(enclosing_method_method_index_offset);892}893void set_enclosing_method_indices(u2 class_index,894u2 method_index);895896// jmethodID support897jmethodID get_jmethod_id(const methodHandle& method_h);898jmethodID get_jmethod_id_fetch_or_update(size_t idnum,899jmethodID new_id, jmethodID* new_jmeths,900jmethodID* to_dealloc_id_p,901jmethodID** to_dealloc_jmeths_p);902static void get_jmethod_id_length_value(jmethodID* cache, size_t idnum,903size_t *length_p, jmethodID* id_p);904void ensure_space_for_methodids(int start_offset = 0);905jmethodID jmethod_id_or_null(Method* method);906907// annotations support908Annotations* annotations() const { return _annotations; }909void set_annotations(Annotations* anno) { _annotations = anno; }910911AnnotationArray* class_annotations() const {912return (_annotations != NULL) ? _annotations->class_annotations() : NULL;913}914Array<AnnotationArray*>* fields_annotations() const {915return (_annotations != NULL) ? _annotations->fields_annotations() : NULL;916}917AnnotationArray* class_type_annotations() const {918return (_annotations != NULL) ? _annotations->class_type_annotations() : NULL;919}920Array<AnnotationArray*>* fields_type_annotations() const {921return (_annotations != NULL) ? _annotations->fields_type_annotations() : NULL;922}923// allocation924instanceOop allocate_instance(TRAPS);925static instanceOop allocate_instance(oop cls, TRAPS);926927// additional member function to return a handle928instanceHandle allocate_instance_handle(TRAPS);929930objArrayOop allocate_objArray(int n, int length, TRAPS);931// Helper function932static instanceOop register_finalizer(instanceOop i, TRAPS);933934// Check whether reflection/jni/jvm code is allowed to instantiate this class;935// if not, throw either an Error or an Exception.936virtual void check_valid_for_instantiation(bool throwError, TRAPS);937938// initialization939void call_class_initializer(TRAPS);940void set_initialization_state_and_notify(ClassState state, TRAPS);941942// OopMapCache support943OopMapCache* oop_map_cache() { return _oop_map_cache; }944void set_oop_map_cache(OopMapCache *cache) { _oop_map_cache = cache; }945void mask_for(const methodHandle& method, int bci, InterpreterOopMap* entry);946947// JNI identifier support (for static fields - for jni performance)948JNIid* jni_ids() { return _jni_ids; }949void set_jni_ids(JNIid* ids) { _jni_ids = ids; }950JNIid* jni_id_for(int offset);951952// maintenance of deoptimization dependencies953inline DependencyContext dependencies();954int mark_dependent_nmethods(KlassDepChange& changes);955void add_dependent_nmethod(nmethod* nm);956void remove_dependent_nmethod(nmethod* nm);957void clean_dependency_context();958959// On-stack replacement support960nmethod* osr_nmethods_head() const { return _osr_nmethods_head; };961void set_osr_nmethods_head(nmethod* h) { _osr_nmethods_head = h; };962void add_osr_nmethod(nmethod* n);963bool remove_osr_nmethod(nmethod* n);964int mark_osr_nmethods(const Method* m);965nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const;966967#if INCLUDE_JVMTI968// Breakpoint support (see methods on Method* for details)969BreakpointInfo* breakpoints() const { return _breakpoints; };970void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; };971#endif972973// support for stub routines974static ByteSize init_state_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_state)); }975JFR_ONLY(DEFINE_KLASS_TRACE_ID_OFFSET;)976static ByteSize init_thread_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_thread)); }977978// subclass/subinterface checks979bool implements_interface(Klass* k) const;980bool is_same_or_direct_interface(Klass* k) const;981982#ifdef ASSERT983// check whether this class or one of its superclasses was redefined984bool has_redefined_this_or_super() const;985#endif986987// Access to the implementor of an interface.988InstanceKlass* implementor() const;989void set_implementor(InstanceKlass* ik);990int nof_implementors() const;991void add_implementor(InstanceKlass* ik); // ik is a new class that implements this interface992void init_implementor(); // initialize993994// link this class into the implementors list of every interface it implements995void process_interfaces();996997// virtual operations from Klass998GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,999Array<InstanceKlass*>* transitive_interfaces);1000bool can_be_primary_super_slow() const;1001int oop_size(oop obj) const { return size_helper(); }1002// slow because it's a virtual call and used for verifying the layout_helper.1003// Using the layout_helper bits, we can call is_instance_klass without a virtual call.1004DEBUG_ONLY(bool is_instance_klass_slow() const { return true; })10051006// Iterators1007void do_local_static_fields(FieldClosure* cl);1008void do_nonstatic_fields(FieldClosure* cl); // including inherited fields1009void do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle, TRAPS);10101011void methods_do(void f(Method* method));1012void array_klasses_do(void f(Klass* k));1013void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);10141015static InstanceKlass* cast(Klass* k) {1016return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));1017}10181019static const InstanceKlass* cast(const Klass* k) {1020assert(k != NULL, "k should not be null");1021assert(k->is_instance_klass(), "cast to InstanceKlass");1022return static_cast<const InstanceKlass*>(k);1023}10241025virtual InstanceKlass* java_super() const {1026return (super() == NULL) ? NULL : cast(super());1027}10281029// Sizing (in words)1030static int header_size() { return sizeof(InstanceKlass)/wordSize; }10311032static int size(int vtable_length, int itable_length,1033int nonstatic_oop_map_size,1034bool is_interface) {1035return align_metadata_size(header_size() +1036vtable_length +1037itable_length +1038nonstatic_oop_map_size +1039(is_interface ? (int)sizeof(Klass*)/wordSize : 0));1040}10411042int size() const { return size(vtable_length(),1043itable_length(),1044nonstatic_oop_map_size(),1045is_interface());1046}104710481049inline intptr_t* start_of_itable() const;1050inline intptr_t* end_of_itable() const;1051inline int itable_offset_in_words() const;1052inline oop static_field_base_raw();10531054inline OopMapBlock* start_of_nonstatic_oop_maps() const;1055inline Klass** end_of_nonstatic_oop_maps() const;10561057inline InstanceKlass* volatile* adr_implementor() const;10581059// Use this to return the size of an instance in heap words:1060int size_helper() const {1061return layout_helper_to_size_helper(layout_helper());1062}10631064// This bit is initialized in classFileParser.cpp.1065// It is false under any of the following conditions:1066// - the class is abstract (including any interface)1067// - the class has a finalizer (if !RegisterFinalizersAtInit)1068// - the class size is larger than FastAllocateSizeLimit1069// - the class is java/lang/Class, which cannot be allocated directly1070bool can_be_fastpath_allocated() const {1071return !layout_helper_needs_slow_path(layout_helper());1072}10731074// Java itable1075klassItable itable() const; // return klassItable wrapper1076Method* method_at_itable(InstanceKlass* holder, int index, TRAPS);1077Method* method_at_itable_or_null(InstanceKlass* holder, int index, bool& itable_entry_found);1078int vtable_index_of_interface_method(Method* method);10791080#if INCLUDE_JVMTI1081void adjust_default_methods(bool* trace_name_printed);1082#endif // INCLUDE_JVMTI10831084void clean_weak_instanceklass_links();1085private:1086void clean_implementors_list();1087void clean_method_data();10881089public:1090// Explicit metaspace deallocation of fields1091// For RedefineClasses and class file parsing errors, we need to deallocate1092// instanceKlasses and the metadata they point to.1093void deallocate_contents(ClassLoaderData* loader_data);1094static void deallocate_methods(ClassLoaderData* loader_data,1095Array<Method*>* methods);1096void static deallocate_interfaces(ClassLoaderData* loader_data,1097const Klass* super_klass,1098Array<InstanceKlass*>* local_interfaces,1099Array<InstanceKlass*>* transitive_interfaces);1100void static deallocate_record_components(ClassLoaderData* loader_data,1101Array<RecordComponent*>* record_component);11021103// The constant pool is on stack if any of the methods are executing or1104// referenced by handles.1105bool on_stack() const { return _constants->on_stack(); }11061107// callbacks for actions during class unloading1108static void unload_class(InstanceKlass* ik);11091110virtual void release_C_heap_structures(bool release_constant_pool = true);11111112// Naming1113const char* signature_name() const;11141115// Oop fields (and metadata) iterators1116//1117// The InstanceKlass iterators also visits the Object's klass.11181119// Forward iteration1120public:1121// Iterate over all oop fields in the oop maps.1122template <typename T, class OopClosureType>1123inline void oop_oop_iterate_oop_maps(oop obj, OopClosureType* closure);11241125// Iterate over all oop fields and metadata.1126template <typename T, class OopClosureType>1127inline void oop_oop_iterate(oop obj, OopClosureType* closure);11281129// Iterate over all oop fields in one oop map.1130template <typename T, class OopClosureType>1131inline void oop_oop_iterate_oop_map(OopMapBlock* map, oop obj, OopClosureType* closure);113211331134// Reverse iteration1135// Iterate over all oop fields and metadata.1136template <typename T, class OopClosureType>1137inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure);11381139private:1140// Iterate over all oop fields in the oop maps.1141template <typename T, class OopClosureType>1142inline void oop_oop_iterate_oop_maps_reverse(oop obj, OopClosureType* closure);11431144// Iterate over all oop fields in one oop map.1145template <typename T, class OopClosureType>1146inline void oop_oop_iterate_oop_map_reverse(OopMapBlock* map, oop obj, OopClosureType* closure);114711481149// Bounded range iteration1150public:1151// Iterate over all oop fields in the oop maps.1152template <typename T, class OopClosureType>1153inline void oop_oop_iterate_oop_maps_bounded(oop obj, OopClosureType* closure, MemRegion mr);11541155// Iterate over all oop fields and metadata.1156template <typename T, class OopClosureType>1157inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr);11581159private:1160// Iterate over all oop fields in one oop map.1161template <typename T, class OopClosureType>1162inline void oop_oop_iterate_oop_map_bounded(OopMapBlock* map, oop obj, OopClosureType* closure, MemRegion mr);116311641165public:1166u2 idnum_allocated_count() const { return _idnum_allocated_count; }11671168private:1169// initialization state1170void set_init_state(ClassState state);1171void set_rewritten() { _misc_flags |= _misc_rewritten; }1172void set_init_thread(Thread *thread) { _init_thread = thread; }11731174// The RedefineClasses() API can cause new method idnums to be needed1175// which will cause the caches to grow. Safety requires different1176// cache management logic if the caches can grow instead of just1177// going from NULL to non-NULL.1178bool idnum_can_increment() const { return has_been_redefined(); }1179inline jmethodID* methods_jmethod_ids_acquire() const;1180inline void release_set_methods_jmethod_ids(jmethodID* jmeths);11811182// Lock during initialization1183public:1184// Lock for (1) initialization; (2) access to the ConstantPool of this class.1185// Must be one per class and it has to be a VM internal object so java code1186// cannot lock it (like the mirror).1187// It has to be an object not a Mutex because it's held through java calls.1188oop init_lock() const;11891190// Returns the array class for the n'th dimension1191virtual Klass* array_klass(int n, TRAPS);1192virtual Klass* array_klass_or_null(int n);11931194// Returns the array class with this class as element type1195virtual Klass* array_klass(TRAPS);1196virtual Klass* array_klass_or_null();11971198private:1199void fence_and_clear_init_lock();12001201bool link_class_impl (TRAPS);1202bool verify_code (TRAPS);1203void initialize_impl (TRAPS);1204void initialize_super_interfaces (TRAPS);1205void eager_initialize_impl ();12061207// find a local method (returns NULL if not found)1208Method* find_method_impl(const Symbol* name,1209const Symbol* signature,1210OverpassLookupMode overpass_mode,1211StaticLookupMode static_mode,1212PrivateLookupMode private_mode) const;12131214static Method* find_method_impl(const Array<Method*>* methods,1215const Symbol* name,1216const Symbol* signature,1217OverpassLookupMode overpass_mode,1218StaticLookupMode static_mode,1219PrivateLookupMode private_mode);12201221#if INCLUDE_JVMTI1222// RedefineClasses support1223void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }1224void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);1225#endif1226// log class name to classlist1227void log_to_classlist() const;1228public:1229// CDS support - remove and restore oops from metadata. Oops are not shared.1230virtual void remove_unshareable_info();1231virtual void remove_java_mirror();1232void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);1233void init_shared_package_entry();1234bool can_be_verified_at_dumptime() const;12351236jint compute_modifier_flags() const;12371238public:1239// JVMTI support1240jint jvmti_class_status() const;12411242virtual void metaspace_pointers_do(MetaspaceClosure* iter);12431244public:1245// Printing1246void print_on(outputStream* st) const;1247void print_value_on(outputStream* st) const;12481249void oop_print_value_on(oop obj, outputStream* st);12501251void oop_print_on (oop obj, outputStream* st);12521253#ifndef PRODUCT1254void print_dependent_nmethods(bool verbose = false);1255bool is_dependent_nmethod(nmethod* nm);1256bool verify_itable_index(int index);1257#endif12581259const char* internal_name() const;12601261// Verification1262void verify_on(outputStream* st);12631264void oop_verify_on(oop obj, outputStream* st);12651266// Logging1267void print_class_load_logging(ClassLoaderData* loader_data,1268const ModuleEntry* module_entry,1269const ClassFileStream* cfs) const;1270};12711272// for adding methods1273// UNSET_IDNUM return means no more ids available1274inline u2 InstanceKlass::next_method_idnum() {1275if (_idnum_allocated_count == ConstMethod::MAX_IDNUM) {1276return ConstMethod::UNSET_IDNUM; // no more ids available1277} else {1278return _idnum_allocated_count++;1279}1280}128112821283/* JNIid class for jfieldIDs only */1284class JNIid: public CHeapObj<mtClass> {1285friend class VMStructs;1286private:1287Klass* _holder;1288JNIid* _next;1289int _offset;1290#ifdef ASSERT1291bool _is_static_field_id;1292#endif12931294public:1295// Accessors1296Klass* holder() const { return _holder; }1297int offset() const { return _offset; }1298JNIid* next() { return _next; }1299// Constructor1300JNIid(Klass* holder, int offset, JNIid* next);1301// Identifier lookup1302JNIid* find(int offset);13031304bool find_local_field(fieldDescriptor* fd) {1305return InstanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd);1306}13071308static void deallocate(JNIid* id);1309// Debugging1310#ifdef ASSERT1311bool is_static_field_id() const { return _is_static_field_id; }1312void set_is_static_field_id() { _is_static_field_id = true; }1313#endif1314void verify(Klass* holder);1315};13161317// An iterator that's used to access the inner classes indices in the1318// InstanceKlass::_inner_classes array.1319class InnerClassesIterator : public StackObj {1320private:1321Array<jushort>* _inner_classes;1322int _length;1323int _idx;1324public:13251326InnerClassesIterator(const InstanceKlass* k) {1327_inner_classes = k->inner_classes();1328if (k->inner_classes() != NULL) {1329_length = _inner_classes->length();1330// The inner class array's length should be the multiple of1331// inner_class_next_offset if it only contains the InnerClasses1332// attribute data, or it should be1333// n*inner_class_next_offset+enclosing_method_attribute_size1334// if it also contains the EnclosingMethod data.1335assert((_length % InstanceKlass::inner_class_next_offset == 0 ||1336_length % InstanceKlass::inner_class_next_offset == InstanceKlass::enclosing_method_attribute_size),1337"just checking");1338// Remove the enclosing_method portion if exists.1339if (_length % InstanceKlass::inner_class_next_offset == InstanceKlass::enclosing_method_attribute_size) {1340_length -= InstanceKlass::enclosing_method_attribute_size;1341}1342} else {1343_length = 0;1344}1345_idx = 0;1346}13471348int length() const {1349return _length;1350}13511352void next() {1353_idx += InstanceKlass::inner_class_next_offset;1354}13551356bool done() const {1357return (_idx >= _length);1358}13591360u2 inner_class_info_index() const {1361return _inner_classes->at(1362_idx + InstanceKlass::inner_class_inner_class_info_offset);1363}13641365void set_inner_class_info_index(u2 index) {1366_inner_classes->at_put(1367_idx + InstanceKlass::inner_class_inner_class_info_offset, index);1368}13691370u2 outer_class_info_index() const {1371return _inner_classes->at(1372_idx + InstanceKlass::inner_class_outer_class_info_offset);1373}13741375void set_outer_class_info_index(u2 index) {1376_inner_classes->at_put(1377_idx + InstanceKlass::inner_class_outer_class_info_offset, index);1378}13791380u2 inner_name_index() const {1381return _inner_classes->at(1382_idx + InstanceKlass::inner_class_inner_name_offset);1383}13841385void set_inner_name_index(u2 index) {1386_inner_classes->at_put(1387_idx + InstanceKlass::inner_class_inner_name_offset, index);1388}13891390u2 inner_access_flags() const {1391return _inner_classes->at(1392_idx + InstanceKlass::inner_class_access_flags_offset);1393}1394};13951396// Iterator over class hierarchy under a particular class. Implements depth-first pre-order traversal.1397// Usage:1398// for (ClassHierarchyIterator iter(root_klass); !iter.done(); iter.next()) {1399// Klass* k = iter.klass();1400// ...1401// }1402class ClassHierarchyIterator : public StackObj {1403private:1404InstanceKlass* _root;1405Klass* _current;1406bool _visit_subclasses;14071408public:1409ClassHierarchyIterator(InstanceKlass* root) : _root(root), _current(root), _visit_subclasses(true) {1410assert(_root == _current, "required"); // initial state1411}14121413bool done() {1414return (_current == NULL);1415}14161417// Make a step iterating over the class hierarchy under the root class.1418// Skips subclasses if requested.1419void next();14201421Klass* klass() {1422assert(!done(), "sanity");1423return _current;1424}14251426// Skip subclasses of the current class.1427void skip_subclasses() {1428_visit_subclasses = false;1429}1430};14311432#endif // SHARE_OOPS_INSTANCEKLASS_HPP143314341435