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
428 int java_fields_count() const { return (int)_java_fields_count; }
429
430 Array<u2>* fields() const { return _fields; }
431 void set_fields(Array<u2>* f, u2 java_fields_count) {
432 guarantee(_fields == NULL || f == NULL, "Just checking");
433 _fields = f;
434 _java_fields_count = java_fields_count;
435 }
436
437 // inner classes
438 Array<u2>* inner_classes() const { return _inner_classes; }
439 void set_inner_classes(Array<u2>* f) { _inner_classes = f; }
440
441 // nest members
442 Array<u2>* nest_members() const { return _nest_members; }
443 void set_nest_members(Array<u2>* m) { _nest_members = m; }
444
445 // nest-host index
446 jushort nest_host_index() const { return _nest_host_index; }
447 void set_nest_host_index(u2 i) { _nest_host_index = i; }
448
449 private:
450 // Called to verify that k is a member of this nest - does not look at k's nest-host
451 bool has_nest_member(InstanceKlass* k, TRAPS) const;
452 public:
453 // Returns nest-host class, resolving and validating it if needed
454 // Returns NULL if an exception occurs during loading, or validation fails
455 InstanceKlass* nest_host(Symbol* validationException, TRAPS);
456 // Check if this klass is a nestmate of k - resolves this nest-host and k's
457 bool has_nestmate_access_to(InstanceKlass* k, TRAPS);
458
459 enum InnerClassAttributeOffset {
460 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
461 inner_class_inner_class_info_offset = 0,
462 inner_class_outer_class_info_offset = 1,
463 inner_class_inner_name_offset = 2,
464 inner_class_access_flags_offset = 3,
465 inner_class_next_offset = 4
466 };
467
468 enum EnclosingMethodAttributeOffset {
469 enclosing_method_class_index_offset = 0,
470 enclosing_method_method_index_offset = 1,
471 enclosing_method_attribute_size = 2
472 };
473
474 // method override check
475 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
476
477 // package
738
739 bool has_been_redefined() const {
740 return (_misc_flags & _misc_has_been_redefined) != 0;
741 }
742 void set_has_been_redefined() {
743 _misc_flags |= _misc_has_been_redefined;
744 }
745
746 bool has_passed_fingerprint_check() const {
747 return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
748 }
749 void set_has_passed_fingerprint_check(bool b) {
750 if (b) {
751 _misc_flags |= _misc_has_passed_fingerprint_check;
752 } else {
753 _misc_flags &= ~_misc_has_passed_fingerprint_check;
754 }
755 }
756 bool supers_have_passed_fingerprint_checks();
757
758 static bool should_store_fingerprint(bool is_unsafe_anonymous);
759 bool should_store_fingerprint() const { return should_store_fingerprint(is_unsafe_anonymous()); }
760 bool has_stored_fingerprint() const;
761 uint64_t get_stored_fingerprint() const;
762 void store_fingerprint(uint64_t fingerprint);
763
764 bool is_scratch_class() const {
765 return (_misc_flags & _misc_is_scratch_class) != 0;
766 }
767
768 void set_is_scratch_class() {
769 _misc_flags |= _misc_is_scratch_class;
770 }
771
772 bool has_resolved_methods() const {
773 return (_misc_flags & _misc_has_resolved_methods) != 0;
774 }
775
776 void set_has_resolved_methods() {
777 _misc_flags |= _misc_has_resolved_methods;
778 }
779 private:
1012
1013 static InstanceKlass* cast(Klass* k) {
1014 return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1015 }
1016
1017 static const InstanceKlass* cast(const Klass* k) {
1018 assert(k != NULL, "k should not be null");
1019 assert(k->is_instance_klass(), "cast to InstanceKlass");
1020 return static_cast<const InstanceKlass*>(k);
1021 }
1022
1023 virtual InstanceKlass* java_super() const {
1024 return (super() == NULL) ? NULL : cast(super());
1025 }
1026
1027 // Sizing (in words)
1028 static int header_size() { return sizeof(InstanceKlass)/wordSize; }
1029
1030 static int size(int vtable_length, int itable_length,
1031 int nonstatic_oop_map_size,
1032 bool is_interface, bool is_unsafe_anonymous, bool has_stored_fingerprint) {
1033 return align_metadata_size(header_size() +
1034 vtable_length +
1035 itable_length +
1036 nonstatic_oop_map_size +
1037 (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1038 (is_unsafe_anonymous ? (int)sizeof(Klass*)/wordSize : 0) +
1039 (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0));
1040 }
1041 int size() const { return size(vtable_length(),
1042 itable_length(),
1043 nonstatic_oop_map_size(),
1044 is_interface(),
1045 is_unsafe_anonymous(),
1046 has_stored_fingerprint());
1047 }
1048 #if INCLUDE_SERVICES
1049 virtual void collect_statistics(KlassSizeStats *sz) const;
1050 #endif
1051
1052 intptr_t* start_of_itable() const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1053 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
1054
1055 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1056
1057 oop static_field_base_raw() { return java_mirror(); }
1058
1059 OopMapBlock* start_of_nonstatic_oop_maps() const {
1060 return (OopMapBlock*)(start_of_itable() + itable_length());
1061 }
1062
1063 Klass** end_of_nonstatic_oop_maps() const {
1064 return (Klass**)(start_of_nonstatic_oop_maps() +
1065 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
428 int java_fields_count() const { return (int)_java_fields_count; }
429
430 Array<u2>* fields() const { return _fields; }
431 void set_fields(Array<u2>* f, u2 java_fields_count) {
432 guarantee(_fields == NULL || f == NULL, "Just checking");
433 _fields = f;
434 _java_fields_count = java_fields_count;
435 }
436
437 // inner classes
438 Array<u2>* inner_classes() const { return _inner_classes; }
439 void set_inner_classes(Array<u2>* f) { _inner_classes = f; }
440
441 // nest members
442 Array<u2>* nest_members() const { return _nest_members; }
443 void set_nest_members(Array<u2>* m) { _nest_members = m; }
444
445 // nest-host index
446 jushort nest_host_index() const { return _nest_host_index; }
447 void set_nest_host_index(u2 i) { _nest_host_index = i; }
448 // dynamic nest member support
449 void set_nest_host(InstanceKlass* host, TRAPS);
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 // Returns the runtime nest host. If static nest host is valid, set the nest host;
461 // otherwise this klass is the host of a nest; all errors are ignored
462 InstanceKlass* runtime_nest_host(TRAPS);
463
464 enum InnerClassAttributeOffset {
465 // From http://mirror.eng/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc10.html#18814
466 inner_class_inner_class_info_offset = 0,
467 inner_class_outer_class_info_offset = 1,
468 inner_class_inner_name_offset = 2,
469 inner_class_access_flags_offset = 3,
470 inner_class_next_offset = 4
471 };
472
473 enum EnclosingMethodAttributeOffset {
474 enclosing_method_class_index_offset = 0,
475 enclosing_method_method_index_offset = 1,
476 enclosing_method_attribute_size = 2
477 };
478
479 // method override check
480 bool is_override(const methodHandle& super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
481
482 // package
743
744 bool has_been_redefined() const {
745 return (_misc_flags & _misc_has_been_redefined) != 0;
746 }
747 void set_has_been_redefined() {
748 _misc_flags |= _misc_has_been_redefined;
749 }
750
751 bool has_passed_fingerprint_check() const {
752 return (_misc_flags & _misc_has_passed_fingerprint_check) != 0;
753 }
754 void set_has_passed_fingerprint_check(bool b) {
755 if (b) {
756 _misc_flags |= _misc_has_passed_fingerprint_check;
757 } else {
758 _misc_flags &= ~_misc_has_passed_fingerprint_check;
759 }
760 }
761 bool supers_have_passed_fingerprint_checks();
762
763 static bool should_store_fingerprint(bool is_hidden_or_anonymous);
764 bool should_store_fingerprint() const { return should_store_fingerprint(is_hidden() || is_unsafe_anonymous()); }
765 bool has_stored_fingerprint() const;
766 uint64_t get_stored_fingerprint() const;
767 void store_fingerprint(uint64_t fingerprint);
768
769 bool is_scratch_class() const {
770 return (_misc_flags & _misc_is_scratch_class) != 0;
771 }
772
773 void set_is_scratch_class() {
774 _misc_flags |= _misc_is_scratch_class;
775 }
776
777 bool has_resolved_methods() const {
778 return (_misc_flags & _misc_has_resolved_methods) != 0;
779 }
780
781 void set_has_resolved_methods() {
782 _misc_flags |= _misc_has_resolved_methods;
783 }
784 private:
1017
1018 static InstanceKlass* cast(Klass* k) {
1019 return const_cast<InstanceKlass*>(cast(const_cast<const Klass*>(k)));
1020 }
1021
1022 static const InstanceKlass* cast(const Klass* k) {
1023 assert(k != NULL, "k should not be null");
1024 assert(k->is_instance_klass(), "cast to InstanceKlass");
1025 return static_cast<const InstanceKlass*>(k);
1026 }
1027
1028 virtual InstanceKlass* java_super() const {
1029 return (super() == NULL) ? NULL : cast(super());
1030 }
1031
1032 // Sizing (in words)
1033 static int header_size() { return sizeof(InstanceKlass)/wordSize; }
1034
1035 static int size(int vtable_length, int itable_length,
1036 int nonstatic_oop_map_size,
1037 bool is_interface, bool is_hidden_or_anonymous, bool has_stored_fingerprint) {
1038 return align_metadata_size(header_size() +
1039 vtable_length +
1040 itable_length +
1041 nonstatic_oop_map_size +
1042 (is_interface ? (int)sizeof(Klass*)/wordSize : 0) +
1043 (is_hidden_or_anonymous ? (int)sizeof(Klass*)/wordSize : 0) +
1044 (has_stored_fingerprint ? (int)sizeof(uint64_t*)/wordSize : 0));
1045 }
1046 int size() const { return size(vtable_length(),
1047 itable_length(),
1048 nonstatic_oop_map_size(),
1049 is_interface(),
1050 (is_hidden() || is_unsafe_anonymous()),
1051 has_stored_fingerprint());
1052 }
1053 #if INCLUDE_SERVICES
1054 virtual void collect_statistics(KlassSizeStats *sz) const;
1055 #endif
1056
1057 intptr_t* start_of_itable() const { return (intptr_t*)start_of_vtable() + vtable_length(); }
1058 intptr_t* end_of_itable() const { return start_of_itable() + itable_length(); }
1059
1060 int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; }
1061
1062 oop static_field_base_raw() { return java_mirror(); }
1063
1064 OopMapBlock* start_of_nonstatic_oop_maps() const {
1065 return (OopMapBlock*)(start_of_itable() + itable_length());
1066 }
1067
1068 Klass** end_of_nonstatic_oop_maps() const {
1069 return (Klass**)(start_of_nonstatic_oop_maps() +
1070 nonstatic_oop_map_count());
|