--- a/hotspot/src/share/vm/opto/runtime.cpp Tue Oct 04 10:07:07 2011 -0700
+++ b/hotspot/src/share/vm/opto/runtime.cpp Tue Oct 04 14:30:04 2011 -0700
@@ -997,10 +997,13 @@
force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
if (handler_address == NULL) {
+ Handle original_exception(thread, exception());
handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true);
assert (handler_address != NULL, "must have compiled handler");
- // Update the exception cache only when the unwind was not forced.
- if (!force_unwind) {
+ // Update the exception cache only when the unwind was not forced
+ // and there didn't happen another exception during the computation of the
+ // compiled exception handler.
+ if (!force_unwind && original_exception() == exception()) {
nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
}
} else {