176 uint8_t _hash_slot;
177
178 private:
179 // This is an index into FileMapHeader::_shared_path_table[], to
180 // associate this class with the JAR file where it's loaded from during
181 // dump time. If a class is not loaded from the shared archive, this field is
182 // -1.
183 s2 _shared_class_path_index;
184
185 #if INCLUDE_CDS
186 // Various attributes for shared classes. Should be zero for a non-shared class.
187 u2 _shared_class_flags;
188 enum CDSSharedClassFlags {
189 _is_shared_class = 1 << 0, // shadows MetaspaceObj::is_shared
190 _archived_lambda_proxy_is_available = 1 << 1,
191 _has_value_based_class_annotation = 1 << 2,
192 _verified_at_dump_time = 1 << 3,
193 _has_archived_enum_objs = 1 << 4,
194 // This class was not loaded from a classfile in the module image
195 // or classpath.
196 _is_generated_shared_class = 1 << 5
197 };
198 #endif
199
200 KlassFlags _misc_flags;
201
202 CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;)
203
204 protected:
205
206 Klass(KlassKind kind);
207 Klass();
208
209 public:
210 int kind() { return _kind; }
211
212 enum class DefaultsLookupMode { find, skip };
213 enum class OverpassLookupMode { find, skip };
214 enum class StaticLookupMode { find, skip };
215 enum class PrivateLookupMode { find, skip };
216
359 CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)
360 NOT_CDS(return false;)
361 }
362
363 void set_has_archived_enum_objs() {
364 CDS_ONLY(_shared_class_flags |= _has_archived_enum_objs;)
365 }
366 bool has_archived_enum_objs() const {
367 CDS_ONLY(return (_shared_class_flags & _has_archived_enum_objs) != 0;)
368 NOT_CDS(return false;)
369 }
370
371 void set_is_generated_shared_class() {
372 CDS_ONLY(_shared_class_flags |= _is_generated_shared_class;)
373 }
374 bool is_generated_shared_class() const {
375 CDS_ONLY(return (_shared_class_flags & _is_generated_shared_class) != 0;)
376 NOT_CDS(return false;)
377 }
378
379 bool is_shared() const { // shadows MetaspaceObj::is_shared)()
380 CDS_ONLY(return (_shared_class_flags & _is_shared_class) != 0;)
381 NOT_CDS(return false;)
382 }
383
384 void set_is_shared() {
385 CDS_ONLY(_shared_class_flags |= _is_shared_class;)
386 }
387
388 // Obtain the module or package for this class
389 virtual ModuleEntry* module() const = 0;
390 virtual PackageEntry* package() const = 0;
391
392 protected: // internal accessors
393 void set_subklass(Klass* s);
394 void set_next_sibling(Klass* s);
395
396 private:
397 static uint8_t compute_hash_slot(Symbol* s);
398 static void hash_insert(Klass* klass, GrowableArray<Klass*>* secondaries, uintx& bitmap);
566 OverpassLookupMode overpass_mode,
567 PrivateLookupMode = PrivateLookupMode::find) const;
568 public:
569 Method* lookup_method(const Symbol* name, const Symbol* signature) const {
570 return uncached_lookup_method(name, signature, OverpassLookupMode::find);
571 }
572
573 // array class with specific rank
574 virtual ArrayKlass* array_klass(int rank, TRAPS) = 0;
575
576 // array class with this klass as element type
577 virtual ArrayKlass* array_klass(TRAPS) = 0;
578
579 // These will return null instead of allocating on the heap:
580 virtual ArrayKlass* array_klass_or_null(int rank) = 0;
581 virtual ArrayKlass* array_klass_or_null() = 0;
582
583 virtual oop protection_domain() const = 0;
584
585 oop class_loader() const;
586
587 inline oop klass_holder() const;
588
589 protected:
590
591 // Error handling when length > max_length or length < 0
592 static void check_array_allocation_length(int length, int max_length, TRAPS);
593
594 void set_vtable_length(int len) { _vtable_len= len; }
595
596 vtableEntry* start_of_vtable() const;
597 #if INCLUDE_CDS
598 void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
599 #endif
600 public:
601 Method* method_at_vtable(int index);
602
603 static ByteSize vtable_start_offset();
604 static ByteSize vtable_length_offset() {
605 return byte_offset_of(Klass, _vtable_len);
|
176 uint8_t _hash_slot;
177
178 private:
179 // This is an index into FileMapHeader::_shared_path_table[], to
180 // associate this class with the JAR file where it's loaded from during
181 // dump time. If a class is not loaded from the shared archive, this field is
182 // -1.
183 s2 _shared_class_path_index;
184
185 #if INCLUDE_CDS
186 // Various attributes for shared classes. Should be zero for a non-shared class.
187 u2 _shared_class_flags;
188 enum CDSSharedClassFlags {
189 _is_shared_class = 1 << 0, // shadows MetaspaceObj::is_shared
190 _archived_lambda_proxy_is_available = 1 << 1,
191 _has_value_based_class_annotation = 1 << 2,
192 _verified_at_dump_time = 1 << 3,
193 _has_archived_enum_objs = 1 << 4,
194 // This class was not loaded from a classfile in the module image
195 // or classpath.
196 _is_generated_shared_class = 1 << 5,
197 // The archived mirror is already initialized. No need to call <clinit>
198 _has_preinitialized_mirror = 1 << 6,
199 };
200 #endif
201
202 KlassFlags _misc_flags;
203
204 CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;)
205
206 protected:
207
208 Klass(KlassKind kind);
209 Klass();
210
211 public:
212 int kind() { return _kind; }
213
214 enum class DefaultsLookupMode { find, skip };
215 enum class OverpassLookupMode { find, skip };
216 enum class StaticLookupMode { find, skip };
217 enum class PrivateLookupMode { find, skip };
218
361 CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)
362 NOT_CDS(return false;)
363 }
364
365 void set_has_archived_enum_objs() {
366 CDS_ONLY(_shared_class_flags |= _has_archived_enum_objs;)
367 }
368 bool has_archived_enum_objs() const {
369 CDS_ONLY(return (_shared_class_flags & _has_archived_enum_objs) != 0;)
370 NOT_CDS(return false;)
371 }
372
373 void set_is_generated_shared_class() {
374 CDS_ONLY(_shared_class_flags |= _is_generated_shared_class;)
375 }
376 bool is_generated_shared_class() const {
377 CDS_ONLY(return (_shared_class_flags & _is_generated_shared_class) != 0;)
378 NOT_CDS(return false;)
379 }
380
381 void set_has_preinitialized_mirror() {
382 CDS_ONLY(_shared_class_flags |= _has_preinitialized_mirror;)
383 }
384 bool has_preinitialized_mirror() const {
385 CDS_ONLY(return (_shared_class_flags & _has_preinitialized_mirror) != 0;)
386 NOT_CDS(return false;)
387 }
388
389 bool is_shared() const { // shadows MetaspaceObj::is_shared)()
390 CDS_ONLY(return (_shared_class_flags & _is_shared_class) != 0;)
391 NOT_CDS(return false;)
392 }
393
394 void set_is_shared() {
395 CDS_ONLY(_shared_class_flags |= _is_shared_class;)
396 }
397
398 // Obtain the module or package for this class
399 virtual ModuleEntry* module() const = 0;
400 virtual PackageEntry* package() const = 0;
401
402 protected: // internal accessors
403 void set_subklass(Klass* s);
404 void set_next_sibling(Klass* s);
405
406 private:
407 static uint8_t compute_hash_slot(Symbol* s);
408 static void hash_insert(Klass* klass, GrowableArray<Klass*>* secondaries, uintx& bitmap);
576 OverpassLookupMode overpass_mode,
577 PrivateLookupMode = PrivateLookupMode::find) const;
578 public:
579 Method* lookup_method(const Symbol* name, const Symbol* signature) const {
580 return uncached_lookup_method(name, signature, OverpassLookupMode::find);
581 }
582
583 // array class with specific rank
584 virtual ArrayKlass* array_klass(int rank, TRAPS) = 0;
585
586 // array class with this klass as element type
587 virtual ArrayKlass* array_klass(TRAPS) = 0;
588
589 // These will return null instead of allocating on the heap:
590 virtual ArrayKlass* array_klass_or_null(int rank) = 0;
591 virtual ArrayKlass* array_klass_or_null() = 0;
592
593 virtual oop protection_domain() const = 0;
594
595 oop class_loader() const;
596 Symbol* class_loader_name_and_id() const;
597
598 inline oop klass_holder() const;
599
600 protected:
601
602 // Error handling when length > max_length or length < 0
603 static void check_array_allocation_length(int length, int max_length, TRAPS);
604
605 void set_vtable_length(int len) { _vtable_len= len; }
606
607 vtableEntry* start_of_vtable() const;
608 #if INCLUDE_CDS
609 void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
610 #endif
611 public:
612 Method* method_at_vtable(int index);
613
614 static ByteSize vtable_start_offset();
615 static ByteSize vtable_length_offset() {
616 return byte_offset_of(Klass, _vtable_len);
|