From a838b8ba1c53881a7cffc82557d4cf0c51c71069 Mon Sep 17 00:00:00 2001 From: coleenp Date: Thu, 19 Dec 2013 20:28:45 +0000 Subject: [PATCH] 8030633: nsk/jvmti/RedefineClasses/StressRedefine failed invalid method ordering length on Solaris Summary: A method with no declared methods was getting an AME overpass method with the latest change. The method_ordering array was not updated for the new methods. Reviewed-by: dcubed, acorn, dsamersoff, lfoltan, hseigel --- src/share/vm/classfile/defaultMethods.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/share/vm/classfile/defaultMethods.cpp b/src/share/vm/classfile/defaultMethods.cpp index 8a60a6b36..0ebeecc62 100644 --- a/src/share/vm/classfile/defaultMethods.cpp +++ b/src/share/vm/classfile/defaultMethods.cpp @@ -1044,7 +1044,8 @@ static void merge_in_new_methods(InstanceKlass* klass, Array* merged_methods = MetadataFactory::new_array( klass->class_loader_data(), new_size, NULL, CHECK); - if (original_ordering != NULL && original_ordering->length() > 0) { + // original_ordering might be empty if this class has no methods of its own + if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) { merged_ordering = MetadataFactory::new_array( klass->class_loader_data(), new_size, CHECK); } @@ -1071,6 +1072,8 @@ static void merge_in_new_methods(InstanceKlass* klass, merged_methods->at_put(i, orig_method); original_methods->at_put(orig_idx, NULL); if (merged_ordering->length() > 0) { + assert(original_ordering != NULL && original_ordering->length() > 0, + "should have original order information for this method"); merged_ordering->at_put(i, original_ordering->at(orig_idx)); } ++orig_idx; @@ -1099,13 +1102,14 @@ static void merge_in_new_methods(InstanceKlass* klass, // Replace klass methods with new merged lists klass->set_methods(merged_methods); klass->set_initial_method_idnum(new_size); + klass->set_method_ordering(merged_ordering); + // Free metadata ClassLoaderData* cld = klass->class_loader_data(); - if (original_methods ->length() > 0) { + if (original_methods->length() > 0) { MetadataFactory::free_array(cld, original_methods); } - if (original_ordering->length() > 0) { - klass->set_method_ordering(merged_ordering); + if (original_ordering != NULL && original_ordering->length() > 0) { MetadataFactory::free_array(cld, original_ordering); } } -- GitLab