2821 #endif // #ifdef ASSERT
2822
2823 // a class references its super class, interfaces, class loader, ...
2824 // and finally its static fields
2825 inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) {
2826 int i;
2827 Klass* klass = java_lang_Class::as_Klass(java_class);
2828
2829 if (klass->is_instance_klass()) {
2830 InstanceKlass* ik = InstanceKlass::cast(klass);
2831
2832 // Ignore the class if it hasn't been initialized yet
2833 if (!ik->is_linked()) {
2834 return true;
2835 }
2836
2837 // get the java mirror
2838 oop mirror = klass->java_mirror();
2839
2840 // super (only if something more interesting than java.lang.Object)
2841 Klass* java_super = ik->java_super();
2842 if (java_super != NULL && java_super != SystemDictionary::Object_klass()) {
2843 oop super = java_super->java_mirror();
2844 if (!CallbackInvoker::report_superclass_reference(mirror, super)) {
2845 return false;
2846 }
2847 }
2848
2849 // class loader
2850 oop cl = ik->class_loader();
2851 if (cl != NULL) {
2852 if (!CallbackInvoker::report_class_loader_reference(mirror, cl)) {
2853 return false;
2854 }
2855 }
2856
2857 // protection domain
2858 oop pd = ik->protection_domain();
2859 if (pd != NULL) {
2860 if (!CallbackInvoker::report_protection_domain_reference(mirror, pd)) {
2861 return false;
2877 constantTag tag = pool->tag_at(i).value();
2878 if (tag.is_string() || tag.is_klass()) {
2879 oop entry;
2880 if (tag.is_string()) {
2881 entry = pool->resolved_string_at(i);
2882 // If the entry is non-null it is resolved.
2883 if (entry == NULL) continue;
2884 } else {
2885 entry = pool->resolved_klass_at(i)->java_mirror();
2886 }
2887 if (!CallbackInvoker::report_constant_pool_reference(mirror, entry, (jint)i)) {
2888 return false;
2889 }
2890 }
2891 }
2892 }
2893
2894 // interfaces
2895 // (These will already have been reported as references from the constant pool
2896 // but are specified by IterateOverReachableObjects and must be reported).
2897 Array<Klass*>* interfaces = ik->local_interfaces();
2898 for (i = 0; i < interfaces->length(); i++) {
2899 oop interf = ((Klass*)interfaces->at(i))->java_mirror();
2900 if (interf == NULL) {
2901 continue;
2902 }
2903 if (!CallbackInvoker::report_interface_reference(mirror, interf)) {
2904 return false;
2905 }
2906 }
2907
2908 // iterate over the static fields
2909
2910 ClassFieldMap* field_map = ClassFieldMap::create_map_of_static_fields(klass);
2911 for (i=0; i<field_map->field_count(); i++) {
2912 ClassFieldDescriptor* field = field_map->field_at(i);
2913 char type = field->field_type();
2914 if (!is_primitive_field_type(type)) {
2915 oop fld_o = mirror->obj_field(field->field_offset());
2916 assert(verify_static_oop(ik, mirror, field->field_offset()), "sanity check");
2917 if (fld_o != NULL) {
2918 int slot = field->field_index();
2919 if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) {
|
2821 #endif // #ifdef ASSERT
2822
2823 // a class references its super class, interfaces, class loader, ...
2824 // and finally its static fields
2825 inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) {
2826 int i;
2827 Klass* klass = java_lang_Class::as_Klass(java_class);
2828
2829 if (klass->is_instance_klass()) {
2830 InstanceKlass* ik = InstanceKlass::cast(klass);
2831
2832 // Ignore the class if it hasn't been initialized yet
2833 if (!ik->is_linked()) {
2834 return true;
2835 }
2836
2837 // get the java mirror
2838 oop mirror = klass->java_mirror();
2839
2840 // super (only if something more interesting than java.lang.Object)
2841 InstanceKlass* java_super = ik->java_super();
2842 if (java_super != NULL && java_super != SystemDictionary::Object_klass()) {
2843 oop super = java_super->java_mirror();
2844 if (!CallbackInvoker::report_superclass_reference(mirror, super)) {
2845 return false;
2846 }
2847 }
2848
2849 // class loader
2850 oop cl = ik->class_loader();
2851 if (cl != NULL) {
2852 if (!CallbackInvoker::report_class_loader_reference(mirror, cl)) {
2853 return false;
2854 }
2855 }
2856
2857 // protection domain
2858 oop pd = ik->protection_domain();
2859 if (pd != NULL) {
2860 if (!CallbackInvoker::report_protection_domain_reference(mirror, pd)) {
2861 return false;
2877 constantTag tag = pool->tag_at(i).value();
2878 if (tag.is_string() || tag.is_klass()) {
2879 oop entry;
2880 if (tag.is_string()) {
2881 entry = pool->resolved_string_at(i);
2882 // If the entry is non-null it is resolved.
2883 if (entry == NULL) continue;
2884 } else {
2885 entry = pool->resolved_klass_at(i)->java_mirror();
2886 }
2887 if (!CallbackInvoker::report_constant_pool_reference(mirror, entry, (jint)i)) {
2888 return false;
2889 }
2890 }
2891 }
2892 }
2893
2894 // interfaces
2895 // (These will already have been reported as references from the constant pool
2896 // but are specified by IterateOverReachableObjects and must be reported).
2897 Array<InstanceKlass*>* interfaces = ik->local_interfaces();
2898 for (i = 0; i < interfaces->length(); i++) {
2899 oop interf = interfaces->at(i)->java_mirror();
2900 if (interf == NULL) {
2901 continue;
2902 }
2903 if (!CallbackInvoker::report_interface_reference(mirror, interf)) {
2904 return false;
2905 }
2906 }
2907
2908 // iterate over the static fields
2909
2910 ClassFieldMap* field_map = ClassFieldMap::create_map_of_static_fields(klass);
2911 for (i=0; i<field_map->field_count(); i++) {
2912 ClassFieldDescriptor* field = field_map->field_at(i);
2913 char type = field->field_type();
2914 if (!is_primitive_field_type(type)) {
2915 oop fld_o = mirror->obj_field(field->field_offset());
2916 assert(verify_static_oop(ik, mirror, field->field_offset()), "sanity check");
2917 if (fld_o != NULL) {
2918 int slot = field->field_index();
2919 if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) {
|