8180627: gc/gctests/Steal/steal001: guarantee(cp->cache() == NULL) failed
Summary: Clean up constant pool cache if class linking fails
Reviewed-by: coleenp, gtriantafill
--- 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
+ }
}