1052 assert(h_init_lock() != NULL, "The initialization state should never be set twice"); |
1052 assert(h_init_lock() != NULL, "The initialization state should never be set twice"); |
1053 set_init_state(state); |
1053 set_init_state(state); |
1054 } |
1054 } |
1055 } |
1055 } |
1056 |
1056 |
1057 Klass* InstanceKlass::implementor(bool log) const { |
1057 Klass* InstanceKlass::implementor() const { |
1058 assert_locked_or_safepoint(Compile_lock); |
1058 assert_locked_or_safepoint(Compile_lock); |
1059 Klass** k = adr_implementor(); |
1059 Klass** k = adr_implementor(); |
1060 if (k == NULL) { |
1060 if (k == NULL) { |
1061 return NULL; |
1061 return NULL; |
1062 } else { |
1062 } else { |
1063 Klass* kls = *k; |
1063 return *k; |
1064 if (kls != NULL && !kls->is_loader_alive()) { |
1064 } |
1065 if (log) { |
1065 } |
1066 if (log_is_enabled(Trace, class, unload)) { |
|
1067 ResourceMark rm; |
|
1068 log_trace(class, unload)("unlinking class (implementor): %s", kls->external_name()); |
|
1069 } |
|
1070 } |
|
1071 return NULL; // don't return unloaded class |
|
1072 } else { |
|
1073 return kls; |
|
1074 } |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 |
1066 |
1079 void InstanceKlass::set_implementor(Klass* k) { |
1067 void InstanceKlass::set_implementor(Klass* k) { |
1080 assert_lock_strong(Compile_lock); |
1068 assert_lock_strong(Compile_lock); |
1081 assert(is_interface(), "not interface"); |
1069 assert(is_interface(), "not interface"); |
1082 Klass** addr = adr_implementor(); |
1070 Klass** addr = adr_implementor(); |
2149 DependencyContext dep_context(&_dep_context); |
2137 DependencyContext dep_context(&_dep_context); |
2150 dep_context.expunge_stale_entries(); |
2138 dep_context.expunge_stale_entries(); |
2151 } |
2139 } |
2152 |
2140 |
2153 void InstanceKlass::clean_implementors_list() { |
2141 void InstanceKlass::clean_implementors_list() { |
2154 assert_locked_or_safepoint(Compile_lock); |
|
2155 assert(is_loader_alive(), "this klass should be live"); |
2142 assert(is_loader_alive(), "this klass should be live"); |
2156 if (is_interface()) { |
2143 if (is_interface()) { |
2157 assert (ClassUnloading, "only called for ClassUnloading"); |
2144 if (ClassUnloading) { |
2158 Klass* impl = implementor(true); |
2145 Klass* impl = implementor(); |
2159 if (impl == NULL) { |
2146 if (impl != NULL) { |
2160 // NULL this field, might be an unloaded klass or NULL |
2147 if (!impl->is_loader_alive()) { |
2161 Klass** klass = adr_implementor(); |
2148 // remove this guy |
2162 *klass = NULL; |
2149 Klass** klass = adr_implementor(); |
|
2150 assert(klass != NULL, "null klass"); |
|
2151 if (klass != NULL) { |
|
2152 *klass = NULL; |
|
2153 } |
|
2154 } |
|
2155 } |
2163 } |
2156 } |
2164 } |
2157 } |
2165 } |
2158 } |
2166 |
2159 |
2167 void InstanceKlass::clean_method_data() { |
2160 void InstanceKlass::clean_method_data() { |
3085 st->print(BULLET"access: "); access_flags().print_on(st); st->cr(); |
3078 st->print(BULLET"access: "); access_flags().print_on(st); st->cr(); |
3086 st->print(BULLET"state: "); st->print_cr("%s", state_names[_init_state]); |
3079 st->print(BULLET"state: "); st->print_cr("%s", state_names[_init_state]); |
3087 st->print(BULLET"name: "); name()->print_value_on(st); st->cr(); |
3080 st->print(BULLET"name: "); name()->print_value_on(st); st->cr(); |
3088 st->print(BULLET"super: "); Metadata::print_value_on_maybe_null(st, super()); st->cr(); |
3081 st->print(BULLET"super: "); Metadata::print_value_on_maybe_null(st, super()); st->cr(); |
3089 st->print(BULLET"sub: "); |
3082 st->print(BULLET"sub: "); |
3090 { |
3083 Klass* sub = subklass(); |
|
3084 int n; |
|
3085 for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) { |
|
3086 if (n < MaxSubklassPrintSize) { |
|
3087 sub->print_value_on(st); |
|
3088 st->print(" "); |
|
3089 } |
|
3090 } |
|
3091 if (n >= MaxSubklassPrintSize) st->print("(" INTX_FORMAT " more klasses...)", n - MaxSubklassPrintSize); |
|
3092 st->cr(); |
|
3093 |
|
3094 if (is_interface()) { |
3091 MutexLocker ml(Compile_lock); |
3095 MutexLocker ml(Compile_lock); |
3092 Klass* sub = subklass(); |
3096 st->print_cr(BULLET"nof implementors: %d", nof_implementors()); |
3093 int n; |
3097 if (nof_implementors() == 1) { |
3094 for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) { |
3098 st->print_cr(BULLET"implementor: "); |
3095 if (n < MaxSubklassPrintSize) { |
3099 st->print(" "); |
3096 sub->print_value_on(st); |
3100 implementor()->print_value_on(st); |
3097 st->print(" "); |
3101 st->cr(); |
3098 } |
3102 } |
3099 } |
3103 } |
3100 if (n >= MaxSubklassPrintSize) st->print("(" INTX_FORMAT " more klasses...)", n - MaxSubklassPrintSize); |
3104 |
3101 st->cr(); |
|
3102 |
|
3103 if (is_interface()) { |
|
3104 st->print_cr(BULLET"nof implementors: %d", nof_implementors()); |
|
3105 if (nof_implementors() == 1) { |
|
3106 st->print_cr(BULLET"implementor: "); |
|
3107 st->print(" "); |
|
3108 implementor()->print_value_on(st); |
|
3109 st->cr(); |
|
3110 } |
|
3111 } |
|
3112 } |
|
3113 st->print(BULLET"arrays: "); Metadata::print_value_on_maybe_null(st, array_klasses()); st->cr(); |
3105 st->print(BULLET"arrays: "); Metadata::print_value_on_maybe_null(st, array_klasses()); st->cr(); |
3114 st->print(BULLET"methods: "); methods()->print_value_on(st); st->cr(); |
3106 st->print(BULLET"methods: "); methods()->print_value_on(st); st->cr(); |
3115 if (Verbose || WizardMode) { |
3107 if (Verbose || WizardMode) { |
3116 Array<Method*>* method_array = methods(); |
3108 Array<Method*>* method_array = methods(); |
3117 for (int i = 0; i < method_array->length(); i++) { |
3109 for (int i = 0; i < method_array->length(); i++) { |
3489 // $$$ This used to be done only for m/s collections. Doing it |
3481 // $$$ This used to be done only for m/s collections. Doing it |
3490 // always seemed a valid generalization. (DLD -- 6/00) |
3482 // always seemed a valid generalization. (DLD -- 6/00) |
3491 vtable().verify(st); |
3483 vtable().verify(st); |
3492 } |
3484 } |
3493 |
3485 |
3494 // This is called from add_to_hierarchy when the Compile_lock is owned. |
3486 // Verify first subklass |
3495 { |
3487 if (subklass() != NULL) { |
3496 MutexLockerEx ml(Compile_lock->owned_by_self() ? NULL : Compile_lock); |
3488 guarantee(subklass()->is_klass(), "should be klass"); |
3497 // Verify first subklass |
3489 } |
3498 if (subklass() != NULL) { |
3490 |
3499 guarantee(subklass()->is_klass(), "should be klass"); |
3491 // Verify siblings |
3500 } |
3492 Klass* super = this->super(); |
3501 |
3493 Klass* sib = next_sibling(); |
3502 // Verify siblings |
3494 if (sib != NULL) { |
3503 Klass* super = this->super(); |
3495 if (sib == this) { |
3504 Klass* sib = next_sibling(); |
3496 fatal("subclass points to itself " PTR_FORMAT, p2i(sib)); |
3505 if (sib != NULL) { |
3497 } |
3506 if (sib == this) { |
3498 |
3507 fatal("subclass points to itself " PTR_FORMAT, p2i(sib)); |
3499 guarantee(sib->is_klass(), "should be klass"); |
3508 } |
3500 guarantee(sib->super() == super, "siblings should have same superklass"); |
3509 |
3501 } |
3510 guarantee(sib->is_klass(), "should be klass"); |
3502 |
3511 guarantee(sib->super() == super, "siblings should have same superklass"); |
3503 // Verify implementor fields requires the Compile_lock, but this is sometimes |
3512 } |
3504 // called inside a safepoint, so don't verify. |
3513 |
|
3514 // Verify implementor fields requires the Compile_lock, |
|
3515 // but this is sometimes called inside a safepoint, so don't verify. |
|
3516 } |
|
3517 |
3505 |
3518 // Verify local interfaces |
3506 // Verify local interfaces |
3519 if (local_interfaces()) { |
3507 if (local_interfaces()) { |
3520 Array<InstanceKlass*>* local_interfaces = this->local_interfaces(); |
3508 Array<InstanceKlass*>* local_interfaces = this->local_interfaces(); |
3521 for (int j = 0; j < local_interfaces->length(); j++) { |
3509 for (int j = 0; j < local_interfaces->length(); j++) { |