< prev index next >

src/hotspot/share/oops/instanceKlass.hpp

Print this page

 306   static bool is_finalization_enabled() { return _finalization_enabled; }
 307 
 308   // Sets finalization state
 309   static void set_finalization_enabled(bool val) { _finalization_enabled = val; }
 310 
 311   // The three BUILTIN class loader types
 312   bool is_shared_boot_class() const { return _misc_flags.is_shared_boot_class(); }
 313   bool is_shared_platform_class() const { return _misc_flags.is_shared_platform_class(); }
 314   bool is_shared_app_class() const {  return _misc_flags.is_shared_app_class(); }
 315   // The UNREGISTERED class loader type
 316   bool is_shared_unregistered_class() const { return _misc_flags.is_shared_unregistered_class(); }
 317 
 318   // Check if the class can be shared in CDS
 319   bool is_shareable() const;
 320 
 321   bool shared_loading_failed() const { return _misc_flags.shared_loading_failed(); }
 322 
 323   void set_shared_loading_failed() { _misc_flags.set_shared_loading_failed(true); }
 324 
 325 #if INCLUDE_CDS

 326   void set_shared_class_loader_type(s2 loader_type) { _misc_flags.set_shared_class_loader_type(loader_type); }
 327   void assign_class_loader_type() { _misc_flags.assign_class_loader_type(_class_loader_data); }
 328 #endif
 329 
 330   bool has_nonstatic_fields() const        { return _misc_flags.has_nonstatic_fields(); }
 331   void set_has_nonstatic_fields(bool b)    { _misc_flags.set_has_nonstatic_fields(b); }
 332 
 333   bool has_localvariable_table() const     { return _misc_flags.has_localvariable_table(); }
 334   void set_has_localvariable_table(bool b) { _misc_flags.set_has_localvariable_table(b); }
 335 
 336   // field sizes
 337   int nonstatic_field_size() const         { return _nonstatic_field_size; }
 338   void set_nonstatic_field_size(int size)  { _nonstatic_field_size = size; }
 339 
 340   int static_field_size() const            { return _static_field_size; }
 341   void set_static_field_size(int size)     { _static_field_size = size; }
 342 
 343   int static_oop_field_count() const       { return (int)_static_oop_field_count; }
 344   void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
 345 

 501                                        TRAPS);
 502 
 503   JavaThread* init_thread()  { return Atomic::load(&_init_thread); }
 504   const char* init_thread_name() {
 505     return init_thread()->name_raw();
 506   }
 507 
 508  public:
 509   // initialization state
 510   bool is_loaded() const                   { return init_state() >= loaded; }
 511   bool is_linked() const                   { return init_state() >= linked; }
 512   bool is_initialized() const              { return init_state() == fully_initialized; }
 513   bool is_not_initialized() const          { return init_state() <  being_initialized; }
 514   bool is_being_initialized() const        { return init_state() == being_initialized; }
 515   bool is_in_error_state() const           { return init_state() == initialization_error; }
 516   bool is_reentrant_initialization(Thread *thread)  { return thread == _init_thread; }
 517   ClassState  init_state() const           { return Atomic::load_acquire(&_init_state); }
 518   const char* init_state_name() const;
 519   bool is_rewritten() const                { return _misc_flags.rewritten(); }
 520 


 521   // is this a sealed class
 522   bool is_sealed() const;
 523 
 524   // defineClass specified verification
 525   bool should_verify_class() const         { return _misc_flags.should_verify_class(); }
 526   void set_should_verify_class(bool value) { _misc_flags.set_should_verify_class(value); }
 527 
 528   // marking
 529   bool is_marked_dependent() const         { return _misc_flags.is_marked_dependent(); }
 530   void set_is_marked_dependent(bool value) { _misc_flags.set_is_marked_dependent(value); }
 531 
 532   // initialization (virtuals from Klass)
 533   bool should_be_initialized() const;  // means that initialize should be called

 534   void initialize(TRAPS);
 535   void link_class(TRAPS);
 536   bool link_class_or_fail(TRAPS); // returns false on failure
 537   void rewrite_class(TRAPS);
 538   void link_methods(TRAPS);
 539   Method* class_initializer() const;
 540 
 541   // reference type
 542   ReferenceType reference_type() const     { return (ReferenceType)_reference_type; }
 543 
 544   // this class cp index
 545   u2 this_class_index() const             { return _this_class_index; }
 546   void set_this_class_index(u2 index)     { _this_class_index = index; }
 547 
 548   static ByteSize reference_type_offset() { return byte_offset_of(InstanceKlass, _reference_type); }
 549 
 550   // find local field, returns true if found
 551   bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 552   // find field in direct superinterfaces, returns the interface in which the field is defined
 553   Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;

 783   void update_methods_jmethod_cache();
 784 
 785   // annotations support
 786   Annotations* annotations() const          { return _annotations; }
 787   void set_annotations(Annotations* anno)   { _annotations = anno; }
 788 
 789   AnnotationArray* class_annotations() const {
 790     return (_annotations != nullptr) ? _annotations->class_annotations() : nullptr;
 791   }
 792   Array<AnnotationArray*>* fields_annotations() const {
 793     return (_annotations != nullptr) ? _annotations->fields_annotations() : nullptr;
 794   }
 795   AnnotationArray* class_type_annotations() const {
 796     return (_annotations != nullptr) ? _annotations->class_type_annotations() : nullptr;
 797   }
 798   Array<AnnotationArray*>* fields_type_annotations() const {
 799     return (_annotations != nullptr) ? _annotations->fields_type_annotations() : nullptr;
 800   }
 801   // allocation
 802   instanceOop allocate_instance(TRAPS);
 803   static instanceOop allocate_instance(oop cls, TRAPS);
 804 
 805   // additional member function to return a handle
 806   instanceHandle allocate_instance_handle(TRAPS);
 807 
 808   objArrayOop allocate_objArray(int n, int length, TRAPS);
 809   // Helper function
 810   static instanceOop register_finalizer(instanceOop i, TRAPS);
 811 
 812   // Check whether reflection/jni/jvm code is allowed to instantiate this class;
 813   // if not, throw either an Error or an Exception.
 814   virtual void check_valid_for_instantiation(bool throwError, TRAPS);
 815 
 816   // initialization
 817   void call_class_initializer(TRAPS);
 818   void set_initialization_state_and_notify(ClassState state, TRAPS);
 819 
 820   // OopMapCache support
 821   OopMapCache* oop_map_cache()               { return _oop_map_cache; }
 822   void set_oop_map_cache(OopMapCache *cache) { _oop_map_cache = cache; }
 823   void mask_for(const methodHandle& method, int bci, InterpreterOopMap* entry);

