hotspot/src/share/vm/interpreter/linkResolver.cpp
changeset 42074 c069e5e285cb
parent 41669 2091069b6851
child 44738 11431bbc9549
child 46262 83280d968b96
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp	Thu Oct 27 09:42:45 2016 -0500
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp	Fri Oct 14 14:47:01 2016 -0700
@@ -1627,19 +1627,23 @@
 
 static void wrap_invokedynamic_exception(TRAPS) {
   if (HAS_PENDING_EXCEPTION) {
+    // See the "Linking Exceptions" section for the invokedynamic instruction
+    // in JVMS 6.5.
+    if (PENDING_EXCEPTION->is_a(SystemDictionary::Error_klass())) {
+      // Pass through an Error, including BootstrapMethodError, any other form
+      // of linkage error, or say ThreadDeath/OutOfMemoryError
+      if (TraceMethodHandles) {
+        tty->print_cr("invokedynamic passes through an Error for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION));
+        PENDING_EXCEPTION->print();
+      }
+      return;
+    }
+
+    // Otherwise wrap the exception in a BootstrapMethodError
     if (TraceMethodHandles) {
       tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION));
       PENDING_EXCEPTION->print();
     }
-    if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) {
-      // throw these guys, since they are already wrapped
-      return;
-    }
-    if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) {
-      // intercept only LinkageErrors which might have failed to wrap
-      return;
-    }
-    // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS.
     Handle nested_exception(THREAD, PENDING_EXCEPTION);
     CLEAR_PENDING_EXCEPTION;
     THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception)