< prev index next >

src/share/vm/prims/jvmtiRedefineClasses.cpp

Print this page
rev 9032 : [mq]: JDK-8178870_coredump.patch

*** 65,74 **** --- 65,79 ---- _class_defs = class_defs; _class_load_kind = class_load_kind; _res = JVMTI_ERROR_NONE; } + static inline InstanceKlass* get_ik(jclass def) { + oop mirror = JNIHandles::resolve_non_null(def); + return InstanceKlass::cast(java_lang_Class::as_Klass(mirror)); + } + bool VM_RedefineClasses::doit_prologue() { if (_class_count == 0) { _res = JVMTI_ERROR_NONE; return false; }
*** 103,112 **** --- 108,122 ---- for (int i = 0; i < _class_count; i++) { if (_scratch_classes[i] != NULL) { ClassLoaderData* cld = _scratch_classes[i]->class_loader_data(); // Free the memory for this class at class unloading time. Not before // because CMS might think this is still live. + InstanceKlass* ik = get_ik(_class_defs[i].klass); + if (ik->get_cached_class_file() == ((InstanceKlass*)_scratch_classes[i])->get_cached_class_file()) { + // Don't double-free cached_class_file copied from the original class if error. + ((InstanceKlass*)_scratch_classes[i])->set_cached_class_file(NULL); + } cld->add_to_deallocate_list((InstanceKlass*)_scratch_classes[i]); } } // Free os::malloc allocated memory in load_new_class_version. os::free(_scratch_classes);
*** 3978,3993 **** // The class file bytes from before any retransformable agents mucked // with them was cached on the scratch class, move to the_class. // Note: we still want to do this if nothing needed caching since it // should get cleared in the_class too. ! if (the_class->get_cached_class_file_bytes() == 0) { // the_class doesn't have a cache yet so copy it the_class->set_cached_class_file(scratch_class->get_cached_class_file()); } ! else if (scratch_class->get_cached_class_file_bytes() != ! the_class->get_cached_class_file_bytes()) { // The same class can be present twice in the scratch classes list or there // are multiple concurrent RetransformClasses calls on different threads. // In such cases we have to deallocate scratch_class cached_class_file. os::free(scratch_class->get_cached_class_file()); } --- 3988,4003 ---- // The class file bytes from before any retransformable agents mucked // with them was cached on the scratch class, move to the_class. // Note: we still want to do this if nothing needed caching since it // should get cleared in the_class too. ! if (the_class->get_cached_class_file() == 0) { // the_class doesn't have a cache yet so copy it the_class->set_cached_class_file(scratch_class->get_cached_class_file()); } ! else if (scratch_class->get_cached_class_file() != ! the_class->get_cached_class_file()) { // The same class can be present twice in the scratch classes list or there // are multiple concurrent RetransformClasses calls on different threads. // In such cases we have to deallocate scratch_class cached_class_file. os::free(scratch_class->get_cached_class_file()); }
< prev index next >