1063   // Must be one per class and it has to be a VM internal object so java code
1064   // cannot lock it (like the mirror).
1065   // It has to be an object not a Mutex because it's held through java calls.
1066   oop init_lock() const;
1067 
1068   // Returns the array class for the n'th dimension
1069   virtual ArrayKlass* array_klass(int n, TRAPS);
1070   virtual ArrayKlass* array_klass_or_null(int n);
1071 
1072   // Returns the array class with this class as element type
1073   virtual ArrayKlass* array_klass(TRAPS);
1074   virtual ArrayKlass* array_klass_or_null();
1075 
1076   static void clean_initialization_error_table();
1077 private:
1078   void fence_and_clear_init_lock();
1079 
1080   bool link_class_impl                           (TRAPS);
1081   bool verify_code                               (TRAPS);
1082   void initialize_impl                           (TRAPS);
1083   void initialize_super_interfaces               (TRAPS);
1084 
1085   void add_initialization_error(JavaThread* current, Handle exception);
1086   oop get_initialization_error(JavaThread* current);
1087 
1088   // find a local method (returns null if not found)
1089   Method* find_method_impl(const Symbol* name,
1090                            const Symbol* signature,
1091                            OverpassLookupMode overpass_mode,
1092                            StaticLookupMode static_mode,
1093                            PrivateLookupMode private_mode) const;
1094 
1095   static Method* find_method_impl(const Array<Method*>* methods,
1096                                   const Symbol* name,
1097                                   const Symbol* signature,
1098                                   OverpassLookupMode overpass_mode,
1099                                   StaticLookupMode static_mode,
1100                                   PrivateLookupMode private_mode);
1101 
1102 #if INCLUDE_JVMTI
1103   // RedefineClasses support
1104   void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }
1105   void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);
1106 #endif
1107   // log class name to classlist
1108   void log_to_classlist() const;
1109 public:
1110 
1111 #if INCLUDE_CDS
1112   // CDS support - remove and restore oops from metadata. Oops are not shared.
1113   virtual void remove_unshareable_info();
1114   void remove_unshareable_flags();
1115   virtual void remove_java_mirror();
1116   void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);
1117   void init_shared_package_entry();
1118   bool can_be_verified_at_dumptime() const;
1119   bool methods_contain_jsr_bytecode() const;
1120   void compute_has_loops_flag_for_methods();
1121 #endif
1122 







