302 static bool is_finalization_enabled() { return _finalization_enabled; }
303
304 // Sets finalization state
305 static void set_finalization_enabled(bool val) { _finalization_enabled = val; }
306
307 // The three BUILTIN class loader types
308 bool is_shared_boot_class() const { return _misc_flags.is_shared_boot_class(); }
309 bool is_shared_platform_class() const { return _misc_flags.is_shared_platform_class(); }
310 bool is_shared_app_class() const { return _misc_flags.is_shared_app_class(); }
311 // The UNREGISTERED class loader type
312 bool is_shared_unregistered_class() const { return _misc_flags.is_shared_unregistered_class(); }
313
314 // Check if the class can be shared in CDS
315 bool is_shareable() const;
316
317 bool shared_loading_failed() const { return _misc_flags.shared_loading_failed(); }
318
319 void set_shared_loading_failed() { _misc_flags.set_shared_loading_failed(true); }
320
321 #if INCLUDE_CDS
322 void set_shared_class_loader_type(s2 loader_type) { _misc_flags.set_shared_class_loader_type(loader_type); }
323 void assign_class_loader_type() { _misc_flags.assign_class_loader_type(_class_loader_data); }
324 #endif
325
326 bool has_nonstatic_fields() const { return _misc_flags.has_nonstatic_fields(); }
327 void set_has_nonstatic_fields(bool b) { _misc_flags.set_has_nonstatic_fields(b); }
328
329 bool has_localvariable_table() const { return _misc_flags.has_localvariable_table(); }
330 void set_has_localvariable_table(bool b) { _misc_flags.set_has_localvariable_table(b); }
331
332 // field sizes
333 int nonstatic_field_size() const { return _nonstatic_field_size; }
334 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; }
335
336 int static_field_size() const { return _static_field_size; }
337 void set_static_field_size(int size) { _static_field_size = size; }
338
339 int static_oop_field_count() const { return (int)_static_oop_field_count; }
340 void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
341
500 // We can safely access the name as long as we hold the _init_monitor.
501 const char* init_thread_name() {
502 assert(_init_monitor->owned_by_self(), "Must hold _init_monitor here");
503 return init_thread()->name_raw();
504 }
505
506 public:
507 // initialization state
508 bool is_loaded() const { return init_state() >= loaded; }
509 bool is_linked() const { return init_state() >= linked; }
510 bool is_being_linked() const { return init_state() == being_linked; }
511 bool is_initialized() const { return init_state() == fully_initialized; }
512 bool is_not_initialized() const { return init_state() < being_initialized; }
513 bool is_being_initialized() const { return init_state() == being_initialized; }
514 bool is_in_error_state() const { return init_state() == initialization_error; }
515 bool is_init_thread(JavaThread *thread) { return thread == init_thread(); }
516 ClassState init_state() const { return Atomic::load(&_init_state); }
517 const char* init_state_name() const;
518 bool is_rewritten() const { return _misc_flags.rewritten(); }
519
520 class LockLinkState : public StackObj {
521 InstanceKlass* _ik;
522 JavaThread* _current;
523 public:
524 LockLinkState(InstanceKlass* ik, JavaThread* current) : _ik(ik), _current(current) {
525 ik->check_link_state_and_wait(current);
526 }
527 ~LockLinkState() {
528 if (!_ik->is_linked()) {
529 // Reset to loaded if linking failed.
530 _ik->set_initialization_state_and_notify(loaded, _current);
531 }
532 }
533 };
534
535 // is this a sealed class
536 bool is_sealed() const;
537
538 // defineClass specified verification
539 bool should_verify_class() const { return _misc_flags.should_verify_class(); }
540 void set_should_verify_class(bool value) { _misc_flags.set_should_verify_class(value); }
541
542 // marking
543 bool is_marked_dependent() const { return _misc_flags.is_marked_dependent(); }
544 void set_is_marked_dependent(bool value) { _misc_flags.set_is_marked_dependent(value); }
545
546 // initialization (virtuals from Klass)
547 bool should_be_initialized() const; // means that initialize should be called
548 void initialize(TRAPS);
549 void link_class(TRAPS);
550 bool link_class_or_fail(TRAPS); // returns false on failure
551 void rewrite_class(TRAPS);
552 void link_methods(TRAPS);
553 Method* class_initializer() const;
554
555 // reference type
556 ReferenceType reference_type() const { return (ReferenceType)_reference_type; }
557
558 // this class cp index
559 u2 this_class_index() const { return _this_class_index; }
560 void set_this_class_index(u2 index) { _this_class_index = index; }
561
562 static ByteSize reference_type_offset() { return byte_offset_of(InstanceKlass, _reference_type); }
563
564 // find local field, returns true if found
565 bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
566 // find field in direct superinterfaces, returns the interface in which the field is defined
567 Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
799 void update_methods_jmethod_cache();
800
801 // annotations support
802 Annotations* annotations() const { return _annotations; }
803 void set_annotations(Annotations* anno) { _annotations = anno; }
804
805 AnnotationArray* class_annotations() const {
806 return (_annotations != nullptr) ? _annotations->class_annotations() : nullptr;
807 }
808 Array<AnnotationArray*>* fields_annotations() const {
809 return (_annotations != nullptr) ? _annotations->fields_annotations() : nullptr;
810 }
811 AnnotationArray* class_type_annotations() const {
812 return (_annotations != nullptr) ? _annotations->class_type_annotations() : nullptr;
813 }
814 Array<AnnotationArray*>* fields_type_annotations() const {
815 return (_annotations != nullptr) ? _annotations->fields_type_annotations() : nullptr;
816 }
817 // allocation
818 instanceOop allocate_instance(TRAPS);
819 static instanceOop allocate_instance(oop cls, TRAPS);
820
821 // additional member function to return a handle
822 instanceHandle allocate_instance_handle(TRAPS);
823
824 objArrayOop allocate_objArray(int n, int length, TRAPS);
825 // Helper function
826 static instanceOop register_finalizer(instanceOop i, TRAPS);
827
828 // Check whether reflection/jni/jvm code is allowed to instantiate this class;
829 // if not, throw either an Error or an Exception.
830 virtual void check_valid_for_instantiation(bool throwError, TRAPS);
831
832 // initialization
833 void call_class_initializer(TRAPS);
834 void set_initialization_state_and_notify(ClassState state, JavaThread* current);
835
836 // OopMapCache support
837 OopMapCache* oop_map_cache() { return _oop_map_cache; }
838 void set_oop_map_cache(OopMapCache *cache) { _oop_map_cache = cache; }
839 void mask_for(const methodHandle& method, int bci, InterpreterOopMap* entry);
1073 static void clear_jmethod_ids(InstanceKlass* klass);
1074 jmethodID update_jmethod_id(jmethodID* jmeths, Method* method, int idnum);
1075
1076 public:
1077 // Returns the array class for the n'th dimension
1078 virtual ArrayKlass* array_klass(int n, TRAPS);
1079 virtual ArrayKlass* array_klass_or_null(int n);
1080
1081 // Returns the array class with this class as element type
1082 virtual ArrayKlass* array_klass(TRAPS);
1083 virtual ArrayKlass* array_klass_or_null();
1084
1085 static void clean_initialization_error_table();
1086
1087 Monitor* init_monitor() const { return _init_monitor; }
1088 private:
1089 void check_link_state_and_wait(JavaThread* current);
1090 bool link_class_impl (TRAPS);
1091 bool verify_code (TRAPS);
1092 void initialize_impl (TRAPS);
1093 void initialize_super_interfaces (TRAPS);
1094
1095 void add_initialization_error(JavaThread* current, Handle exception);
1096 oop get_initialization_error(JavaThread* current);
1097
1098 // find a local method (returns null if not found)
1099 Method* find_method_impl(const Symbol* name,
1100 const Symbol* signature,
1101 OverpassLookupMode overpass_mode,
1102 StaticLookupMode static_mode,
1103 PrivateLookupMode private_mode) const;
1104
1105 static Method* find_method_impl(const Array<Method*>* methods,
1106 const Symbol* name,
1107 const Symbol* signature,
1108 OverpassLookupMode overpass_mode,
1109 StaticLookupMode static_mode,
1110 PrivateLookupMode private_mode);
1111
1112 #if INCLUDE_JVMTI
1113 // RedefineClasses support
1114 void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }
1115 void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);
1116 #endif
1117 // log class name to classlist
1118 void log_to_classlist() const;
1119 public:
1120
1121 #if INCLUDE_CDS
1122 // CDS support - remove and restore oops from metadata. Oops are not shared.
1123 virtual void remove_unshareable_info();
1124 void remove_unshareable_flags();
1125 virtual void remove_java_mirror();
1126 void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);
1127 void init_shared_package_entry();
1128 bool can_be_verified_at_dumptime() const;
1129 bool methods_contain_jsr_bytecode() const;
1130 void compute_has_loops_flag_for_methods();
1131 #endif
1132
1133 jint compute_modifier_flags() const;
1134
1135 public:
1136 // JVMTI support
1137 jint jvmti_class_status() const;
1138
1139 virtual void metaspace_pointers_do(MetaspaceClosure* iter);
1140
1141 public:
1142 // Printing
1143 void print_on(outputStream* st) const;
1144 void print_value_on(outputStream* st) const;
1145
1146 void oop_print_value_on(oop obj, outputStream* st);
1147
1148 void oop_print_on (oop obj, outputStream* st);
1149
1150 #ifndef PRODUCT
1151 void print_dependent_nmethods(bool verbose = false);
1152 bool is_dependent_nmethod(nmethod* nm);
|
302 static bool is_finalization_enabled() { return _finalization_enabled; }
303
304 // Sets finalization state
305 static void set_finalization_enabled(bool val) { _finalization_enabled = val; }
306
307 // The three BUILTIN class loader types
308 bool is_shared_boot_class() const { return _misc_flags.is_shared_boot_class(); }
309 bool is_shared_platform_class() const { return _misc_flags.is_shared_platform_class(); }
310 bool is_shared_app_class() const { return _misc_flags.is_shared_app_class(); }
311 // The UNREGISTERED class loader type
312 bool is_shared_unregistered_class() const { return _misc_flags.is_shared_unregistered_class(); }
313
314 // Check if the class can be shared in CDS
315 bool is_shareable() const;
316
317 bool shared_loading_failed() const { return _misc_flags.shared_loading_failed(); }
318
319 void set_shared_loading_failed() { _misc_flags.set_shared_loading_failed(true); }
320
321 #if INCLUDE_CDS
322 int shared_class_loader_type() const;
323 void set_shared_class_loader_type(s2 loader_type) { _misc_flags.set_shared_class_loader_type(loader_type); }
324 void assign_class_loader_type() { _misc_flags.assign_class_loader_type(_class_loader_data); }
325 #endif
326
327 bool has_nonstatic_fields() const { return _misc_flags.has_nonstatic_fields(); }
328 void set_has_nonstatic_fields(bool b) { _misc_flags.set_has_nonstatic_fields(b); }
329
330 bool has_localvariable_table() const { return _misc_flags.has_localvariable_table(); }
331 void set_has_localvariable_table(bool b) { _misc_flags.set_has_localvariable_table(b); }
332
333 // field sizes
334 int nonstatic_field_size() const { return _nonstatic_field_size; }
335 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; }
336
337 int static_field_size() const { return _static_field_size; }
338 void set_static_field_size(int size) { _static_field_size = size; }
339
340 int static_oop_field_count() const { return (int)_static_oop_field_count; }
341 void set_static_oop_field_count(u2 size) { _static_oop_field_count = size; }
342
501 // We can safely access the name as long as we hold the _init_monitor.
502 const char* init_thread_name() {
503 assert(_init_monitor->owned_by_self(), "Must hold _init_monitor here");
504 return init_thread()->name_raw();
505 }
506
507 public:
508 // initialization state
509 bool is_loaded() const { return init_state() >= loaded; }
510 bool is_linked() const { return init_state() >= linked; }
511 bool is_being_linked() const { return init_state() == being_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_init_thread(JavaThread *thread) { return thread == init_thread(); }
517 ClassState init_state() const { return Atomic::load(&_init_state); }
518 const char* init_state_name() const;
519 bool is_rewritten() const { return _misc_flags.rewritten(); }
520
521 static const char* state2name(ClassState state);
522
523 class LockLinkState : public StackObj {
524 InstanceKlass* _ik;
525 JavaThread* _current;
526 public:
527 LockLinkState(InstanceKlass* ik, JavaThread* current) : _ik(ik), _current(current) {
528 ik->check_link_state_and_wait(current);
529 }
530 ~LockLinkState() {
531 if (!_ik->is_linked()) {
532 // Reset to loaded if linking failed.
533 _ik->set_initialization_state_and_notify(loaded, _current);
534 }
535 }
536 };
537
538 // is this a sealed class
539 bool is_sealed() const;
540
541 // defineClass specified verification
542 bool should_verify_class() const { return _misc_flags.should_verify_class(); }
543 void set_should_verify_class(bool value) { _misc_flags.set_should_verify_class(value); }
544
545 // marking
546 bool is_marked_dependent() const { return _misc_flags.is_marked_dependent(); }
547 void set_is_marked_dependent(bool value) { _misc_flags.set_is_marked_dependent(value); }
548
549 // initialization (virtuals from Klass)
550 bool should_be_initialized() const; // means that initialize should be called
551 void initialize_from_cds(TRAPS);
552 void initialize(TRAPS);
553 void link_class(TRAPS);
554 bool link_class_or_fail(TRAPS); // returns false on failure
555 void rewrite_class(TRAPS);
556 void link_methods(TRAPS);
557 Method* class_initializer() const;
558
559 // reference type
560 ReferenceType reference_type() const { return (ReferenceType)_reference_type; }
561
562 // this class cp index
563 u2 this_class_index() const { return _this_class_index; }
564 void set_this_class_index(u2 index) { _this_class_index = index; }
565
566 static ByteSize reference_type_offset() { return byte_offset_of(InstanceKlass, _reference_type); }
567
568 // find local field, returns true if found
569 bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
570 // find field in direct superinterfaces, returns the interface in which the field is defined
571 Klass* find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
803 void update_methods_jmethod_cache();
804
805 // annotations support
806 Annotations* annotations() const { return _annotations; }
807 void set_annotations(Annotations* anno) { _annotations = anno; }
808
809 AnnotationArray* class_annotations() const {
810 return (_annotations != nullptr) ? _annotations->class_annotations() : nullptr;
811 }
812 Array<AnnotationArray*>* fields_annotations() const {
813 return (_annotations != nullptr) ? _annotations->fields_annotations() : nullptr;
814 }
815 AnnotationArray* class_type_annotations() const {
816 return (_annotations != nullptr) ? _annotations->class_type_annotations() : nullptr;
817 }
818 Array<AnnotationArray*>* fields_type_annotations() const {
819 return (_annotations != nullptr) ? _annotations->fields_type_annotations() : nullptr;
820 }
821 // allocation
822 instanceOop allocate_instance(TRAPS);
823 static instanceOop allocate_instance(oop cls, const char* who, TRAPS);
824
825 // additional member function to return a handle
826 instanceHandle allocate_instance_handle(TRAPS);
827
828 objArrayOop allocate_objArray(int n, int length, TRAPS);
829 // Helper function
830 static instanceOop register_finalizer(instanceOop i, TRAPS);
831
832 // Check whether reflection/jni/jvm code is allowed to instantiate this class;
833 // if not, throw either an Error or an Exception.
834 virtual void check_valid_for_instantiation(bool throwError, TRAPS);
835
836 // initialization
837 void call_class_initializer(TRAPS);
838 void set_initialization_state_and_notify(ClassState state, JavaThread* current);
839
840 // OopMapCache support
841 OopMapCache* oop_map_cache() { return _oop_map_cache; }
842 void set_oop_map_cache(OopMapCache *cache) { _oop_map_cache = cache; }
843 void mask_for(const methodHandle& method, int bci, InterpreterOopMap* entry);
1077 static void clear_jmethod_ids(InstanceKlass* klass);
1078 jmethodID update_jmethod_id(jmethodID* jmeths, Method* method, int idnum);
1079
1080 public:
1081 // Returns the array class for the n'th dimension
1082 virtual ArrayKlass* array_klass(int n, TRAPS);
1083 virtual ArrayKlass* array_klass_or_null(int n);
1084
1085 // Returns the array class with this class as element type
1086 virtual ArrayKlass* array_klass(TRAPS);
1087 virtual ArrayKlass* array_klass_or_null();
1088
1089 static void clean_initialization_error_table();
1090
1091 Monitor* init_monitor() const { return _init_monitor; }
1092 private:
1093 void check_link_state_and_wait(JavaThread* current);
1094 bool link_class_impl (TRAPS);
1095 bool verify_code (TRAPS);
1096 void initialize_impl (TRAPS);
1097 void initialize_super_interfaces(TRAPS);
1098
1099 void add_initialization_error(JavaThread* current, Handle exception);
1100 oop get_initialization_error(JavaThread* current);
1101
1102 // find a local method (returns null if not found)
1103 Method* find_method_impl(const Symbol* name,
1104 const Symbol* signature,
1105 OverpassLookupMode overpass_mode,
1106 StaticLookupMode static_mode,
1107 PrivateLookupMode private_mode) const;
1108
1109 static Method* find_method_impl(const Array<Method*>* methods,
1110 const Symbol* name,
1111 const Symbol* signature,
1112 OverpassLookupMode overpass_mode,
1113 StaticLookupMode static_mode,
1114 PrivateLookupMode private_mode);
1115
1116 #if INCLUDE_JVMTI
1117 // RedefineClasses support
1118 void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; }
1119 void mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count);
1120 #endif
1121 // log class name to classlist
1122 void log_to_classlist() const;
1123 public:
1124
1125 #if INCLUDE_CDS
1126 // CDS support - remove and restore oops from metadata. Oops are not shared.
1127 virtual void remove_unshareable_info();
1128 void remove_unshareable_flags();
1129 virtual void remove_java_mirror();
1130 void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS);
1131 void init_shared_package_entry();
1132 bool can_be_verified_at_dumptime() const;
1133 bool methods_contain_jsr_bytecode() const;
1134 void compute_has_loops_flag_for_methods();
1135 #endif
1136
1137 bool has_init_deps_processed() const { return _misc_flags.has_init_deps_processed(); }
1138 void set_has_init_deps_processed() {
1139 assert(is_initialized(), "");
1140 assert(!has_init_deps_processed(), "already set"); // one-off action
1141 _misc_flags.set_has_init_deps_processed(true);
1142 }
1143
1144 jint compute_modifier_flags() const;
1145
1146 public:
1147 // JVMTI support
1148 jint jvmti_class_status() const;
1149
1150 virtual void metaspace_pointers_do(MetaspaceClosure* iter);
1151
1152 public:
1153 // Printing
1154 void print_on(outputStream* st) const;
1155 void print_value_on(outputStream* st) const;
1156
1157 void oop_print_value_on(oop obj, outputStream* st);
1158
1159 void oop_print_on (oop obj, outputStream* st);
1160
1161 #ifndef PRODUCT
1162 void print_dependent_nmethods(bool verbose = false);
1163 bool is_dependent_nmethod(nmethod* nm);
|