< prev index next >

src/hotspot/share/oops/klass.hpp

Print this page

174   JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
175 
176 private:
177   // This is an index into FileMapHeader::_shared_path_table[], to
178   // associate this class with the JAR file where it's loaded from during
179   // dump time. If a class is not loaded from the shared archive, this field is
180   // -1.
181   s2 _shared_class_path_index;
182 
183 #if INCLUDE_CDS
184   // Various attributes for shared classes. Should be zero for a non-shared class.
185   u2     _shared_class_flags;
186   enum CDSSharedClassFlags {
187     _is_shared_class                       = 1 << 0,  // shadows MetaspaceObj::is_shared
188     _archived_lambda_proxy_is_available    = 1 << 1,
189     _has_value_based_class_annotation      = 1 << 2,
190     _verified_at_dump_time                 = 1 << 3,
191     _has_archived_enum_objs                = 1 << 4,
192     // This class was not loaded from a classfile in the module image
193     // or classpath.
194     _is_generated_shared_class             = 1 << 5


195   };
196 #endif
197 
198   CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;)
199 
200 protected:
201 
202   Klass(KlassKind kind);
203   Klass();
204 
205   void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
206 
207  public:
208   int kind() { return _kind; }
209 
210   enum class DefaultsLookupMode { find, skip };
211   enum class OverpassLookupMode { find, skip };
212   enum class StaticLookupMode   { find, skip };
213   enum class PrivateLookupMode  { find, skip };
214 

357     CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)
358     NOT_CDS(return false;)
359   }
360 
361   void set_has_archived_enum_objs() {
362     CDS_ONLY(_shared_class_flags |= _has_archived_enum_objs;)
363   }
364   bool has_archived_enum_objs() const {
365     CDS_ONLY(return (_shared_class_flags & _has_archived_enum_objs) != 0;)
366     NOT_CDS(return false;)
367   }
368 
369   void set_is_generated_shared_class() {
370     CDS_ONLY(_shared_class_flags |= _is_generated_shared_class;)
371   }
372   bool is_generated_shared_class() const {
373     CDS_ONLY(return (_shared_class_flags & _is_generated_shared_class) != 0;)
374     NOT_CDS(return false;)
375   }
376 








377   bool is_shared() const                { // shadows MetaspaceObj::is_shared)()
378     CDS_ONLY(return (_shared_class_flags & _is_shared_class) != 0;)
379     NOT_CDS(return false;)
380   }
381 
382   void set_is_shared() {
383     CDS_ONLY(_shared_class_flags |= _is_shared_class;)
384   }
385 
386   // Obtain the module or package for this class
387   virtual ModuleEntry* module() const = 0;
388   virtual PackageEntry* package() const = 0;
389 
390  protected:                                // internal accessors
391   void     set_subklass(Klass* s);
392   void     set_next_sibling(Klass* s);
393 
394  private:
395   static void  hash_insert(Klass* klass, GrowableArray<Klass*>* secondaries, uintx& bitmap);
396   static uintx hash_secondary_supers(Array<Klass*>* secondaries, bool rewrite);

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);

174   JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
175 
176 private:
177   // This is an index into FileMapHeader::_shared_path_table[], to
178   // associate this class with the JAR file where it's loaded from during
179   // dump time. If a class is not loaded from the shared archive, this field is
180   // -1.
181   s2 _shared_class_path_index;
182 
183 #if INCLUDE_CDS
184   // Various attributes for shared classes. Should be zero for a non-shared class.
185   u2     _shared_class_flags;
186   enum CDSSharedClassFlags {
187     _is_shared_class                       = 1 << 0,  // shadows MetaspaceObj::is_shared
188     _archived_lambda_proxy_is_available    = 1 << 1,
189     _has_value_based_class_annotation      = 1 << 2,
190     _verified_at_dump_time                 = 1 << 3,
191     _has_archived_enum_objs                = 1 << 4,
192     // This class was not loaded from a classfile in the module image
193     // or classpath.
194     _is_generated_shared_class             = 1 << 5,
195     // The archived mirror is already initialized. No need to call <clinit>
196     _has_preinitialized_mirror             = 1 << 6,
197   };
198 #endif
199 
200   CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;)
201 
202 protected:
203 
204   Klass(KlassKind kind);
205   Klass();
206 
207   void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
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   void set_has_preinitialized_mirror() {
380     CDS_ONLY(_shared_class_flags |= _has_preinitialized_mirror;)
381   }
382   bool has_preinitialized_mirror() const {
383     CDS_ONLY(return (_shared_class_flags & _has_preinitialized_mirror) != 0;)
384     NOT_CDS(return false;)
385   }
386 
387   bool is_shared() const                { // shadows MetaspaceObj::is_shared)()
388     CDS_ONLY(return (_shared_class_flags & _is_shared_class) != 0;)
389     NOT_CDS(return false;)
390   }
391 
392   void set_is_shared() {
393     CDS_ONLY(_shared_class_flags |= _is_shared_class;)
394   }
395 
396   // Obtain the module or package for this class
397   virtual ModuleEntry* module() const = 0;
398   virtual PackageEntry* package() const = 0;
399 
400  protected:                                // internal accessors
401   void     set_subklass(Klass* s);
402   void     set_next_sibling(Klass* s);
403 
404  private:
405   static void  hash_insert(Klass* klass, GrowableArray<Klass*>* secondaries, uintx& bitmap);
406   static uintx hash_secondary_supers(Array<Klass*>* secondaries, bool rewrite);

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);
< prev index next >