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