3976 3977 old_constants->set_pool_holder(scratch_class()); 3978 #endif 3979 3980 // track number of methods that are EMCP for add_previous_version() call below 3981 int emcp_method_count = check_methods_and_mark_as_obsolete(); 3982 transfer_old_native_function_registrations(the_class); 3983 3984 // The class file bytes from before any retransformable agents mucked 3985 // with them was cached on the scratch class, move to the_class. 3986 // Note: we still want to do this if nothing needed caching since it 3987 // should get cleared in the_class too. 3988 if (the_class->get_cached_class_file_bytes() == 0) { 3989 // the_class doesn't have a cache yet so copy it 3990 the_class->set_cached_class_file(scratch_class->get_cached_class_file()); 3991 } 3992 else if (scratch_class->get_cached_class_file_bytes() != 3993 the_class->get_cached_class_file_bytes()) { 3994 // The same class can be present twice in the scratch classes list or there 3995 // are multiple concurrent RetransformClasses calls on different threads. 3996 // In such cases we have to deallocate scratch_class cached_class_file_bytes. 3997 os::free(scratch_class->get_cached_class_file_bytes()); 3998 } 3999 4000 // NULL out in scratch class to not delete twice. The class to be redefined 4001 // always owns these bytes. 4002 scratch_class->set_cached_class_file(NULL); 4003 4004 // Replace inner_classes 4005 Array<u2>* old_inner_classes = the_class->inner_classes(); 4006 the_class->set_inner_classes(scratch_class->inner_classes()); 4007 scratch_class->set_inner_classes(old_inner_classes); 4008 4009 // Initialize the vtable and interface table after 4010 // methods have been rewritten 4011 { 4012 ResourceMark rm(THREAD); 4013 // no exception should happen here since we explicitly 4014 // do not check loader constraints. 4015 // compare_and_normalize_class_versions has already checked: 4016 // - classloaders unchanged, signatures unchanged 4017 // - all instanceKlasses for redefined classes reused & contents updated | 3976 3977 old_constants->set_pool_holder(scratch_class()); 3978 #endif 3979 3980 // track number of methods that are EMCP for add_previous_version() call below 3981 int emcp_method_count = check_methods_and_mark_as_obsolete(); 3982 transfer_old_native_function_registrations(the_class); 3983 3984 // The class file bytes from before any retransformable agents mucked 3985 // with them was cached on the scratch class, move to the_class. 3986 // Note: we still want to do this if nothing needed caching since it 3987 // should get cleared in the_class too. 3988 if (the_class->get_cached_class_file_bytes() == 0) { 3989 // the_class doesn't have a cache yet so copy it 3990 the_class->set_cached_class_file(scratch_class->get_cached_class_file()); 3991 } 3992 else if (scratch_class->get_cached_class_file_bytes() != 3993 the_class->get_cached_class_file_bytes()) { 3994 // The same class can be present twice in the scratch classes list or there 3995 // are multiple concurrent RetransformClasses calls on different threads. 3996 // In such cases we have to deallocate scratch_class cached_class_file. 3997 os::free(scratch_class->get_cached_class_file()); 3998 } 3999 4000 // NULL out in scratch class to not delete twice. The class to be redefined 4001 // always owns these bytes. 4002 scratch_class->set_cached_class_file(NULL); 4003 4004 // Replace inner_classes 4005 Array<u2>* old_inner_classes = the_class->inner_classes(); 4006 the_class->set_inner_classes(scratch_class->inner_classes()); 4007 scratch_class->set_inner_classes(old_inner_classes); 4008 4009 // Initialize the vtable and interface table after 4010 // methods have been rewritten 4011 { 4012 ResourceMark rm(THREAD); 4013 // no exception should happen here since we explicitly 4014 // do not check loader constraints. 4015 // compare_and_normalize_class_versions has already checked: 4016 // - classloaders unchanged, signatures unchanged 4017 // - all instanceKlasses for redefined classes reused & contents updated |