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