comparison src/share/vm/classfile/defaultMethods.cpp @ 17465:62e87648a4be

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
author coleenp
date Thu, 19 Dec 2013 20:28:45 +0000
parents 5832cdaf89c6
children 78468e5dc6fc
comparison
equal deleted inserted replaced
17464:5832cdaf89c6 17465:62e87648a4be
1042 int new_size = klass->methods()->length() + new_methods->length(); 1042 int new_size = klass->methods()->length() + new_methods->length();
1043 1043
1044 Array<Method*>* merged_methods = MetadataFactory::new_array<Method*>( 1044 Array<Method*>* merged_methods = MetadataFactory::new_array<Method*>(
1045 klass->class_loader_data(), new_size, NULL, CHECK); 1045 klass->class_loader_data(), new_size, NULL, CHECK);
1046 1046
1047 if (original_ordering != NULL && original_ordering->length() > 0) { 1047 // original_ordering might be empty if this class has no methods of its own
1048 if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) {
1048 merged_ordering = MetadataFactory::new_array<int>( 1049 merged_ordering = MetadataFactory::new_array<int>(
1049 klass->class_loader_data(), new_size, CHECK); 1050 klass->class_loader_data(), new_size, CHECK);
1050 } 1051 }
1051 int method_order_index = klass->methods()->length(); 1052 int method_order_index = klass->methods()->length();
1052 1053
1069 if (orig_method != NULL && 1070 if (orig_method != NULL &&
1070 (new_method == NULL || orig_method->name() < new_method->name())) { 1071 (new_method == NULL || orig_method->name() < new_method->name())) {
1071 merged_methods->at_put(i, orig_method); 1072 merged_methods->at_put(i, orig_method);
1072 original_methods->at_put(orig_idx, NULL); 1073 original_methods->at_put(orig_idx, NULL);
1073 if (merged_ordering->length() > 0) { 1074 if (merged_ordering->length() > 0) {
1075 assert(original_ordering != NULL && original_ordering->length() > 0,
1076 "should have original order information for this method");
1074 merged_ordering->at_put(i, original_ordering->at(orig_idx)); 1077 merged_ordering->at_put(i, original_ordering->at(orig_idx));
1075 } 1078 }
1076 ++orig_idx; 1079 ++orig_idx;
1077 } else { 1080 } else {
1078 merged_methods->at_put(i, new_method); 1081 merged_methods->at_put(i, new_method);
1097 #endif 1100 #endif
1098 1101
1099 // Replace klass methods with new merged lists 1102 // Replace klass methods with new merged lists
1100 klass->set_methods(merged_methods); 1103 klass->set_methods(merged_methods);
1101 klass->set_initial_method_idnum(new_size); 1104 klass->set_initial_method_idnum(new_size);
1102 1105 klass->set_method_ordering(merged_ordering);
1106
1107 // Free metadata
1103 ClassLoaderData* cld = klass->class_loader_data(); 1108 ClassLoaderData* cld = klass->class_loader_data();
1104 if (original_methods ->length() > 0) { 1109 if (original_methods->length() > 0) {
1105 MetadataFactory::free_array(cld, original_methods); 1110 MetadataFactory::free_array(cld, original_methods);
1106 } 1111 }
1107 if (original_ordering->length() > 0) { 1112 if (original_ordering != NULL && original_ordering->length() > 0) {
1108 klass->set_method_ordering(merged_ordering);
1109 MetadataFactory::free_array(cld, original_ordering); 1113 MetadataFactory::free_array(cld, original_ordering);
1110 } 1114 }
1111 } 1115 }