8180627: gc/gctests/Steal/steal001: guarantee(cp->cache() == NULL) failed
authorhseigel
Wed, 02 Aug 2017 08:19:09 -0400
changeset 46741 d5a7407108b4
parent 46740 0f11e65a02bf
child 46742 24ec8a039c90
8180627: gc/gctests/Steal/steal001: guarantee(cp->cache() == NULL) failed Summary: Clean up constant pool cache if class linking fails Reviewed-by: coleenp, gtriantafill
hotspot/src/share/vm/interpreter/rewriter.cpp
--- a/hotspot/src/share/vm/interpreter/rewriter.cpp	Wed Aug 02 00:15:52 2017 +0000
+++ b/hotspot/src/share/vm/interpreter/rewriter.cpp	Wed Aug 02 08:19:09 2017 -0400
@@ -27,6 +27,7 @@
 #include "interpreter/bytecodes.hpp"
 #include "interpreter/interpreter.hpp"
 #include "interpreter/rewriter.hpp"
+#include "memory/metadataFactory.hpp"
 #include "memory/metaspaceShared.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/generateOopMap.hpp"
@@ -101,7 +102,13 @@
   // the above lines.
   _pool->initialize_resolved_references(loader_data, _resolved_references_map,
                                         _resolved_reference_limit,
-                                        CHECK);
+                                        THREAD);
+
+  // Clean up constant pool cache if initialize_resolved_references() failed.
+  if (HAS_PENDING_EXCEPTION) {
+    MetadataFactory::free_metadata(loader_data, cache);
+    _pool->set_cache(NULL);  // so the verifier isn't confused
+  }
 }