227 enum {
228 _misc_rewritten = 1 << 2, // methods rewritten.
229 _misc_has_nonstatic_fields = 1 << 3, // for sizing with UseCompressedOops
230 _misc_should_verify_class = 1 << 4, // allow caching of preverification
231 _misc_is_unsafe_anonymous = 1 << 5, // has embedded _unsafe_anonymous_host field
232 _misc_is_contended = 1 << 6, // marked with contended annotation
233 _misc_has_nonstatic_concrete_methods = 1 << 7, // class/superclass/implemented interfaces has non-static, concrete methods
234 _misc_declares_nonstatic_concrete_methods = 1 << 8, // directly declares non-static, concrete methods
235 _misc_has_been_redefined = 1 << 9, // class has been redefined
236 _misc_has_passed_fingerprint_check = 1 << 10, // when this class was loaded, the fingerprint computed from its
237 // code source was found to be matching the value recorded by AOT.
238 _misc_is_scratch_class = 1 << 11, // class is the redefined scratch class
239 _misc_is_shared_boot_class = 1 << 12, // defining class loader is boot class loader
240 _misc_is_shared_platform_class = 1 << 13, // defining class loader is platform class loader
241 _misc_is_shared_app_class = 1 << 14, // defining class loader is app class loader
242 _misc_has_resolved_methods = 1 << 15 // resolved methods table entries added for this class
243 };
244 u2 loader_type_bits() {
245 return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
246 }
247 u2 _misc_flags;
248 u2 _minor_version; // minor version number of class file
249 u2 _major_version; // major version number of class file
250 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization)
251 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
252 JNIid* _jni_ids; // First JNI identifier for static fields in this class
253 jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
254 nmethodBucket* volatile _dep_context; // packed DependencyContext structure
255 uint64_t volatile _dep_context_last_cleaned;
256 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class
257 #if INCLUDE_JVMTI
258 BreakpointInfo* _breakpoints; // bpt lists, managed by Method*
259 // Linked instanceKlasses of previous versions
260 InstanceKlass* _previous_versions;
261 // JVMTI fields can be moved to their own structure - see 6315920
262 // JVMTI: cached class file, before retransformable agent modified it in CFLH
263 JvmtiCachedClassFileData* _cached_class_file;
264 #endif
265
266 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
267
430 int java_fields_count() const { return (int)_java_fields_count; }
431
432 Array<u2>* fields() const { return _fields; }
433 void set_fields(Array<u2>* f, u2 java_fields_count) {
434 guarantee(_fields == NULL || f == NULL, "Just checking");
435 _fields = f;
436 _java_fields_count = java_fields_count;
437 }
438
439 // inner classes
440 Array<u2>* inner_classes() const { return _inner_classes; }
441 void set_inner_classes(Array<u2>* f) { _inner_classes = f; }
442
443 // nest members
444 Array<u2>* nest_members() const { return _nest_members; }
445 void set_nest_members(Array<u2>* m) { _nest_members = m; }
446
447 // nest-host index
448 jushort nest_host_index() const { return _nest_host_index; }
449 void set_nest_host_index(u2 i) { _nest_host_index = i; }
450
451 private:
452 // Called to verify that k is a member of this nest - does not look at k's nest-host
453 bool has_nest_member(InstanceKlass* k, TRAPS) const;
454 public:
455 // Returns nest-host class, resolving and validating it if needed
456 // Returns NULL if an exception occurs during loading, or validation fails
457 InstanceKlass* nest_host(Symbol* validationException, TRAPS);
458 // Check if this klass is a nestmate of k - resolves this nest-host and k's
459 bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
460
461 enum InnerClassAttributeOffset {
462 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
463 inner_class_inner_class_info_offset = 0,
464 inner_class_outer_class_info_offset = 1,
465 inner_class_inner_name_offset = 2,
466 inner_class_access_flags_offset = 3,
467 inner_class_next_offset = 4
468 };
469
470 enum EnclosingMethodAttributeOffset {
471 enclosing_method_class_index_offset = 0,
472 enclosing_method_method_index_offset = 1,
473 enclosing_method_attribute_size = 2
474 };
475
476 // method override check
477 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
478
479 // package
748
749 bool has_been_redefined() const {
750 return (_misc_flags & _misc_has_been_redefined) != 0;
751 }
752 void set_has_been_redefined() {
753 _misc_flags |= _misc_has_been_redefined;
754 }
755
756 bool has_passed_fingerprint_check() const {
757 return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
758 }
759 void set_has_passed_fingerprint_check(bool b) {
760 if (b) {
761 _misc_flags |= _misc_has_passed_fingerprint_check;
762 } else {
763 _misc_flags &= ~_misc_has_passed_fingerprint_check;
764 }
765 }
766 bool supers_have_passed_fingerprint_checks();
767
768 static bool should_store_fingerprint(bool is_unsafe_anonymous);
769 bool should_store_fingerprint() const { return should_store_fingerprint(is_unsafe_anonymous()); }
770 bool has_stored_fingerprint() const;
771 uint64_t get_stored_fingerprint() const;
772 void store_fingerprint(uint64_t fingerprint);
773
774 bool is_scratch_class() const {
775 return (_misc_flags & _misc_is_scratch_class) != 0;
776 }
777
778 void set_is_scratch_class() {
779 _misc_flags |= _misc_is_scratch_class;
780 }
781
782 bool has_resolved_methods() const {
783 return (_misc_flags & _misc_has_resolved_methods) != 0;
784 }
785
786 void set_has_resolved_methods() {
787 _misc_flags |= _misc_has_resolved_methods;
788 }
789 private:
1021
1022 static InstanceKlass* cast(Klass* k) {
1023 return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1024 }
1025
1026 static const InstanceKlass* cast(const Klass* k) {
1027 assert(k != NULL, "k should not be null");
1028 assert(k->is_instance_klass(), "cast to InstanceKlass");
1029 return static_cast<const InstanceKlass*>(k);
1030 }
1031
1032 virtual InstanceKlass* java_super() const {
1033 return (super() == NULL) ? NULL : cast(super());
1034 }
1035
1036 // Sizing (in words)
1037 static int header_size() { return sizeof(InstanceKlass)/wordSize; }
1038
1039 static int size(int vtable_length, int itable_length,
1040 int nonstatic_oop_map_size,
1041 bool is_interface, bool is_unsafe_anonymous, bool has_stored_fingerprint) {
1042 return align_metadata_size(header_size() +
1043 vtable_length +
1044 itable_length +
1045 nonstatic_oop_map_size +
1046 (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1047 (is_unsafe_anonymous ? (int)sizeof(Klass*)/wordSize : 0) +
1048 (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0));
1049 }
1050 int size() const { return size(vtable_length(),
1051 itable_length(),
1052 nonstatic_oop_map_size(),
1053 is_interface(),
1054 is_unsafe_anonymous(),
1055 has_stored_fingerprint());
1056 }
1057 #if INCLUDE_SERVICES
1058 virtual void collect_statistics(KlassSizeStats *sz) const;
1059 #endif
1060
1061 intptr_t* start_of_itable() const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1062 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
1063
1064 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1065
1066 oop static_field_base_raw() { return java_mirror(); }
1067
1068 OopMapBlock* start_of_nonstatic_oop_maps() const {
1069 return (OopMapBlock*)(start_of_itable() + itable_length());
1070 }
1071
1072 Klass** end_of_nonstatic_oop_maps() const {
1073 return (Klass**)(start_of_nonstatic_oop_maps() +
1074 nonstatic_oop_map_count());
|
227 enum {
228 _misc_rewritten = 1 << 2, // methods rewritten.
229 _misc_has_nonstatic_fields = 1 << 3, // for sizing with UseCompressedOops
230 _misc_should_verify_class = 1 << 4, // allow caching of preverification
231 _misc_is_unsafe_anonymous = 1 << 5, // has embedded _unsafe_anonymous_host field
232 _misc_is_contended = 1 << 6, // marked with contended annotation
233 _misc_has_nonstatic_concrete_methods = 1 << 7, // class/superclass/implemented interfaces has non-static, concrete methods
234 _misc_declares_nonstatic_concrete_methods = 1 << 8, // directly declares non-static, concrete methods
235 _misc_has_been_redefined = 1 << 9, // class has been redefined
236 _misc_has_passed_fingerprint_check = 1 << 10, // when this class was loaded, the fingerprint computed from its
237 // code source was found to be matching the value recorded by AOT.
238 _misc_is_scratch_class = 1 << 11, // class is the redefined scratch class
239 _misc_is_shared_boot_class = 1 << 12, // defining class loader is boot class loader
240 _misc_is_shared_platform_class = 1 << 13, // defining class loader is platform class loader
241 _misc_is_shared_app_class = 1 << 14, // defining class loader is app class loader
242 _misc_has_resolved_methods = 1 << 15 // resolved methods table entries added for this class
243 };
244 u2 loader_type_bits() {
245 return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
246 }
247 u4 _misc_flags;
248 u2 _minor_version; // minor version number of class file
249 u2 _major_version; // major version number of class file
250 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization)
251 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
252 JNIid* _jni_ids; // First JNI identifier for static fields in this class
253 jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none
254 nmethodBucket* volatile _dep_context; // packed DependencyContext structure
255 uint64_t volatile _dep_context_last_cleaned;
256 nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class
257 #if INCLUDE_JVMTI
258 BreakpointInfo* _breakpoints; // bpt lists, managed by Method*
259 // Linked instanceKlasses of previous versions
260 InstanceKlass* _previous_versions;
261 // JVMTI fields can be moved to their own structure - see 6315920
262 // JVMTI: cached class file, before retransformable agent modified it in CFLH
263 JvmtiCachedClassFileData* _cached_class_file;
264 #endif
265
266 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change
267
430 int java_fields_count() const { return (int)_java_fields_count; }
431
432 Array<u2>* fields() const { return _fields; }
433 void set_fields(Array<u2>* f, u2 java_fields_count) {
434 guarantee(_fields == NULL || f == NULL, "Just checking");
435 _fields = f;
436 _java_fields_count = java_fields_count;
437 }
438
439 // inner classes
440 Array<u2>* inner_classes() const { return _inner_classes; }
441 void set_inner_classes(Array<u2>* f) { _inner_classes = f; }
442
443 // nest members
444 Array<u2>* nest_members() const { return _nest_members; }
445 void set_nest_members(Array<u2>* m) { _nest_members = m; }
446
447 // nest-host index
448 jushort nest_host_index() const { return _nest_host_index; }
449 void set_nest_host_index(u2 i) { _nest_host_index = i; }
450 // dynamic nest member support
451 void set_nest_host(InstanceKlass* host, TRAPS);
452
453 private:
454 // Called to verify that k is a member of this nest - does not look at k's nest-host
455 bool has_nest_member(InstanceKlass* k, TRAPS) const;
456 public:
457 // Returns nest-host class, resolving and validating it if needed
458 // Returns NULL if an exception occurs during loading, or validation fails
459 InstanceKlass* nest_host(Symbol* validationException, TRAPS);
460 // Check if this klass is a nestmate of k - resolves this nest-host and k's
461 bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
462 // Returns the runtime nest host. If static nest host is valid, set the nest host;
463 // otherwise this klass is the host of a nest; all errors are ignored
464 InstanceKlass* runtime_nest_host(TRAPS);
465
466 enum InnerClassAttributeOffset {
467 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
468 inner_class_inner_class_info_offset = 0,
469 inner_class_outer_class_info_offset = 1,
470 inner_class_inner_name_offset = 2,
471 inner_class_access_flags_offset = 3,
472 inner_class_next_offset = 4
473 };
474
475 enum EnclosingMethodAttributeOffset {
476 enclosing_method_class_index_offset = 0,
477 enclosing_method_method_index_offset = 1,
478 enclosing_method_attribute_size = 2
479 };
480
481 // method override check
482 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
483
484 // package
753
754 bool has_been_redefined() const {
755 return (_misc_flags & _misc_has_been_redefined) != 0;
756 }
757 void set_has_been_redefined() {
758 _misc_flags |= _misc_has_been_redefined;
759 }
760
761 bool has_passed_fingerprint_check() const {
762 return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
763 }
764 void set_has_passed_fingerprint_check(bool b) {
765 if (b) {
766 _misc_flags |= _misc_has_passed_fingerprint_check;
767 } else {
768 _misc_flags &= ~_misc_has_passed_fingerprint_check;
769 }
770 }
771 bool supers_have_passed_fingerprint_checks();
772
773 static bool should_store_fingerprint(bool is_hidden_or_anonymous);
774 bool should_store_fingerprint() const { return should_store_fingerprint(is_hidden() || is_unsafe_anonymous()); }
775 bool has_stored_fingerprint() const;
776 uint64_t get_stored_fingerprint() const;
777 void store_fingerprint(uint64_t fingerprint);
778
779 bool is_scratch_class() const {
780 return (_misc_flags & _misc_is_scratch_class) != 0;
781 }
782
783 void set_is_scratch_class() {
784 _misc_flags |= _misc_is_scratch_class;
785 }
786
787 bool has_resolved_methods() const {
788 return (_misc_flags & _misc_has_resolved_methods) != 0;
789 }
790
791 void set_has_resolved_methods() {
792 _misc_flags |= _misc_has_resolved_methods;
793 }
794 private:
1026
1027 static InstanceKlass* cast(Klass* k) {
1028 return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1029 }
1030
1031 static const InstanceKlass* cast(const Klass* k) {
1032 assert(k != NULL, "k should not be null");
1033 assert(k->is_instance_klass(), "cast to InstanceKlass");
1034 return static_cast<const InstanceKlass*>(k);
1035 }
1036
1037 virtual InstanceKlass* java_super() const {
1038 return (super() == NULL) ? NULL : cast(super());
1039 }
1040
1041 // Sizing (in words)
1042 static int header_size() { return sizeof(InstanceKlass)/wordSize; }
1043
1044 static int size(int vtable_length, int itable_length,
1045 int nonstatic_oop_map_size,
1046 bool is_interface, bool is_hidden_or_anonymous, bool has_stored_fingerprint) {
1047 return align_metadata_size(header_size() +
1048 vtable_length +
1049 itable_length +
1050 nonstatic_oop_map_size +
1051 (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1052 (is_hidden_or_anonymous ? (int)sizeof(Klass*)/wordSize : 0) +
1053 (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0));
1054 }
1055 int size() const { return size(vtable_length(),
1056 itable_length(),
1057 nonstatic_oop_map_size(),
1058 is_interface(),
1059 (is_hidden() || is_unsafe_anonymous()),
1060 has_stored_fingerprint());
1061 }
1062 #if INCLUDE_SERVICES
1063 virtual void collect_statistics(KlassSizeStats *sz) const;
1064 #endif
1065
1066 intptr_t* start_of_itable() const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1067 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
1068
1069 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1070
1071 oop static_field_base_raw() { return java_mirror(); }
1072
1073 OopMapBlock* start_of_nonstatic_oop_maps() const {
1074 return (OopMapBlock*)(start_of_itable() + itable_length());
1075 }
1076
1077 Klass** end_of_nonstatic_oop_maps() const {
1078 return (Klass**)(start_of_nonstatic_oop_maps() +
1079 nonstatic_oop_map_count());
|