8023547: com/sun/jdi/RedefineMulti.sh fails with IllegalArgumentException after JDK-8021948 .
authorjiangli
Thu, 22 Aug 2013 19:27:42 -0400
changeset 19537 7db00fe9bb8e
parent 19534 b0611f290c80
child 19538 d3d20902831f
8023547: com/sun/jdi/RedefineMulti.sh fails with IllegalArgumentException after JDK-8021948 . Summary: Need to check if the constant pool mapping returns 0. Reviewed-by: coleenp, sspitsyn
hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Thu Aug 22 14:56:10 2013 -0400
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Thu Aug 22 19:27:42 2013 -0400
@@ -1554,18 +1554,22 @@
     return false;
   }
 
-  // rewrite sourc file name index:
+  // rewrite source file name index:
   u2 source_file_name_idx = scratch_class->source_file_name_index();
   if (source_file_name_idx != 0) {
     u2 new_source_file_name_idx = find_new_index(source_file_name_idx);
-    scratch_class->set_source_file_name_index(new_source_file_name_idx);
+    if (new_source_file_name_idx != 0) {
+      scratch_class->set_source_file_name_index(new_source_file_name_idx);
+    }
   }
 
   // rewrite class generic signature index:
   u2 generic_signature_index = scratch_class->generic_signature_index();
   if (generic_signature_index != 0) {
     u2 new_generic_signature_index = find_new_index(generic_signature_index);
-    scratch_class->set_generic_signature_index(new_generic_signature_index);
+    if (new_generic_signature_index != 0) {
+      scratch_class->set_generic_signature_index(new_generic_signature_index);
+    }
   }
 
   return true;
@@ -1737,7 +1741,10 @@
 
     for (int i = 0; i < len; i++) {
       const u2 cp_index = elem[i].name_cp_index;
-      elem[i].name_cp_index = find_new_index(cp_index);
+      const u2 new_cp_index = find_new_index(cp_index);
+      if (new_cp_index != 0) {
+        elem[i].name_cp_index = new_cp_index;
+      }
     }
   }
 } // end rewrite_cp_refs_in_method()