Path: blob/master/src/hotspot/share/oops/klass.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_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// vtable length120int _vtable_len;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;155156jint _modifier_flags; // Processed access flags, for use by Class.getModifiers.157AccessFlags _access_flags; // Access flags. The class/interface distinction is stored here.158159JFR_ONLY(DEFINE_TRACE_ID_FIELD;)160161// Biased locking implementation and statistics162// (the 64-bit chunk goes first, to avoid some fragmentation)163jlong _last_biased_lock_bulk_revocation_time;164markWord _prototype_header; // Used when biased locking is both enabled and disabled for this type165jint _biased_lock_revocation_count;166167private:168// This is an index into FileMapHeader::_shared_path_table[], to169// associate this class with the JAR file where it's loaded from during170// dump time. If a class is not loaded from the shared archive, this field is171// -1.172jshort _shared_class_path_index;173174#if INCLUDE_CDS175// Flags of the current shared class.176u2 _shared_class_flags;177enum {178_archived_lambda_proxy_is_available = 2,179_has_value_based_class_annotation = 4,180_is_shared_old_klass = 8181};182#endif183184CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;)185186protected:187188// Constructor189Klass(KlassID id);190Klass() : _id(KlassID(-1)) { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }191192void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();193194public:195int id() { return _id; }196197enum class DefaultsLookupMode { find, skip };198enum class OverpassLookupMode { find, skip };199enum class StaticLookupMode { find, skip };200enum class PrivateLookupMode { find, skip };201202virtual bool is_klass() const { return true; }203204// super() cannot be InstanceKlass* -- Java arrays are covariant, and _super is used205// to implement that. NB: the _super of "[Ljava/lang/Integer;" is "[Ljava/lang/Number;"206// If this is not what your code expects, you're probably looking for Klass::java_super().207Klass* super() const { return _super; }208void set_super(Klass* k) { _super = k; }209210// initializes _super link, _primary_supers & _secondary_supers arrays211void initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS);212213// klass-specific helper for initializing _secondary_supers214virtual GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,215Array<InstanceKlass*>* transitive_interfaces);216217// java_super is the Java-level super type as specified by Class.getSuperClass.218virtual InstanceKlass* java_super() const { return NULL; }219220juint super_check_offset() const { return _super_check_offset; }221void set_super_check_offset(juint o) { _super_check_offset = o; }222223Klass* secondary_super_cache() const { return _secondary_super_cache; }224void set_secondary_super_cache(Klass* k) { _secondary_super_cache = k; }225226Array<Klass*>* secondary_supers() const { return _secondary_supers; }227void set_secondary_supers(Array<Klass*>* k) { _secondary_supers = k; }228229// Return the element of the _super chain of the given depth.230// If there is no such element, return either NULL or this.231Klass* primary_super_of_depth(juint i) const {232assert(i < primary_super_limit(), "oob");233Klass* super = _primary_supers[i];234assert(super == NULL || super->super_depth() == i, "correct display");235return super;236}237238// Can this klass be a primary super? False for interfaces and arrays of239// interfaces. False also for arrays or classes with long super chains.240bool can_be_primary_super() const {241const juint secondary_offset = in_bytes(secondary_super_cache_offset());242return super_check_offset() != secondary_offset;243}244virtual bool can_be_primary_super_slow() const;245246// Returns number of primary supers; may be a number in the inclusive range [0, primary_super_limit].247juint super_depth() const {248if (!can_be_primary_super()) {249return primary_super_limit();250} else {251juint d = (super_check_offset() - in_bytes(primary_supers_offset())) / sizeof(Klass*);252assert(d < primary_super_limit(), "oob");253assert(_primary_supers[d] == this, "proper init");254return d;255}256}257258// java mirror259oop java_mirror() const;260oop java_mirror_no_keepalive() const;261void set_java_mirror(Handle m);262263oop archived_java_mirror() NOT_CDS_JAVA_HEAP_RETURN_(NULL);264void set_archived_java_mirror(oop m) NOT_CDS_JAVA_HEAP_RETURN;265266// Temporary mirror switch used by RedefineClasses267void replace_java_mirror(oop mirror);268269// Set java mirror OopHandle to NULL for CDS270// This leaves the OopHandle in the CLD, but that's ok, you can't release them.271void clear_java_mirror_handle() { _java_mirror = OopHandle(); }272273// modifier flags274jint modifier_flags() const { return _modifier_flags; }275void set_modifier_flags(jint flags) { _modifier_flags = flags; }276277// size helper278int layout_helper() const { return _layout_helper; }279void set_layout_helper(int lh) { _layout_helper = lh; }280281// Note: for instances layout_helper() may include padding.282// Use InstanceKlass::contains_field_offset to classify field offsets.283284// sub/superklass links285Klass* subklass(bool log = false) const;286Klass* next_sibling(bool log = false) const;287288InstanceKlass* superklass() const;289void append_to_sibling_list(); // add newly created receiver to superklass' subklass list290291void set_next_link(Klass* k) { _next_link = k; }292Klass* next_link() const { return _next_link; } // The next klass defined by the class loader.293Klass** next_link_addr() { return &_next_link; }294295// class loader data296ClassLoaderData* class_loader_data() const { return _class_loader_data; }297void set_class_loader_data(ClassLoaderData* loader_data) { _class_loader_data = loader_data; }298299int shared_classpath_index() const {300return _shared_class_path_index;301};302303void set_shared_classpath_index(int index) {304_shared_class_path_index = index;305};306307bool has_archived_mirror_index() const {308CDS_JAVA_HEAP_ONLY(return _archived_mirror_index >= 0;)309NOT_CDS_JAVA_HEAP(return false);310}311312void clear_archived_mirror_index() NOT_CDS_JAVA_HEAP_RETURN;313314void set_lambda_proxy_is_available() {315CDS_ONLY(_shared_class_flags |= _archived_lambda_proxy_is_available;)316}317void clear_lambda_proxy_is_available() {318CDS_ONLY(_shared_class_flags &= ~_archived_lambda_proxy_is_available;)319}320bool lambda_proxy_is_available() const {321CDS_ONLY(return (_shared_class_flags & _archived_lambda_proxy_is_available) != 0;)322NOT_CDS(return false;)323}324325void set_has_value_based_class_annotation() {326CDS_ONLY(_shared_class_flags |= _has_value_based_class_annotation;)327}328void clear_has_value_based_class_annotation() {329CDS_ONLY(_shared_class_flags &= ~_has_value_based_class_annotation;)330}331bool has_value_based_class_annotation() const {332CDS_ONLY(return (_shared_class_flags & _has_value_based_class_annotation) != 0;)333NOT_CDS(return false;)334}335336void set_is_shared_old_klass() {337CDS_ONLY(_shared_class_flags |= _is_shared_old_klass;)338}339bool is_shared_old_klass() const {340CDS_ONLY(return (_shared_class_flags & _is_shared_old_klass) != 0;)341NOT_CDS(return false;)342}343344345// Obtain the module or package for this class346virtual ModuleEntry* module() const = 0;347virtual PackageEntry* package() const = 0;348349protected: // internal accessors350void set_subklass(Klass* s);351void set_next_sibling(Klass* s);352353public:354355// Compiler support356static ByteSize super_offset() { return in_ByteSize(offset_of(Klass, _super)); }357static ByteSize super_check_offset_offset() { return in_ByteSize(offset_of(Klass, _super_check_offset)); }358static ByteSize primary_supers_offset() { return in_ByteSize(offset_of(Klass, _primary_supers)); }359static ByteSize secondary_super_cache_offset() { return in_ByteSize(offset_of(Klass, _secondary_super_cache)); }360static ByteSize secondary_supers_offset() { return in_ByteSize(offset_of(Klass, _secondary_supers)); }361static ByteSize java_mirror_offset() { return in_ByteSize(offset_of(Klass, _java_mirror)); }362static ByteSize class_loader_data_offset() { return in_ByteSize(offset_of(Klass, _class_loader_data)); }363static ByteSize modifier_flags_offset() { return in_ByteSize(offset_of(Klass, _modifier_flags)); }364static ByteSize layout_helper_offset() { return in_ByteSize(offset_of(Klass, _layout_helper)); }365static ByteSize access_flags_offset() { return in_ByteSize(offset_of(Klass, _access_flags)); }366367// Unpacking layout_helper:368static const int _lh_neutral_value = 0; // neutral non-array non-instance value369static const int _lh_instance_slow_path_bit = 0x01;370static const int _lh_log2_element_size_shift = BitsPerByte*0;371static const int _lh_log2_element_size_mask = BitsPerLong-1;372static const int _lh_element_type_shift = BitsPerByte*1;373static const int _lh_element_type_mask = right_n_bits(BitsPerByte); // shifted mask374static const int _lh_header_size_shift = BitsPerByte*2;375static const int _lh_header_size_mask = right_n_bits(BitsPerByte); // shifted mask376static const int _lh_array_tag_bits = 2;377static const int _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits;378static const int _lh_array_tag_obj_value = ~0x01; // 0x80000000 >> 30379380static const unsigned int _lh_array_tag_type_value = 0Xffffffff; // ~0x00, // 0xC0000000 >> 30381382static int layout_helper_size_in_bytes(jint lh) {383assert(lh > (jint)_lh_neutral_value, "must be instance");384return (int) lh & ~_lh_instance_slow_path_bit;385}386static bool layout_helper_needs_slow_path(jint lh) {387assert(lh > (jint)_lh_neutral_value, "must be instance");388return (lh & _lh_instance_slow_path_bit) != 0;389}390static bool layout_helper_is_instance(jint lh) {391return (jint)lh > (jint)_lh_neutral_value;392}393static bool layout_helper_is_array(jint lh) {394return (jint)lh < (jint)_lh_neutral_value;395}396static bool layout_helper_is_typeArray(jint lh) {397// _lh_array_tag_type_value == (lh >> _lh_array_tag_shift);398return (juint)lh >= (juint)(_lh_array_tag_type_value << _lh_array_tag_shift);399}400static bool layout_helper_is_objArray(jint lh) {401// _lh_array_tag_obj_value == (lh >> _lh_array_tag_shift);402return (jint)lh < (jint)(_lh_array_tag_type_value << _lh_array_tag_shift);403}404static int layout_helper_header_size(jint lh) {405assert(lh < (jint)_lh_neutral_value, "must be array");406int hsize = (lh >> _lh_header_size_shift) & _lh_header_size_mask;407assert(hsize > 0 && hsize < (int)sizeof(oopDesc)*3, "sanity");408return hsize;409}410static BasicType layout_helper_element_type(jint lh) {411assert(lh < (jint)_lh_neutral_value, "must be array");412int btvalue = (lh >> _lh_element_type_shift) & _lh_element_type_mask;413assert(btvalue >= T_BOOLEAN && btvalue <= T_OBJECT, "sanity");414return (BasicType) btvalue;415}416417// Want a pattern to quickly diff against layout header in register418// find something less clever!419static int layout_helper_boolean_diffbit() {420jint zlh = array_layout_helper(T_BOOLEAN);421jint blh = array_layout_helper(T_BYTE);422assert(zlh != blh, "array layout helpers must differ");423int diffbit = 1;424while ((diffbit & (zlh ^ blh)) == 0 && (diffbit & zlh) == 0) {425diffbit <<= 1;426assert(diffbit != 0, "make sure T_BOOLEAN has a different bit than T_BYTE");427}428return diffbit;429}430431static int layout_helper_log2_element_size(jint lh) {432assert(lh < (jint)_lh_neutral_value, "must be array");433int l2esz = (lh >> _lh_log2_element_size_shift) & _lh_log2_element_size_mask;434assert(l2esz <= LogBytesPerLong,435"sanity. l2esz: 0x%x for lh: 0x%x", (uint)l2esz, (uint)lh);436return l2esz;437}438static jint array_layout_helper(jint tag, int hsize, BasicType etype, int log2_esize) {439return (tag << _lh_array_tag_shift)440| (hsize << _lh_header_size_shift)441| ((int)etype << _lh_element_type_shift)442| (log2_esize << _lh_log2_element_size_shift);443}444static jint instance_layout_helper(jint size, bool slow_path_flag) {445return (size << LogBytesPerWord)446| (slow_path_flag ? _lh_instance_slow_path_bit : 0);447}448static int layout_helper_to_size_helper(jint lh) {449assert(lh > (jint)_lh_neutral_value, "must be instance");450// Note that the following expression discards _lh_instance_slow_path_bit.451return lh >> LogBytesPerWord;452}453// Out-of-line version computes everything based on the etype:454static jint array_layout_helper(BasicType etype);455456// What is the maximum number of primary superclasses any klass can have?457static juint primary_super_limit() { return _primary_super_limit; }458459// vtables460klassVtable vtable() const;461int vtable_length() const { return _vtable_len; }462463// subclass check464bool is_subclass_of(const Klass* k) const;465// subtype check: true if is_subclass_of, or if k is interface and receiver implements it466bool is_subtype_of(Klass* k) const {467juint off = k->super_check_offset();468Klass* sup = *(Klass**)( (address)this + off );469const juint secondary_offset = in_bytes(secondary_super_cache_offset());470if (sup == k) {471return true;472} else if (off != secondary_offset) {473return false;474} else {475return search_secondary_supers(k);476}477}478479bool search_secondary_supers(Klass* k) const;480481// Find LCA in class hierarchy482Klass *LCA( Klass *k );483484// Check whether reflection/jni/jvm code is allowed to instantiate this class;485// if not, throw either an Error or an Exception.486virtual void check_valid_for_instantiation(bool throwError, TRAPS);487488// array copying489virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS);490491// tells if the class should be initialized492virtual bool should_be_initialized() const { return false; }493// initializes the klass494virtual void initialize(TRAPS);495virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const;496virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature,497OverpassLookupMode overpass_mode,498PrivateLookupMode = PrivateLookupMode::find) const;499public:500Method* lookup_method(const Symbol* name, const Symbol* signature) const {501return uncached_lookup_method(name, signature, OverpassLookupMode::find);502}503504// array class with specific rank505virtual Klass* array_klass(int rank, TRAPS) = 0;506507// array class with this klass as element type508virtual Klass* array_klass(TRAPS) = 0;509510// These will return NULL instead of allocating on the heap:511virtual Klass* array_klass_or_null(int rank) = 0;512virtual Klass* array_klass_or_null() = 0;513514virtual oop protection_domain() const = 0;515516oop class_loader() const;517518inline oop klass_holder() const;519520protected:521522// Error handling when length > max_length or length < 0523static void check_array_allocation_length(int length, int max_length, TRAPS);524525void set_vtable_length(int len) { _vtable_len= len; }526527vtableEntry* start_of_vtable() const;528void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);529public:530Method* method_at_vtable(int index);531532static ByteSize vtable_start_offset();533static ByteSize vtable_length_offset() {534return byte_offset_of(Klass, _vtable_len);535}536537// CDS support - remove and restore oops from metadata. Oops are not shared.538virtual void remove_unshareable_info();539virtual void remove_java_mirror();540541bool is_unshareable_info_restored() const {542assert(is_shared(), "use this for shared classes only");543if (has_archived_mirror_index()) {544// _java_mirror is not a valid OopHandle but rather an encoded reference in the shared heap545return false;546} else if (_java_mirror.ptr_raw() == NULL) {547return false;548} else {549return true;550}551}552553public:554// ALL FUNCTIONS BELOW THIS POINT ARE DISPATCHED FROM AN OOP555// These functions describe behavior for the oop not the KLASS.556557// actual oop size of obj in memory558virtual int oop_size(oop obj) const = 0;559560// Size of klass in word size.561virtual int size() const = 0;562563// Returns the Java name for a class (Resource allocated)564// For arrays, this returns the name of the element with a leading '['.565// For classes, this returns the name with the package separators566// turned into '.'s.567const char* external_name() const;568// Returns the name for a class (Resource allocated) as the class569// would appear in a signature.570// For arrays, this returns the name of the element with a leading '['.571// For classes, this returns the name with a leading 'L' and a trailing ';'572// and the package separators as '/'.573virtual const char* signature_name() const;574575const char* joint_in_module_of_loader(const Klass* class2, bool include_parent_loader = false) const;576const char* class_in_module_of_loader(bool use_are = false, bool include_parent_loader = false) const;577578// Returns "interface", "abstract class" or "class".579const char* external_kind() const;580581// type testing operations582#ifdef ASSERT583protected:584virtual bool is_instance_klass_slow() const { return false; }585virtual bool is_array_klass_slow() const { return false; }586virtual bool is_objArray_klass_slow() const { return false; }587virtual bool is_typeArray_klass_slow() const { return false; }588#endif // ASSERT589public:590591// Fast non-virtual versions592#ifndef ASSERT593#define assert_same_query(xval, xcheck) xval594#else595private:596static bool assert_same_query(bool xval, bool xslow) {597assert(xval == xslow, "slow and fast queries agree");598return xval;599}600public:601#endif602inline bool is_instance_klass() const { return assert_same_query(603layout_helper_is_instance(layout_helper()),604is_instance_klass_slow()); }605inline bool is_array_klass() const { return assert_same_query(606layout_helper_is_array(layout_helper()),607is_array_klass_slow()); }608inline bool is_objArray_klass() const { return assert_same_query(609layout_helper_is_objArray(layout_helper()),610is_objArray_klass_slow()); }611inline bool is_typeArray_klass() const { return assert_same_query(612layout_helper_is_typeArray(layout_helper()),613is_typeArray_klass_slow()); }614#undef assert_same_query615616// Access flags617AccessFlags access_flags() const { return _access_flags; }618void set_access_flags(AccessFlags flags) { _access_flags = flags; }619620bool is_public() const { return _access_flags.is_public(); }621bool is_final() const { return _access_flags.is_final(); }622bool is_interface() const { return _access_flags.is_interface(); }623bool is_abstract() const { return _access_flags.is_abstract(); }624bool is_super() const { return _access_flags.is_super(); }625bool is_synthetic() const { return _access_flags.is_synthetic(); }626void set_is_synthetic() { _access_flags.set_is_synthetic(); }627bool has_finalizer() const { return _access_flags.has_finalizer(); }628bool has_final_method() const { return _access_flags.has_final_method(); }629void set_has_finalizer() { _access_flags.set_has_finalizer(); }630void set_has_final_method() { _access_flags.set_has_final_method(); }631bool has_vanilla_constructor() const { return _access_flags.has_vanilla_constructor(); }632void set_has_vanilla_constructor() { _access_flags.set_has_vanilla_constructor(); }633bool has_miranda_methods () const { return access_flags().has_miranda_methods(); }634void set_has_miranda_methods() { _access_flags.set_has_miranda_methods(); }635bool is_shared() const { return access_flags().is_shared_class(); } // shadows MetaspaceObj::is_shared)()636void set_is_shared() { _access_flags.set_is_shared_class(); }637bool is_hidden() const { return access_flags().is_hidden_class(); }638void set_is_hidden() { _access_flags.set_is_hidden_class(); }639bool is_value_based() { return _access_flags.is_value_based_class(); }640void set_is_value_based() { _access_flags.set_is_value_based_class(); }641642inline bool is_non_strong_hidden() const;643644bool is_cloneable() const;645void set_is_cloneable();646647// Biased locking support648// Note: the prototype header is always set up to be at least the649// prototype markWord. If biased locking is enabled it may further be650// biasable and have an epoch.651markWord prototype_header() const { return _prototype_header; }652653// NOTE: once instances of this klass are floating around in the654// system, this header must only be updated at a safepoint.655// NOTE 2: currently we only ever set the prototype header to the656// biasable prototype for instanceKlasses. There is no technical657// reason why it could not be done for arrayKlasses aside from658// wanting to reduce the initial scope of this optimization. There659// are potential problems in setting the bias pattern for660// JVM-internal oops.661inline void set_prototype_header(markWord header);662static ByteSize prototype_header_offset() { return in_ByteSize(offset_of(Klass, _prototype_header)); }663664int biased_lock_revocation_count() const { return (int) _biased_lock_revocation_count; }665// Atomically increments biased_lock_revocation_count and returns updated value666int atomic_incr_biased_lock_revocation_count();667void set_biased_lock_revocation_count(int val) { _biased_lock_revocation_count = (jint) val; }668jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }669void set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }670671JFR_ONLY(DEFINE_TRACE_ID_METHODS;)672673virtual void metaspace_pointers_do(MetaspaceClosure* iter);674virtual MetaspaceObj::Type type() const { return ClassType; }675676inline bool is_loader_alive() const;677678void clean_subklass();679680static void clean_weak_klass_links(bool unloading_occurred, bool clean_alive_klasses = true);681static void clean_subklass_tree() {682clean_weak_klass_links(/*unloading_occurred*/ true , /* clean_alive_klasses */ false);683}684685virtual void array_klasses_do(void f(Klass* k)) {}686687// Return self, except for abstract classes with exactly 1688// implementor. Then return the 1 concrete implementation.689Klass *up_cast_abstract();690691// klass name692Symbol* name() const { return _name; }693void set_name(Symbol* n);694695virtual void release_C_heap_structures();696697public:698virtual jint compute_modifier_flags() const = 0;699700// JVMTI support701virtual jint jvmti_class_status() const;702703// Printing704virtual void print_on(outputStream* st) const;705706virtual void oop_print_value_on(oop obj, outputStream* st);707virtual void oop_print_on (oop obj, outputStream* st);708709virtual const char* internal_name() const = 0;710711// Verification712virtual void verify_on(outputStream* st);713void verify() { verify_on(tty); }714715#ifndef PRODUCT716bool verify_vtable_index(int index);717#endif718719virtual void oop_verify_on(oop obj, outputStream* st);720721// for error reporting722static bool is_valid(Klass* k);723};724725#endif // SHARE_OOPS_KLASS_HPP726727728