1123   jint compute_modifier_flags() const;
1124 
1125 public:
1126   // JVMTI support
1127   jint jvmti_class_status() const;
1128 
1129   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
1130 
1131  public:
1132   // Printing
1133   void print_on(outputStream* st) const;
1134   void print_value_on(outputStream* st) const;
1135 
1136   void oop_print_value_on(oop obj, outputStream* st);
1137 
1138   void oop_print_on      (oop obj, outputStream* st);
1139 
1140 #ifndef PRODUCT
1141   void print_dependent_nmethods(bool verbose = false);
1142   bool is_dependent_nmethod(nmethod* nm);

 306   static bool is_finalization_enabled() { return _finalization_enabled; }
 307 
 308   // Sets finalization state
 309   static void set_finalization_enabled(bool val) { _finalization_enabled = val; }
 310 
 311   // The three BUILTIN class loader types
 312   bool is_shared_boot_class() const { return _misc_flags.is_shared_boot_class(); }
 313   bool is_shared_platform_class() const { return _misc_flags.is_shared_platform_class(); }
 314   bool is_shared_app_class() const {  return _misc_flags.is_shared_app_class(); }
 315   // The UNREGISTERED class loader type
 316   bool is_shared_unregistered_class() const { return _misc_flags.is_shared_unregistered_class(); }
 317 
 318   // Check if the class can be shared in CDS
 319   bool is_shareable() const;
 320 
 321   bool shared_loading_failed() const { return _misc_flags.shared_loading_failed(); }
 322 
 323   void set_shared_loading_failed() { _misc_flags.set_shared_loading_failed(true); }
 324 
 325 #if INCLUDE_CDS
 326   int  shared_class_loader_type() const;
 327   void set_shared_class_loader_type(s2 loader_type) { _misc_flags.set_shared_class_loader_type(loader_type); }
 328   void assign_class_loader_type() { _misc_flags.assign_class_loader_type(_class_loader_data); }
 329 #endif
 330 
 331   bool has_nonstatic_fields() const        { return _misc_flags.has_nonstatic_fields(); }
 332   void set_has_nonstatic_fields(bool b)    { _misc_flags.set_has_nonstatic_fields(b); }
 333 
 334   bool has_localvariable_table() const     { return _misc_flags.has_localvariable_table(); }
 335   void set_has_localvariable_table(bool b) { _misc_flags.set_has_localvariable_table(b); }
 336 
 337   // field sizes
 338   int nonstatic_field_size() const         { return _nonstatic_field_size; }
 339   void set_nonstatic_field_size(int size)  { _nonstatic_field_size = size; }
 340 
 341   int static_field_size() const            { return _static_field_size; }
 342   void set_static_field_size(int size)     { _static_field_size = size; }
 343 
 344   int static_oop_field_count() const       { return (int)_static_oop_field_count; }
 345   void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
 346 

 502                                        TRAPS);
 503 
 504   JavaThread* init_thread()  { return Atomic::load(&_init_thread); }
 505   const char* init_thread_name() {
 506     return init_thread()->name_raw();
 507   }
 508 
 509  public:
 510   // initialization state
 511   bool is_loaded() const                   { return init_state() >= loaded; }
 512   bool is_linked() const                   { return init_state() >= linked; }
 513   bool is_initialized() const              { return init_state() == fully_initialized; }
 514   bool is_not_initialized() const          { return init_state() <  being_initialized; }
 515   bool is_being_initialized() const        { return init_state() == being_initialized; }
 516   bool is_in_error_state() const           { return init_state() == initialization_error; }
 517   bool is_reentrant_initialization(Thread *thread)  { return thread == _init_thread; }
 518   ClassState  init_state() const           { return Atomic::load_acquire(&_init_state); }
 519   const char* init_state_name() const;
 520   bool is_rewritten() const                { return _misc_flags.rewritten(); }
 521 
 522   static const char* state2name(ClassState state);
 523 
 524   // is this a sealed class
 525   bool is_sealed() const;
 526 
 527   // defineClass specified verification
 528   bool should_verify_class() const         { return _misc_flags.should_verify_class(); }
 529   void set_should_verify_class(bool value) { _misc_flags.set_should_verify_class(value); }
 530 
 531   // marking
 532   bool is_marked_dependent() const         { return _misc_flags.is_marked_dependent(); }
 533   void set_is_marked_dependent(bool value) { _misc_flags.set_is_marked_dependent(value); }
 534 
 535   // initialization (virtuals from Klass)
 536   bool should_be_initialized() const;  // means that initialize should be called
 537   void initialize_from_cds(TRAPS);
 538   void initialize(TRAPS);
 539   void link_class(TRAPS);
 540   bool link_class_or_fail(TRAPS); // returns false on failure
 541   void rewrite_class(TRAPS);
 542   void link_methods(TRAPS);
 543   Method* class_initializer() const;
 544 
 545   // reference type
 546   ReferenceType reference_type() const     { return (ReferenceType)_reference_type; }
 547 
 548   // this class cp index
 549   u2 this_class_index() const             { return _this_class_index; }
 550   void set_this_class_index(u2 index)     { _this_class_index = index; }
 551 
 552   static ByteSize reference_type_offset() { return byte_offset_of(InstanceKlass, _reference_type); }
 553 
 554   // find local field, returns true if found
 555   bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
 556   // find field in direct superinterfaces, returns the interface in which the field is defined
 557   Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;

 787   void update_methods_jmethod_cache();
 788 
 789   // annotations support
 790   Annotations* annotations() const          { return _annotations; }
 791   void set_annotations(Annotations* anno)   { _annotations = anno; }
 792 
 793   AnnotationArray* class_annotations() const {
 794     return (_annotations != nullptr) ? _annotations->class_annotations() : nullptr;
 795   }
 796   Array<AnnotationArray*>* fields_annotations() const {
 797     return (_annotations != nullptr) ? _annotations->fields_annotations() : nullptr;
 798   }
 799   AnnotationArray* class_type_annotations() const {
 800     return (_annotations != nullptr) ? _annotations->class_type_annotations() : nullptr;
 801   }
 802   Array<AnnotationArray*>* fields_type_annotations() const {
 803     return (_annotations != nullptr) ? _annotations->fields_type_annotations() : nullptr;
 804   }
 805   // allocation
 806   instanceOop allocate_instance(TRAPS);
 807   static instanceOop allocate_instance(oop cls, const char* who, TRAPS);
 808 
 809   // additional member function to return a handle
 810   instanceHandle allocate_instance_handle(TRAPS);
 811 
 812   objArrayOop allocate_objArray(int n, int length, TRAPS);
 813   // Helper function
 814   static instanceOop register_finalizer(instanceOop i, TRAPS);
 815 
 816   // Check whether reflection/jni/jvm code is allowed to instantiate this class;
 817   // if not, throw either an Error or an Exception.
 818   virtual void check_valid_for_instantiation(bool throwError, TRAPS);
 819 
 820   // initialization
 821   void call_class_initializer(TRAPS);
 822   void set_initialization_state_and_notify(ClassState state, TRAPS);
 823 
 824   // OopMapCache support
 825   OopMapCache* oop_map_cache()               { return _oop_map_cache; }
 826   void set_oop_map_cache(OopMapCache *cache) { _oop_map_cache = cache; }
 827   void mask_for(const methodHandle& method, int bci, InterpreterOopMap* entry);

