6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool")
authorcoleenp
Thu, 03 Mar 2011 19:52:23 -0500
changeset 8651 81b517a9249f
parent 8650 45f6a91a52de
child 8652 209b2ce94ce5
6512830: Error: assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool") Summary: Redefine classes copies the constant pool while the constant pool may be resolving strings or classes Reviewed-by: dcubed, dsamersoff, acorn
hotspot/src/share/vm/oops/constantPoolOop.cpp
hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
--- a/hotspot/src/share/vm/oops/constantPoolOop.cpp	Thu Mar 03 19:51:36 2011 -0500
+++ b/hotspot/src/share/vm/oops/constantPoolOop.cpp	Thu Mar 03 19:52:23 2011 -0500
@@ -1175,8 +1175,15 @@
 
   case JVM_CONSTANT_UnresolvedClass:
   {
-    Symbol* k = from_cp->unresolved_klass_at(from_i);
-    to_cp->unresolved_klass_at_put(to_i, k);
+    // Can be resolved after checking tag, so check the slot first.
+    CPSlot entry = from_cp->slot_at(from_i);
+    if (entry.is_oop()) {
+      assert(entry.get_oop()->is_klass(), "must be");
+      // Already resolved
+      to_cp->klass_at_put(to_i, (klassOop)entry.get_oop());
+    } else {
+      to_cp->unresolved_klass_at_put(to_i, entry.get_symbol());
+    }
   } break;
 
   case JVM_CONSTANT_UnresolvedClassInError:
@@ -1189,8 +1196,14 @@
 
   case JVM_CONSTANT_UnresolvedString:
   {
-    Symbol* s = from_cp->unresolved_string_at(from_i);
-    to_cp->unresolved_string_at_put(to_i, s);
+    // Can be resolved after checking tag, so check the slot first.
+    CPSlot entry = from_cp->slot_at(from_i);
+    if (entry.is_oop()) {
+      // Already resolved (either string or pseudo-string)
+      to_cp->string_at_put(to_i, entry.get_oop());
+    } else {
+      to_cp->unresolved_string_at_put(to_i, entry.get_symbol());
+    }
   } break;
 
   case JVM_CONSTANT_Utf8:
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Thu Mar 03 19:51:36 2011 -0500
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp	Thu Mar 03 19:52:23 2011 -0500
@@ -1084,7 +1084,10 @@
       jbyte old_tag = old_cp->tag_at(old_i).value();
       switch (old_tag) {
       case JVM_CONSTANT_Class:
+      case JVM_CONSTANT_UnresolvedClass:
         // revert the copy to JVM_CONSTANT_UnresolvedClass
+        // May be resolving while calling this so do the same for
+        // JVM_CONSTANT_UnresolvedClass (klass_name_at() deals with transition)
         (*merge_cp_p)->unresolved_klass_at_put(old_i,
           old_cp->klass_name_at(old_i));
         break;