179 _has_raw_archived_mirror = 1, 180 _archived_lambda_proxy_is_available = 2 181 }; 182 #endif 183 184 // The _archived_mirror is set at CDS dump time pointing to the cached mirror 185 // in the open archive heap region when archiving java object is supported. 186 CDS_JAVA_HEAP_ONLY(narrowOop _archived_mirror;) 187 188 protected: 189 190 // Constructor 191 Klass(KlassID id); 192 Klass() : _id(KlassID(-1)) { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); } 193 194 void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw(); 195 196 public: 197 int id() { return _id; } 198 199 enum DefaultsLookupMode { find_defaults, skip_defaults }; 200 enum OverpassLookupMode { find_overpass, skip_overpass }; 201 enum StaticLookupMode { find_static, skip_static }; 202 enum PrivateLookupMode { find_private, skip_private }; 203 204 virtual bool is_klass() const { return true; } 205 206 // super() cannot be InstanceKlass* -- Java arrays are covariant, and _super is used 207 // to implement that. NB: the _super of "[Ljava/lang/Integer;" is "[Ljava/lang/Number;" 208 // If this is not what your code expects, you're probably looking for Klass::java_super(). 209 Klass* super() const { return _super; } 210 void set_super(Klass* k) { _super = k; } 211 212 // initializes _super link, _primary_supers & _secondary_supers arrays 213 void initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS); 214 215 // klass-specific helper for initializing _secondary_supers 216 virtual GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots, 217 Array<InstanceKlass*>* transitive_interfaces); 218 219 // java_super is the Java-level super type as specified by Class.getSuperClass. 220 virtual InstanceKlass* java_super() const { return NULL; } 221 222 juint super_check_offset() const { return _super_check_offset; } 465 466 bool search_secondary_supers(Klass* k) const; 467 468 // Find LCA in class hierarchy 469 Klass *LCA( Klass *k ); 470 471 // Check whether reflection/jni/jvm code is allowed to instantiate this class; 472 // if not, throw either an Error or an Exception. 473 virtual void check_valid_for_instantiation(bool throwError, TRAPS); 474 475 // array copying 476 virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 477 478 // tells if the class should be initialized 479 virtual bool should_be_initialized() const { return false; } 480 // initializes the klass 481 virtual void initialize(TRAPS); 482 virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const; 483 virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature, 484 OverpassLookupMode overpass_mode, 485 PrivateLookupMode = find_private) const; 486 public: 487 Method* lookup_method(const Symbol* name, const Symbol* signature) const { 488 return uncached_lookup_method(name, signature, find_overpass); 489 } 490 491 // array class with specific rank 492 Klass* array_klass(int rank, TRAPS) { return array_klass_impl(false, rank, THREAD); } 493 494 // array class with this klass as element type 495 Klass* array_klass(TRAPS) { return array_klass_impl(false, THREAD); } 496 497 // These will return NULL instead of allocating on the heap: 498 // NB: these can block for a mutex, like other functions with TRAPS arg. 499 Klass* array_klass_or_null(int rank); 500 Klass* array_klass_or_null(); 501 502 virtual oop protection_domain() const = 0; 503 504 oop class_loader() const; 505 506 // This loads the klass's holder as a phantom. This is useful when a weak Klass 507 // pointer has been "peeked" and then must be kept alive before it may 508 // be used safely. All uses of klass_holder need to apply the appropriate barriers, | 179 _has_raw_archived_mirror = 1, 180 _archived_lambda_proxy_is_available = 2 181 }; 182 #endif 183 184 // The _archived_mirror is set at CDS dump time pointing to the cached mirror 185 // in the open archive heap region when archiving java object is supported. 186 CDS_JAVA_HEAP_ONLY(narrowOop _archived_mirror;) 187 188 protected: 189 190 // Constructor 191 Klass(KlassID id); 192 Klass() : _id(KlassID(-1)) { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); } 193 194 void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw(); 195 196 public: 197 int id() { return _id; } 198 199 enum class DefaultsLookupMode { find_defaults, skip_defaults }; 200 enum class OverpassLookupMode { find_overpass, skip_overpass }; 201 enum class StaticLookupMode { find_static, skip_static }; 202 enum class PrivateLookupMode { find_private, skip_private }; 203 204 virtual bool is_klass() const { return true; } 205 206 // super() cannot be InstanceKlass* -- Java arrays are covariant, and _super is used 207 // to implement that. NB: the _super of "[Ljava/lang/Integer;" is "[Ljava/lang/Number;" 208 // If this is not what your code expects, you're probably looking for Klass::java_super(). 209 Klass* super() const { return _super; } 210 void set_super(Klass* k) { _super = k; } 211 212 // initializes _super link, _primary_supers & _secondary_supers arrays 213 void initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS); 214 215 // klass-specific helper for initializing _secondary_supers 216 virtual GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots, 217 Array<InstanceKlass*>* transitive_interfaces); 218 219 // java_super is the Java-level super type as specified by Class.getSuperClass. 220 virtual InstanceKlass* java_super() const { return NULL; } 221 222 juint super_check_offset() const { return _super_check_offset; } 465 466 bool search_secondary_supers(Klass* k) const; 467 468 // Find LCA in class hierarchy 469 Klass *LCA( Klass *k ); 470 471 // Check whether reflection/jni/jvm code is allowed to instantiate this class; 472 // if not, throw either an Error or an Exception. 473 virtual void check_valid_for_instantiation(bool throwError, TRAPS); 474 475 // array copying 476 virtual void copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS); 477 478 // tells if the class should be initialized 479 virtual bool should_be_initialized() const { return false; } 480 // initializes the klass 481 virtual void initialize(TRAPS); 482 virtual Klass* find_field(Symbol* name, Symbol* signature, fieldDescriptor* fd) const; 483 virtual Method* uncached_lookup_method(const Symbol* name, const Symbol* signature, 484 OverpassLookupMode overpass_mode, 485 PrivateLookupMode = PrivateLookupMode::find_private) const; 486 public: 487 Method* lookup_method(const Symbol* name, const Symbol* signature) const { 488 return uncached_lookup_method(name, signature, OverpassLookupMode::find_overpass); 489 } 490 491 // array class with specific rank 492 Klass* array_klass(int rank, TRAPS) { return array_klass_impl(false, rank, THREAD); } 493 494 // array class with this klass as element type 495 Klass* array_klass(TRAPS) { return array_klass_impl(false, THREAD); } 496 497 // These will return NULL instead of allocating on the heap: 498 // NB: these can block for a mutex, like other functions with TRAPS arg. 499 Klass* array_klass_or_null(int rank); 500 Klass* array_klass_or_null(); 501 502 virtual oop protection_domain() const = 0; 503 504 oop class_loader() const; 505 506 // This loads the klass's holder as a phantom. This is useful when a weak Klass 507 // pointer has been "peeked" and then must be kept alive before it may 508 // be used safely. All uses of klass_holder need to apply the appropriate barriers, |