332 set_secondary_supers(Universe::the_empty_klass_array()); |
332 set_secondary_supers(Universe::the_empty_klass_array()); |
333 return NULL; |
333 return NULL; |
334 } |
334 } |
335 |
335 |
336 |
336 |
337 Klass* Klass::subklass() const { |
|
338 return _subklass == NULL ? NULL : _subklass; |
|
339 } |
|
340 |
|
341 InstanceKlass* Klass::superklass() const { |
337 InstanceKlass* Klass::superklass() const { |
342 assert(super() == NULL || super()->oop_is_instance(), "must be instance klass"); |
338 assert(super() == NULL || super()->oop_is_instance(), "must be instance klass"); |
343 return _super == NULL ? NULL : InstanceKlass::cast(_super); |
339 return _super == NULL ? NULL : InstanceKlass::cast(_super); |
344 } |
|
345 |
|
346 Klass* Klass::next_sibling() const { |
|
347 return _next_sibling == NULL ? NULL : _next_sibling; |
|
348 } |
340 } |
349 |
341 |
350 void Klass::set_subklass(Klass* s) { |
342 void Klass::set_subklass(Klass* s) { |
351 assert(s != this, "sanity check"); |
343 assert(s != this, "sanity check"); |
352 _subklass = s; |
344 _subklass = s; |
363 InstanceKlass* super = superklass(); |
355 InstanceKlass* super = superklass(); |
364 if (super == NULL) return; // special case: class Object |
356 if (super == NULL) return; // special case: class Object |
365 assert((!super->is_interface() // interfaces cannot be supers |
357 assert((!super->is_interface() // interfaces cannot be supers |
366 && (super->superklass() == NULL || !is_interface())), |
358 && (super->superklass() == NULL || !is_interface())), |
367 "an interface can only be a subklass of Object"); |
359 "an interface can only be a subklass of Object"); |
368 Klass* prev_first_subklass = super->subklass_oop(); |
360 Klass* prev_first_subklass = super->subklass(); |
369 if (prev_first_subklass != NULL) { |
361 if (prev_first_subklass != NULL) { |
370 // set our sibling to be the superklass' previous first subklass |
362 // set our sibling to be the superklass' previous first subklass |
371 set_next_sibling(prev_first_subklass); |
363 set_next_sibling(prev_first_subklass); |
372 } |
364 } |
373 // make ourselves the superklass' first subklass |
365 // make ourselves the superklass' first subklass |
403 Klass* current = stack.pop(); |
395 Klass* current = stack.pop(); |
404 |
396 |
405 assert(current->is_loader_alive(is_alive), "just checking, this should be live"); |
397 assert(current->is_loader_alive(is_alive), "just checking, this should be live"); |
406 |
398 |
407 // Find and set the first alive subklass |
399 // Find and set the first alive subklass |
408 Klass* sub = current->subklass_oop(); |
400 Klass* sub = current->subklass(); |
409 while (sub != NULL && !sub->is_loader_alive(is_alive)) { |
401 while (sub != NULL && !sub->is_loader_alive(is_alive)) { |
410 #ifndef PRODUCT |
402 #ifndef PRODUCT |
411 if (TraceClassUnloading && WizardMode) { |
403 if (TraceClassUnloading && WizardMode) { |
412 ResourceMark rm; |
404 ResourceMark rm; |
413 tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name()); |
405 tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name()); |
414 } |
406 } |
415 #endif |
407 #endif |
416 sub = sub->next_sibling_oop(); |
408 sub = sub->next_sibling(); |
417 } |
409 } |
418 current->set_subklass(sub); |
410 current->set_subklass(sub); |
419 if (sub != NULL) { |
411 if (sub != NULL) { |
420 stack.push(sub); |
412 stack.push(sub); |
421 } |
413 } |
422 |
414 |
423 // Find and set the first alive sibling |
415 // Find and set the first alive sibling |
424 Klass* sibling = current->next_sibling_oop(); |
416 Klass* sibling = current->next_sibling(); |
425 while (sibling != NULL && !sibling->is_loader_alive(is_alive)) { |
417 while (sibling != NULL && !sibling->is_loader_alive(is_alive)) { |
426 if (TraceClassUnloading && WizardMode) { |
418 if (TraceClassUnloading && WizardMode) { |
427 ResourceMark rm; |
419 ResourceMark rm; |
428 tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name()); |
420 tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name()); |
429 } |
421 } |
430 sibling = sibling->next_sibling_oop(); |
422 sibling = sibling->next_sibling(); |
431 } |
423 } |
432 current->set_next_sibling(sibling); |
424 current->set_next_sibling(sibling); |
433 if (sibling != NULL) { |
425 if (sibling != NULL) { |
434 stack.push(sibling); |
426 stack.push(sibling); |
435 } |
427 } |