hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/InvocationPlugins.java
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/InvocationPlugins.java Tue May 30 15:41:23 2017 -0700
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/InvocationPlugins.java Wed May 31 18:20:20 2017 -0700
@@ -709,14 +709,42 @@
return null;
}
+ @SuppressWarnings("serial")
+ static class InvocationPlugRegistrationError extends GraalError {
+ InvocationPlugRegistrationError(Throwable cause) {
+ super(cause);
+ }
+ }
+
private void flushDeferrables() {
if (deferredRegistrations != null) {
synchronized (this) {
if (deferredRegistrations != null) {
- for (Runnable deferrable : deferredRegistrations) {
- deferrable.run();
+ try {
+ for (Runnable deferrable : deferredRegistrations) {
+ deferrable.run();
+ }
+ deferredRegistrations = null;
+ } catch (InvocationPlugRegistrationError t) {
+ throw t;
+ } catch (Throwable t) {
+ /*
+ * Something went wrong during registration but it's possible we'll end up
+ * coming back into this code. nulling out deferredRegistrations would just
+ * cause other things to break and rerunning them would cause errors about
+ * already registered plugins, so rethrow the original exception during
+ * later invocations.
+ */
+ deferredRegistrations.clear();
+ Runnable rethrow = new Runnable() {
+ @Override
+ public void run() {
+ throw new InvocationPlugRegistrationError(t);
+ }
+ };
+ deferredRegistrations.add(rethrow);
+ rethrow.run();
}
- deferredRegistrations = null;
}
}
}