--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Wed Jul 09 21:56:16 2014 +0000
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Thu Jul 10 15:12:48 2014 +0200
@@ -717,11 +717,22 @@
// unneeded entries.
bool has_redefined_a_class = JvmtiExport::has_redefined_a_class();
MetadataOnStackMark md_on_stack;
+ if (has_redefined_a_class) {
+ // purge_previous_versions also cleans weak method links. Because
+ // one method's MDO can reference another method from another
+ // class loader, we need to first clean weak method links for all
+ // class loaders here. Below, we can then free redefined methods
+ // for all class loaders.
+ while (data != NULL) {
+ if (data->is_alive(is_alive_closure)) {
+ data->classes_do(InstanceKlass::purge_previous_versions);
+ }
+ data = data->next();
+ }
+ }
+ data = _head;
while (data != NULL) {
if (data->is_alive(is_alive_closure)) {
- if (has_redefined_a_class) {
- data->classes_do(InstanceKlass::purge_previous_versions);
- }
data->free_deallocate_list();
prev = data;
data = data->next();