During SystemDictionary::purge(), we used to call ik->dependencies().remove_all_dependents() on dead instance klasses that were about to be deleted. But that was buggy as nmethod unloading happening before purge() could have removed nmethods that died. So instead a new member function, ik->dependencies().wipe() was called during purge to solve that problem (https://bugs.openjdk.java.net/browse/JDK-8143408).
This code breaks the idea of removing external references to dead metadata before purge. Therefore, I think it would be more ideal to move the cleaning of the DependencyContexts from SystemDictionary::do_unloading() instead. That way, when implementing concurrent class unloading, we can focus the locking in do_unloading and just delete things in SystemDictionary::purge(), after a rendezvous handshake. This also sounds like a better solution to the earlier bug.
This code breaks the idea of removing external references to dead metadata before purge. Therefore, I think it would be more ideal to move the cleaning of the DependencyContexts from SystemDictionary::do_unloading() instead. That way, when implementing concurrent class unloading, we can focus the locking in do_unloading and just delete things in SystemDictionary::purge(), after a rendezvous handshake. This also sounds like a better solution to the earlier bug.