src/hotspot/share/oops/instanceKlass.cpp
changeset 51887 32161fbea3fe
parent 51697 49e1b21d9878
child 51962 628909466216
equal deleted inserted replaced
51883:7e78be444e68 51887:32161fbea3fe
  2415 static void clear_all_breakpoints(Method* m) {
  2415 static void clear_all_breakpoints(Method* m) {
  2416   m->clear_all_breakpoints();
  2416   m->clear_all_breakpoints();
  2417 }
  2417 }
  2418 #endif
  2418 #endif
  2419 
  2419 
  2420 void InstanceKlass::notify_unload_class(InstanceKlass* ik) {
  2420 void InstanceKlass::unload_class(InstanceKlass* ik) {
       
  2421   // Release dependencies.
       
  2422   ik->dependencies().remove_all_dependents();
       
  2423 
  2421   // notify the debugger
  2424   // notify the debugger
  2422   if (JvmtiExport::should_post_class_unload()) {
  2425   if (JvmtiExport::should_post_class_unload()) {
  2423     JvmtiExport::post_class_unload(ik);
  2426     JvmtiExport::post_class_unload(ik);
  2424   }
  2427   }
  2425 
  2428 
  2460   if (jmeths != (jmethodID*)NULL) {
  2463   if (jmeths != (jmethodID*)NULL) {
  2461     release_set_methods_jmethod_ids(NULL);
  2464     release_set_methods_jmethod_ids(NULL);
  2462     FreeHeap(jmeths);
  2465     FreeHeap(jmeths);
  2463   }
  2466   }
  2464 
  2467 
  2465   // Release dependencies.
  2468   assert(_dep_context == DependencyContext::EMPTY,
  2466   // It is desirable to use DC::remove_all_dependents() here, but, unfortunately,
  2469          "dependencies should already be cleaned");
  2467   // it is not safe (see JDK-8143408). The problem is that the klass dependency
       
  2468   // context can contain live dependencies, since there's a race between nmethod &
       
  2469   // klass unloading. If the klass is dead when nmethod unloading happens, relevant
       
  2470   // dependencies aren't removed from the context associated with the class (see
       
  2471   // nmethod::flush_dependencies). It ends up during klass unloading as seemingly
       
  2472   // live dependencies pointing to unloaded nmethods and causes a crash in
       
  2473   // DC::remove_all_dependents() when it touches unloaded nmethod.
       
  2474   dependencies().wipe();
       
  2475 
  2470 
  2476 #if INCLUDE_JVMTI
  2471 #if INCLUDE_JVMTI
  2477   // Deallocate breakpoint records
  2472   // Deallocate breakpoint records
  2478   if (breakpoints() != 0x0) {
  2473   if (breakpoints() != 0x0) {
  2479     methods_do(clear_all_breakpoints);
  2474     methods_do(clear_all_breakpoints);