< prev index next >

src/hotspot/share/oops/klass.hpp

Print this page

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


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

348     CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)
349     NOT_CDS(return false;)
350   }
351 
352   void set_has_archived_enum_objs() {
353     CDS_ONLY(_shared_class_flags |= _has_archived_enum_objs;)
354   }
355   bool has_archived_enum_objs() const {
356     CDS_ONLY(return (_shared_class_flags & _has_archived_enum_objs) != 0;)
357     NOT_CDS(return false;)
358   }
359 
360   void set_is_generated_shared_class() {
361     CDS_ONLY(_shared_class_flags |= _is_generated_shared_class;)
362   }
363   bool is_generated_shared_class() const {
364     CDS_ONLY(return (_shared_class_flags & _is_generated_shared_class) != 0;)
365     NOT_CDS(return false;)
366   }
367 








368   bool is_shared() const                { // shadows MetaspaceObj::is_shared)()
369     CDS_ONLY(return (_shared_class_flags & _is_shared_class) != 0;)
370     NOT_CDS(return false;)
371   }
372 
373   void set_is_shared() {
374     CDS_ONLY(_shared_class_flags |= _is_shared_class;)
375   }
376 
377   // Obtain the module or package for this class
378   virtual ModuleEntry* module() const = 0;
379   virtual PackageEntry* package() const = 0;
380 
381  protected:                                // internal accessors
382   void     set_subklass(Klass* s);
383   void     set_next_sibling(Klass* s);
384 
385  public:
386 
387   // Compiler support

533                                          OverpassLookupMode overpass_mode,
534                                          PrivateLookupMode = PrivateLookupMode::find) const;
535  public:
536   Method* lookup_method(const Symbol* name, const Symbol* signature) const {
537     return uncached_lookup_method(name, signature, OverpassLookupMode::find);
538   }
539 
540   // array class with specific rank
541   virtual ArrayKlass* array_klass(int rank, TRAPS) = 0;
542 
543   // array class with this klass as element type
544   virtual ArrayKlass* array_klass(TRAPS) = 0;
545 
546   // These will return null instead of allocating on the heap:
547   virtual ArrayKlass* array_klass_or_null(int rank) = 0;
548   virtual ArrayKlass* array_klass_or_null() = 0;
549 
550   virtual oop protection_domain() const = 0;
551 
552   oop class_loader() const;

