src/share/vm/prims/jvmtiRedefineClasses.cpp

Print this page

        

*** 1394,1404 **** // in order to find the start of the first complete object on the card. ClassLoaderData* loader_data = the_class->class_loader_data(); ConstantPool* merge_cp_oop = ConstantPool::allocate(loader_data, merge_cp_length, ! THREAD); MergeCPCleaner cp_cleaner(loader_data, merge_cp_oop); HandleMark hm(THREAD); // make sure handles are cleared before // MergeCPCleaner clears out merge_cp_oop constantPoolHandle merge_cp(THREAD, merge_cp_oop); --- 1394,1404 ---- // in order to find the start of the first complete object on the card. ClassLoaderData* loader_data = the_class->class_loader_data(); ConstantPool* merge_cp_oop = ConstantPool::allocate(loader_data, merge_cp_length, ! CHECK_(JVMTI_ERROR_OUT_OF_MEMORY)); MergeCPCleaner cp_cleaner(loader_data, merge_cp_oop); HandleMark hm(THREAD); // make sure handles are cleared before // MergeCPCleaner clears out merge_cp_oop constantPoolHandle merge_cp(THREAD, merge_cp_oop);
*** 1470,1480 **** // and merged constant pools are supersets of the new constant // pool. // Replace the new constant pool with a shrunken copy of the // merged constant pool ! set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, THREAD); // The new constant pool replaces scratch_cp so have cleaner clean it up. // It can't be cleaned up while there are handles to it. cp_cleaner.add_scratch_cp(scratch_cp()); } } else { --- 1470,1481 ---- // and merged constant pools are supersets of the new constant // pool. // Replace the new constant pool with a shrunken copy of the // merged constant pool ! set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, ! CHECK_(JVMTI_ERROR_OUT_OF_MEMORY)); // The new constant pool replaces scratch_cp so have cleaner clean it up. // It can't be cleaned up while there are handles to it. cp_cleaner.add_scratch_cp(scratch_cp()); } } else {
*** 1500,1510 **** // Replace the new constant pool with a shrunken copy of the // merged constant pool so now the rewritten bytecodes have // valid references; the previous new constant pool will get // GCed. ! set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, THREAD); // The new constant pool replaces scratch_cp so have cleaner clean it up. // It can't be cleaned up while there are handles to it. cp_cleaner.add_scratch_cp(scratch_cp()); } --- 1501,1512 ---- // Replace the new constant pool with a shrunken copy of the // merged constant pool so now the rewritten bytecodes have // valid references; the previous new constant pool will get // GCed. ! set_new_constant_pool(loader_data, scratch_class, merge_cp, merge_cp_length, ! CHECK_(JVMTI_ERROR_OUT_OF_MEMORY)); // The new constant pool replaces scratch_cp so have cleaner clean it up. // It can't be cleaned up while there are handles to it. cp_cleaner.add_scratch_cp(scratch_cp()); }
*** 2485,2496 **** assert(scratch_cp->length() >= scratch_cp_length, "sanity check"); // scratch_cp is a merged constant pool and has enough space for a // worst case merge situation. We want to associate the minimum // sized constant pool with the klass to save space. ! constantPoolHandle smaller_cp(THREAD, ! ConstantPool::allocate(loader_data, scratch_cp_length, THREAD)); // preserve version() value in the smaller copy int version = scratch_cp->version(); assert(version != 0, "sanity check"); smaller_cp->set_version(version); --- 2487,2498 ---- assert(scratch_cp->length() >= scratch_cp_length, "sanity check"); // scratch_cp is a merged constant pool and has enough space for a // worst case merge situation. We want to associate the minimum // sized constant pool with the klass to save space. ! ConstantPool* cp = ConstantPool::allocate(loader_data, scratch_cp_length, CHECK); ! constantPoolHandle smaller_cp(THREAD, cp); // preserve version() value in the smaller copy int version = scratch_cp->version(); assert(version != 0, "sanity check"); smaller_cp->set_version(version);
*** 2498,2507 **** --- 2500,2514 ---- // attach klass to new constant pool // reference to the cp holder is needed for copy_operands() smaller_cp->set_pool_holder(scratch_class()); scratch_cp->copy_cp_to(1, scratch_cp_length - 1, smaller_cp, 1, THREAD); + if (HAS_PENDING_EXCEPTION) { + // Exception is handled in the caller + loader_data->add_to_deallocate_list(smaller_cp()); + return; + } scratch_cp = smaller_cp; // attach new constant pool to klass scratch_class->set_constants(scratch_cp());