Path: blob/master/src/hotspot/share/oops/klass.hpp
64441 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_KLASS_HPP25#define SHARE_OOPS_KLASS_HPP2627#include "memory/iterator.hpp"28#include "memory/memRegion.hpp"29#include "oops/markWord.hpp"30#include "oops/metadata.hpp"31#include "oops/oop.hpp"32#include "oops/oopHandle.hpp"33#include "utilities/accessFlags.hpp"34#include "utilities/macros.hpp"35#if INCLUDE_JFR36#include "jfr/support/jfrTraceIdExtension.hpp"37#endif3839// Klass IDs for all subclasses of Klass40enum KlassID {41InstanceKlassID,42InstanceRefKlassID,43InstanceMirrorKlassID,44InstanceClassLoaderKlassID,45TypeArrayKlassID,46ObjArrayKlassID47};4849const uint KLASS_ID_COUNT = 6;5051//52// A Klass provides:53// 1: language level class object (method dictionary etc.)54// 2: provide vm dispatch behavior for the object55// Both functions are combined into one C++ class.5657// One reason for the oop/klass dichotomy in the implementation is58// that we don't want a C++ vtbl pointer in every object. Thus,59// normal oops don't have any virtual functions. Instead, they60// forward all "virtual" functions to their klass, which does have61// a vtbl and does the C++ dispatch depending on the object's62// actual type. (See oop.inline.hpp for some of the forwarding code.)63// ALL FUNCTIONS IMPLEMENTING THIS DISPATCH ARE PREFIXED WITH "oop_"!6465// Forward declarations.66template <class T> class Array;67template <class T> class GrowableArray;68class ClassLoaderData;69class fieldDescriptor;70class klassVtable;71class ModuleEntry;72class PackageEntry;73class ParCompactionManager;74class PSPromotionManager;75class vtableEntry;7677class Klass : public Metadata {78friend class VMStructs;79friend class JVMCIVMStructs;80protected:81// If you add a new field that points to any metaspace object, you82// must add this field to Klass::metaspace_pointers_do().8384// note: put frequently-used fields together at start of klass structure85// for better cache behavior (may not make much of a difference but sure won't hurt)86enum { _primary_super_limit = 8 };8788// The "layout helper" is a combined descriptor of object layout.89// For klasses which are neither instance nor array, the value is zero.90//91// For instances, layout helper is a positive number, the instance size.92// This size is already passed through align_object_size and scaled to bytes.93// The low order bit is set if instances of this class cannot be94// allocated using the fastpath.95//96// For arrays, layout helper is a negative number, containing four97// distinct bytes, as follows:98// MSB:[tag, hsz, ebt, log2(esz)]:LSB99// where:100// tag is 0x80 if the elements are oops, 0xC0 if non-oops101// hsz is array header size in bytes (i.e., offset of first element)102// ebt is the BasicType of the elements103// esz is the element size in bytes104// This packed word is arranged so as to be quickly unpacked by the105// various fast paths that use the various subfields.106//107// The esz bits can be used directly by a SLL instruction, without masking.108//109// Note that the array-kind tag looks like 0x00 for instance klasses,110// since their length in bytes is always less than 24Mb.111//112// Final note: This comes first, immediately after C++ vtable,113// because it is frequently queried.114jint _layout_helper;115116// Klass identifier used to implement devirtualized oop closure dispatching.117const KlassID _id;118119// Processed access flags, for use by Class.getModifiers.120jint _modifier_flags;121122// The fields _super_check_offset, _secondary_super_cache, _secondary_supers123// and _primary_supers all help make fast subtype checks. See big discussion124// in doc/server_compiler/checktype.txt125//126// Where to look to observe a supertype (it is &_secondary_super_cache for127// secondary supers, else is &_primary_supers[depth()].128juint _super_check_offset;129130// Class name. Instance classes: java/lang/String, etc. Array classes: [I,131// [Ljava/lang/String;, etc. Set to zero for all other kinds of classes.132Symbol* _name;133134// Cache of last observed secondary supertype135Klass* _secondary_super_cache;136// Array of all secondary supertypes137Array<Klass*>* _secondary_supers;138// Ordered list of all primary supertypes139Klass* _primary_supers[_primary_super_limit];140// java/lang/Class instance mirroring this class141OopHandle _java_mirror;142// Superclass143Klass* _super;144// First subclass (NULL if none); _subklass->next_sibling() is next one145Klass* volatile _subklass;146// Sibling link (or NULL); links all subklasses of a klass147Klass* volatile _next_sibling;148149// All klasses loaded by a class loader are chained through these links150Klass* _next_link;151152// The VM's representation of the ClassLoader used to load this class.153// Provide access the corresponding instance java.lang.ClassLoader.154ClassLoaderData* _class_loader_data;155156int _vtable_len; // vtable length. This field may be read very often when we157// have lots of itable dispatches (e.g., lambdas and streams).158// Keep it away from the beginning of a Klass to avoid cacheline159// contention that may happen when a nearby object is modified.160AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here.161162JFR_ONLY(DEFINE_TRACE_ID_FIELD;)163164// Biased locking implementation and statistics165// (the 64-bit chunk goes first, to avoid some fragmentation)166jlong _last_biased_lock_bulk_revocation_time;167markWord _prototype_header; // Used when biased locking is both enabled and disabled for this type168jint _biased_lock_revocation_count;169170private:171// This is an index into FileMapHeader::_shared_path_table[], to172// associate this class with the JAR file where it's loaded from during173// dump time. If a class is not loaded from the shared archive, this field is174// -1.175jshort _shared_class_path_index;176177#if INCLUDE_CDS178// Flags of the current shared class.179u2 _shared_class_flags;180enum {181_archived_lambda_proxy_is_available = 2,182_has_value_based_class_annotation = 4,183_verified_at_dump_time = 8184};185#endif186187CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;)188189protected:190191// Constructor192Klass(KlassID id);193Klass() : _id(KlassID(-1)) { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }194195void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();196197public:198int id() { return _id; }199200enum class DefaultsLookupMode { find, skip };201enum class OverpassLookupMode { find, skip };202enum class StaticLookupMode { find, skip };203enum class PrivateLookupMode { find, skip };204205virtual bool is_klass() const { return true; }206207// super() cannot be InstanceKlass* -- Java arrays are covariant, and _super is used208// to implement that. NB: the _super of "[Ljava/lang/Integer;" is "[Ljava/lang/Number;"209// If this is not what your code expects, you're probably looking for Klass::java_super().210Klass* super() const { return _super; }211void set_super(Klass* k) { _super = k; }212213// initializes _super link, _primary_supers & _secondary_supers arrays214void initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS);215216// klass-specific helper for initializing _secondary_supers217virtual GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,218Array<InstanceKlass*>* transitive_interfaces);219220// java_super is the Java-level super type as specified by Class.getSuperClass.221virtual InstanceKlass* java_super() const { return NULL; }222223juint super_check_offset() const { return _super_check_offset; }224void set_super_check_offset(juint o) { _super_check_offset = o; }225226Klass* secondary_super_cache() const { return _secondary_super_cache; }227void set_secondary_super_cache(Klass* k) { _secondary_super_cache = k; }228229Array<Klass*>* secondary_supers() const { return _secondary_supers; }230void set_secondary_supers(Array<Klass*>* k) { _secondary_supers = k; }231232// Return the element of the _super chain of the given depth.233// If there is no such element, return either NULL or this.234Klass* primary_super_of_depth(juint i) const {235assert(i < primary_super_limit(), "oob");236Klass* super = _primary_supers[i];237assert(super == NULL || super->super_depth() == i, "correct display");238return super;239}240241// Can this klass be a primary super? False for interfaces and arrays of242// interfaces. False also for arrays or classes with long super chains.243bool can_be_primary_super() const {244const juint secondary_offset = in_bytes(secondary_super_cache_offset());245return super_check_offset() != secondary_offset;246}247virtual bool can_be_primary_super_slow() const;248249// Returns number of primary supers; may be a number in the inclusive range [0, primary_super_limit].250juint super_depth() const {251if (!can_be_primary_super()) {252return primary_super_limit();253} else {254juint d = (super_check_offset() - in_bytes(primary_supers_offset())) / sizeof(Klass*);255assert(d < primary_super_limit(), "oob");256assert(_primary_supers[d] == this, "proper init");257return d;258}259}260261// java mirror262oop java_mirror() const;263oop java_mirror_no_keepalive() const;264void set_java_mirror(Handle m);265266oop archived_java_mirror() NOT_CDS_JAVA_HEAP_RETURN_(NULL);267void set_archived_java_mirror(oop m) NOT_CDS_JAVA_HEAP_RETURN;268269// Temporary mirror switch used by RedefineClasses270void replace_java_mirror(oop mirror);271272// Set java mirror OopHandle to NULL for CDS273// This leaves the OopHandle in the CLD, but that's ok, you can't release them.274void clear_java_mirror_handle() { _java_mirror = OopHandle(); }275276// modifier flags277jint modifier_flags() const { return _modifier_flags; }278void set_modifier_flags(jint flags) { _modifier_flags = flags; }279280// size helper281int layout_helper() const { return _layout_helper; }282void set_layout_helper(int lh) { _layout_helper = lh; }283284// Note: for instances layout_helper() may include padding.285// Use InstanceKlass::contains_field_offset to classify field offsets.286287// sub/superklass links288Klass* subklass(bool log = false) const;289Klass* next_sibling(bool log = false) const;290291InstanceKlass* superklass() const;292void append_to_sibling_list(); // add newly created receiver to superklass' subklass list293294void set_next_link(Klass* k) { _next_link = k; }295Klass* next_link() const { return _next_link; } // The next klass defined by the class loader.296Klass** next_link_addr() { return &_next_link; }297298// class loader data299ClassLoaderData* class_loader_data() const { return _class_loader_data; }300void set_class_loader_data(ClassLoaderData* loader_data) { _class_loader_data = loader_data; }301302int shared_classpath_index() const {303return _shared_class_path_index;304};305306void set_shared_classpath_index(int index) {307_shared_class_path_index = index;308};309310bool has_archived_mirror_index() const {311CDS_JAVA_HEAP_ONLY(return _archived_mirror_index >= 0;)312NOT_CDS_JAVA_HEAP(return false);313}314315void clear_archived_mirror_index() NOT_CDS_JAVA_HEAP_RETURN;316317void set_lambda_proxy_is_available() {318CDS_ONLY(_shared_class_flags |= _archived_lambda_proxy_is_available;)319}320void clear_lambda_proxy_is_available() {321CDS_ONLY(_shared_class_flags &= ~_archived_lambda_proxy_is_available;)322}323bool lambda_proxy_is_available() const {324CDS_ONLY(return (_shared_class_flags & _archived_lambda_proxy_is_available) != 0;)325NOT_CDS(return false;)326}327328void set_has_value_based_class_annotation() {329CDS_ONLY(_shared_class_flags |= _has_value_based_class_annotation;)330}331void clear_has_value_based_class_annotation() {332CDS_ONLY(_shared_class_flags &= ~_has_value_based_class_annotation;)333}334bool has_value_based_class_annotation() const {335CDS_ONLY(return (_shared_class_flags & _has_value_based_class_annotation) != 0;)336NOT_CDS(return false;)337}338339void set_verified_at_dump_time() {340CDS_ONLY(_shared_class_flags |= _verified_at_dump_time;)341}342bool verified_at_dump_time() const {343CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)344NOT_CDS(return false;)345}346347348// Obtain the module or package for this class349virtual ModuleEntry* module() const = 0;350virtual PackageEntry* package() const = 0;351352protected: // internal accessors353void set_subklass(Klass* s);354void set_next_sibling(Klass* s);355356public:357358// Compiler support359static ByteSize super_offset() { return in_ByteSize(offset_of(Klass, _super)); }360static ByteSize super_check_offset_offset() { return in_ByteSize(offset_of(Klass, _super_check_offset)); }361static ByteSize primary_supers_offset() { return in_ByteSize(offset_of(Klass, _primary_supers)); }362static ByteSize secondary_super_cache_offset() { return in_ByteSize(offset_of(Klass, _secondary_super_cache)); }363static ByteSize secondary_supers_offset() { return in_ByteSize(offset_of(Klass, _secondary_supers)); }364static ByteSize java_mirror_offset() { return in_ByteSize(offset_of(Klass, _java_mirror)); }365static ByteSize class_loader_data_offset() { return in_ByteSize(offset_of(Klass, _class_loader_data)); }366static ByteSize modifier_flags_offset() { return in_ByteSize(offset_of(Klass, _modifier_flags)); }367static ByteSize layout_helper_offset() { return in_ByteSize(offset_of(Klass, _layout_helper)); }368static ByteSize access_flags_offset() { return in_ByteSize(offset_of(Klass, _access_flags)); }369370// Unpacking layout_helper:371static const int _lh_neutral_value = 0; // neutral non-array non-instance value372static const int _lh_instance_slow_path_bit = 0x01;373static const int _lh_log2_element_size_shift = BitsPerByte*0;374static const int _lh_log2_element_size_mask = BitsPerLong-1;375static const int _lh_element_type_shift = BitsPerByte*1;376static const int _lh_element_type_mask = right_n_bits(BitsPerByte); // shifted mask377static const int _lh_header_size_shift = BitsPerByte*2;378static const int _lh_header_size_mask = right_n_bits(BitsPerByte); // shifted mask379static const int _lh_array_tag_bits = 2;380static const int _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits;381static const int _lh_array_tag_obj_value = ~0x01; // 0x80000000 >> 30382383static const unsigned int _lh_array_tag_type_value = 0Xffffffff; // ~0x00, // 0xC0000000 >> 30384385static int layout_helper_size_in_bytes(jint lh) {386assert(lh > (jint)_lh_neutral_value, "must be instance");387return (int) lh & ~_lh_instance_slow_path_bit;388}389static bool layout_helper_needs_slow_path(jint lh) {390assert(lh > (jint)_lh_neutral_value, "must be instance");391return (lh & _lh_instance_slow_path_bit) != 0;392}393static bool layout_helper_is_instance(jint lh) {394return (jint)lh > (jint)_lh_neutral_value;395}396static bool layout_helper_is_array(jint lh) {397return (jint)lh < (jint)_lh_neutral_value;398}399static bool layout_helper_is_typeArray(jint lh) {400// _lh_array_tag_type_value == (lh >> _lh_array_tag_shift);401return (juint)lh >= (juint)(_lh_array_tag_type_value << _lh_array_tag_shift);402}403static bool layout_helper_is_objArray(jint lh) {404// _lh_array_tag_obj_value == (lh >> _lh_array_tag_shift);405return (jint)lh < (jint)(_lh_array_tag_type_value << _lh_array_tag_shift);406}407static int layout_helper_header_size(jint lh) {408assert(lh < (jint)_lh_neutral_value, "must be array");409int hsize = (lh >> _lh_header_size_shift) & _lh_header_size_mask;410assert(hsize > 0 && hsize < (int)sizeof(oopDesc)*3, "sanity");411return hsize;412}413static BasicType layout_helper_element_type(jint lh) {414assert(lh < (jint)_lh_neutral_value, "must be array");415int btvalue = (lh >> _lh_element_type_shift) & _lh_element_type_mask;416assert(btvalue >= T_BOOLEAN && btvalue <= T_OBJECT, "sanity");417return (BasicType) btvalue;418}419420// Want a pattern to quickly diff against layout header in register421// find something less clever!422static int layout_helper_boolean_diffbit() {423jint zlh = array_layout_helper(T_BOOLEAN);424jint blh = array_layout_helper(T_BYTE);425assert(zlh != blh, "array layout helpers must differ");426int diffbit = 1;427while ((diffbit & (zlh ^ blh)) == 0 && (diffbit & zlh) == 0) {428diffbit <<= 1;429assert(diffbit != 0, "make sure T_BOOLEAN has a different bit than T_BYTE");430}431return diffbit;432}433434static int layout_helper_log2_element_size(jint lh) {435assert(lh < (jint)_lh_neutral_value, "must be array");436int l2esz = (lh >> _lh_log2_element_size_shift) & _lh_log2_element_size_mask;437assert(l2esz <= LogBytesPerLong,438"sanity. l2esz: 0x%x for lh: 0x%x", (uint)l2esz, (uint)lh);439return l2esz;440}441static jint array_layout_helper(jint tag, int hsize, BasicType etype, int log2_esize) {442return (tag << _lh_array_tag_shift)443| (hsize << _lh_header_size_shift)444| ((int)etype << _lh_element_type_shift)445| (log2_esize << _lh_log2_element_size_shift);446}447static jint instance_layout_helper(jint size, bool slow_path_flag) {448return (size << LogBytesPerWord)449| (slow_path_flag ? _lh_instance_slow_path_bit : 0);450}451static int layout_helper_to_size_helper(jint lh) {452assert(lh > (jint)_lh_neutral_value, "must be instance");453// Note that the following expression discards _lh_instance_slow_path_bit.454return lh >> LogBytesPerWord;455}456// Out-of-line version computes everything based on the etype:457static jint array_layout_helper(BasicType etype);458459// What is the maximum number of primary superclasses any klass can have?460static juint primary_super_limit() { return _primary_super_limit; }461462// vtables463klassVtable vtable() const;464int vtable_length() const { return _vtable_len; }465466// subclass check467bool is_subclass_of(const Klass* k) const;468// subtype check: true if is_subclass_of, or if k is interface and receiver implements it469bool is_subtype_of(Klass* k) const {470juint off = k->super_check_offset();471Klass* sup = *(Klass**)( (address)this + off );472const juint secondary_offset = in_bytes(secondary_super_cache_offset());473if (sup == k) {474return true;475} else if (off != secondary_offset) {476return false;477} else {478return search_secondary_supers(k);479}480}481482bool search_secondary_supers(Klass* k) const;483484// Find LCA in class hierarchy485Klass *LCA( Klass *k );486487// Check whether reflection/jni/jvm code is allowed to instantiate this class;488// if not, throw either an Error or an Exception.489virtual void check_valid_for_instantiation(bool throwError, TRAPS);490491// array copying492virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);493494// tells if the class should be initialized495virtual bool should_be_initialized() const { return false; }496// initializes the klass497virtual void initialize(TRAPS);498virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const;499virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature,500OverpassLookupMode overpass_mode,501PrivateLookupMode = PrivateLookupMode::find) const;502public:503Method* lookup_method(const Symbol* name, const Symbol* signature) const {504return uncached_lookup_method(name, signature, OverpassLookupMode::find);505}506507// array class with specific rank508virtual Klass* array_klass(int rank, TRAPS) = 0;509510// array class with this klass as element type511virtual Klass* array_klass(TRAPS) = 0;512513// These will return NULL instead of allocating on the heap:514virtual Klass* array_klass_or_null(int rank) = 0;515virtual Klass* array_klass_or_null() = 0;516517virtual oop protection_domain() const = 0;518519oop class_loader() const;520521inline oop klass_holder() const;522523protected:524525// Error handling when length > max_length or length < 0526static void check_array_allocation_length(int length, int max_length, TRAPS);527528void set_vtable_length(int len) { _vtable_len= len; }529530vtableEntry* start_of_vtable() const;531void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);532public:533Method* method_at_vtable(int index);534535static ByteSize vtable_start_offset();536static ByteSize vtable_length_offset() {537return byte_offset_of(Klass, _vtable_len);538}539540// CDS support - remove and restore oops from metadata. Oops are not shared.541virtual void remove_unshareable_info();542virtual void remove_java_mirror();543544bool is_unshareable_info_restored() const {545assert(is_shared(), "use this for shared classes only");546if (has_archived_mirror_index()) {547// _java_mirror is not a valid OopHandle but rather an encoded reference in the shared heap548return false;549} else if (_java_mirror.ptr_raw() == NULL) {550return false;551} else {552return true;553}554}555556public:557// ALL FUNCTIONS BELOW THIS POINT ARE DISPATCHED FROM AN OOP558// These functions describe behavior for the oop not the KLASS.559560// actual oop size of obj in memory561virtual int oop_size(oop obj) const = 0;562563// Size of klass in word size.564virtual int size() const = 0;565566// Returns the Java name for a class (Resource allocated)567// For arrays, this returns the name of the element with a leading '['.568// For classes, this returns the name with the package separators569// turned into '.'s.570const char* external_name() const;571// Returns the name for a class (Resource allocated) as the class572// would appear in a signature.573// For arrays, this returns the name of the element with a leading '['.574// For classes, this returns the name with a leading 'L' and a trailing ';'575// and the package separators as '/'.576virtual const char* signature_name() const;577578const char* joint_in_module_of_loader(const Klass* class2, bool include_parent_loader = false) const;579const char* class_in_module_of_loader(bool use_are = false, bool include_parent_loader = false) const;580581// Returns "interface", "abstract class" or "class".582const char* external_kind() const;583584// type testing operations585#ifdef ASSERT586protected:587virtual bool is_instance_klass_slow() const { return false; }588virtual bool is_array_klass_slow() const { return false; }589virtual bool is_objArray_klass_slow() const { return false; }590virtual bool is_typeArray_klass_slow() const { return false; }591#endif // ASSERT592public:593594// Fast non-virtual versions595#ifndef ASSERT596#define assert_same_query(xval, xcheck) xval597#else598private:599static bool assert_same_query(bool xval, bool xslow) {600assert(xval == xslow, "slow and fast queries agree");601return xval;602}603public:604#endif605inline bool is_instance_klass() const { return assert_same_query(606layout_helper_is_instance(layout_helper()),607is_instance_klass_slow()); }608inline bool is_array_klass() const { return assert_same_query(609layout_helper_is_array(layout_helper()),610is_array_klass_slow()); }611inline bool is_objArray_klass() const { return assert_same_query(612layout_helper_is_objArray(layout_helper()),613is_objArray_klass_slow()); }614inline bool is_typeArray_klass() const { return assert_same_query(615layout_helper_is_typeArray(layout_helper()),616is_typeArray_klass_slow()); }617#undef assert_same_query618619// Access flags620AccessFlags access_flags() const { return _access_flags; }621void set_access_flags(AccessFlags flags) { _access_flags = flags; }622623bool is_public() const { return _access_flags.is_public(); }624bool is_final() const { return _access_flags.is_final(); }625bool is_interface() const { return _access_flags.is_interface(); }626bool is_abstract() const { return _access_flags.is_abstract(); }627bool is_super() const { return _access_flags.is_super(); }628bool is_synthetic() const { return _access_flags.is_synthetic(); }629void set_is_synthetic() { _access_flags.set_is_synthetic(); }630bool has_finalizer() const { return _access_flags.has_finalizer(); }631bool has_final_method() const { return _access_flags.has_final_method(); }632void set_has_finalizer() { _access_flags.set_has_finalizer(); }633void set_has_final_method() { _access_flags.set_has_final_method(); }634bool has_vanilla_constructor() const { return _access_flags.has_vanilla_constructor(); }635void set_has_vanilla_constructor() { _access_flags.set_has_vanilla_constructor(); }636bool has_miranda_methods () const { return access_flags().has_miranda_methods(); }637void set_has_miranda_methods() { _access_flags.set_has_miranda_methods(); }638bool is_shared() const { return access_flags().is_shared_class(); } // shadows MetaspaceObj::is_shared)()639void set_is_shared() { _access_flags.set_is_shared_class(); }640bool is_hidden() const { return access_flags().is_hidden_class(); }641void set_is_hidden() { _access_flags.set_is_hidden_class(); }642bool is_value_based() { return _access_flags.is_value_based_class(); }643void set_is_value_based() { _access_flags.set_is_value_based_class(); }644645inline bool is_non_strong_hidden() const;646647bool is_cloneable() const;648void set_is_cloneable();649650// Biased locking support651// Note: the prototype header is always set up to be at least the652// prototype markWord. If biased locking is enabled it may further be653// biasable and have an epoch.654markWord prototype_header() const { return _prototype_header; }655656// NOTE: once instances of this klass are floating around in the657// system, this header must only be updated at a safepoint.658// NOTE 2: currently we only ever set the prototype header to the659// biasable prototype for instanceKlasses. There is no technical660// reason why it could not be done for arrayKlasses aside from661// wanting to reduce the initial scope of this optimization. There662// are potential problems in setting the bias pattern for663// JVM-internal oops.664inline void set_prototype_header(markWord header);665static ByteSize prototype_header_offset() { return in_ByteSize(offset_of(Klass, _prototype_header)); }666667int biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }668// Atomically increments biased_lock_revocation_count and returns updated value669int atomic_incr_biased_lock_revocation_count();670void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }671jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }672void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }673674JFR_ONLY(DEFINE_TRACE_ID_METHODS;)675676virtual void metaspace_pointers_do(MetaspaceClosure* iter);677virtual MetaspaceObj::Type type() const { return ClassType; }678679inline bool is_loader_alive() const;680681void clean_subklass();682683static void clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses = true);684static void clean_subklass_tree() {685clean_weak_klass_links(/*unloading_occurred*/ true , /* clean_alive_klasses */ false);686}687688virtual void array_klasses_do(void f(Klass* k)) {}689690// Return self, except for abstract classes with exactly 1691// implementor. Then return the 1 concrete implementation.692Klass *up_cast_abstract();693694// klass name695Symbol* name() const { return _name; }696void set_name(Symbol* n);697698virtual void release_C_heap_structures(bool release_constant_pool = true);699700public:701virtual jint compute_modifier_flags() const = 0;702703// JVMTI support704virtual jint jvmti_class_status() const;705706// Printing707virtual void print_on(outputStream* st) const;708709virtual void oop_print_value_on(oop obj, outputStream* st);710virtual void oop_print_on (oop obj, outputStream* st);711712virtual const char* internal_name() const = 0;713714// Verification715virtual void verify_on(outputStream* st);716void verify() { verify_on(tty); }717718#ifndef PRODUCT719bool verify_vtable_index(int index);720#endif721722virtual void oop_verify_on(oop obj, outputStream* st);723724// for error reporting725static bool is_valid(Klass* k);726};727728#endif // SHARE_OOPS_KLASS_HPP729730731