1067   // Must be one per class and it has to be a VM internal object so java code
1068   // cannot lock it (like the mirror).
1069   // It has to be an object not a Mutex because it's held through java calls.
1070   oop init_lock() const;
1071 
1072   // Returns the array class for the n'th dimension
1073   virtual ArrayKlass* array_klass(int n, TRAPS);
1074   virtual ArrayKlass* array_klass_or_null(int n);
1075 
1076   // Returns the array class with this class as element type
1077   virtual ArrayKlass* array_klass(TRAPS);
1078   virtual ArrayKlass* array_klass_or_null();
1079 
1080   static void clean_initialization_error_table();
1081 private:
1082   void fence_and_clear_init_lock();
1083 
1084   bool link_class_impl                           (TRAPS);
1085   bool verify_code                               (TRAPS);
1086   void initialize_impl                           (TRAPS);
1087   void initialize_super_interfaces(TRAPS);
1088 
1089   void add_initialization_error(JavaThread* current, Handle exception);
1090   oop get_initialization_error(JavaThread* current);
1091 
1092   // find a local method (returns null if not found)
1093   Method* find_method_impl(const Symbol* name,
1094                            const Symbol* signature,
1095                            OverpassLookupMode overpass_mode,
1096                            StaticLookupMode static_mode,
1097                            PrivateLookupMode private_mode) const;
1098 
1099   static Method* find_method_impl(const Array<Method*>* methods,
1100                                   const Symbol* name,
1101                                   const Symbol* signature,
1102                                   OverpassLookupMode overpass_mode,
1103                                   StaticLookupMode static_mode,
1104                                   PrivateLookupMode private_mode);
1105 
1106 #if INCLUDE_JVMTI
1107   // RedefineClasses support
1108   void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }
1109   void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);
1110 #endif
1111   // log class name to classlist
1112   void log_to_classlist() const;
1113 public:
1114 
1115 #if INCLUDE_CDS
1116   // CDS support - remove and restore oops from metadata. Oops are not shared.
1117   virtual void remove_unshareable_info();
1118   void remove_unshareable_flags();
1119   virtual void remove_java_mirror();
1120   void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);
1121   void init_shared_package_entry();
1122   bool can_be_verified_at_dumptime() const;
1123   bool methods_contain_jsr_bytecode() const;
1124   void compute_has_loops_flag_for_methods();
1125 #endif
1126 
1127   bool     has_init_deps_processed() const { return _misc_flags.has_init_deps_processed(); }
1128   void set_has_init_deps_processed() {
1129     assert(is_initialized(), "");
1130     assert(!has_init_deps_processed(), "already set"); // one-off action
1131     _misc_flags.set_has_init_deps_processed(true);
1132   }
1133 
1134   jint compute_modifier_flags() const;
1135 
1136 public:
1137   // JVMTI support
1138   jint jvmti_class_status() const;
1139 
1140   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
1141 
1142  public:
1143   // Printing
1144   void print_on(outputStream* st) const;
1145   void print_value_on(outputStream* st) const;
1146 
1147   void oop_print_value_on(oop obj, outputStream* st);
1148 
1149   void oop_print_on      (oop obj, outputStream* st);
1150 
1151 #ifndef PRODUCT
1152   void print_dependent_nmethods(bool verbose = false);
1153   bool is_dependent_nmethod(nmethod* nm);
< prev index next >