553 
554   inline oop klass_holder() const;
555 
556  protected:
557 
558   // Error handling when length > max_length or length < 0
559   static void check_array_allocation_length(int length, int max_length, TRAPS);
560 
561   void set_vtable_length(int len) { _vtable_len= len; }
562 
563   vtableEntry* start_of_vtable() const;
564 #if INCLUDE_CDS
565   void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
566 #endif
567  public:
568   Method* method_at_vtable(int index);
569 
570   static ByteSize vtable_start_offset();
571   static ByteSize vtable_length_offset() {
572     return byte_offset_of(Klass, _vtable_len);

168   JFR_ONLY(DEFINE_TRACE_ID_FIELD;)
169 
170 private:
171   // This is an index into FileMapHeader::_shared_path_table[], to
172   // associate this class with the JAR file where it's loaded from during
173   // dump time. If a class is not loaded from the shared archive, this field is
174   // -1.
175   s2 _shared_class_path_index;
176 
177 #if INCLUDE_CDS
178   // Various attributes for shared classes. Should be zero for a non-shared class.
179   u2     _shared_class_flags;
180   enum CDSSharedClassFlags {
181     _is_shared_class                       = 1 << 0,  // shadows MetaspaceObj::is_shared
182     _archived_lambda_proxy_is_available    = 1 << 1,
183     _has_value_based_class_annotation      = 1 << 2,
184     _verified_at_dump_time                 = 1 << 3,
185     _has_archived_enum_objs                = 1 << 4,
186     // This class was not loaded from a classfile in the module image
187     // or classpath.
188     _is_generated_shared_class             = 1 << 5,
189     // The archived mirror is already initialized. No need to call <clinit>
190     _has_preinitialized_mirror             = 1 << 6,
191   };
192 #endif
193 
194   CDS_JAVA_HEAP_ONLY(int _archived_mirror_index;)
195 
196 protected:
197 
198   Klass(KlassKind kind);
199   Klass();
200 
201   void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
202 
203  public:
204   int kind() { return _kind; }
205 
206   enum class DefaultsLookupMode { find, skip };
207   enum class OverpassLookupMode { find, skip };
208   enum class StaticLookupMode   { find, skip };
209   enum class PrivateLookupMode  { find, skip };
210 

350     CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)
351     NOT_CDS(return false;)
352   }
353 
354   void set_has_archived_enum_objs() {
355     CDS_ONLY(_shared_class_flags |= _has_archived_enum_objs;)
356   }
357   bool has_archived_enum_objs() const {
358     CDS_ONLY(return (_shared_class_flags & _has_archived_enum_objs) != 0;)
359     NOT_CDS(return false;)
360   }
361 
362   void set_is_generated_shared_class() {
363     CDS_ONLY(_shared_class_flags |= _is_generated_shared_class;)
364   }
365   bool is_generated_shared_class() const {
366     CDS_ONLY(return (_shared_class_flags & _is_generated_shared_class) != 0;)
367     NOT_CDS(return false;)
368   }
369 
370   void set_has_preinitialized_mirror() {
371     CDS_ONLY(_shared_class_flags |= _has_preinitialized_mirror;)
372   }
373   bool has_preinitialized_mirror() const {
374     CDS_ONLY(return (_shared_class_flags & _has_preinitialized_mirror) != 0;)
375     NOT_CDS(return false;)
376   }
377 
378   bool is_shared() const                { // shadows MetaspaceObj::is_shared)()
379     CDS_ONLY(return (_shared_class_flags & _is_shared_class) != 0;)
380     NOT_CDS(return false;)
381   }
382 
383   void set_is_shared() {
384     CDS_ONLY(_shared_class_flags |= _is_shared_class;)
385   }
386 
387   // Obtain the module or package for this class
388   virtual ModuleEntry* module() const = 0;
389   virtual PackageEntry* package() const = 0;
390 
391  protected:                                // internal accessors
392   void     set_subklass(Klass* s);
393   void     set_next_sibling(Klass* s);
394 
395  public:
396 
397   // Compiler support

543                                          OverpassLookupMode overpass_mode,
544                                          PrivateLookupMode = PrivateLookupMode::find) const;
545  public:
546   Method* lookup_method(const Symbol* name, const Symbol* signature) const {
547     return uncached_lookup_method(name, signature, OverpassLookupMode::find);
548   }
549 
550   // array class with specific rank
551   virtual ArrayKlass* array_klass(int rank, TRAPS) = 0;
552 
553   // array class with this klass as element type
554   virtual ArrayKlass* array_klass(TRAPS) = 0;
555 
556   // These will return null instead of allocating on the heap:
557   virtual ArrayKlass* array_klass_or_null(int rank) = 0;
558   virtual ArrayKlass* array_klass_or_null() = 0;
559 
560   virtual oop protection_domain() const = 0;
561 
562   oop class_loader() const;
563   Symbol* class_loader_name_and_id() const;
564 
565   inline oop klass_holder() const;
566 
567  protected:
568 
569   // Error handling when length > max_length or length < 0
570   static void check_array_allocation_length(int length, int max_length, TRAPS);
571 
572   void set_vtable_length(int len) { _vtable_len= len; }
573 
574   vtableEntry* start_of_vtable() const;
575 #if INCLUDE_CDS
576   void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);
577 #endif
578  public:
579   Method* method_at_vtable(int index);
580 
581   static ByteSize vtable_start_offset();
582   static ByteSize vtable_length_offset() {
583     return byte_offset_of(Klass, _vtable_len);
< prev index next >