< prev index next >

src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java

Print this page

        

@@ -200,10 +200,13 @@
      */
     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) {
         this.invocation = Objects.requireNonNull(invocation);
         this.guard = guard;
         this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint };
+        if (exception != null && !Throwable.class.isAssignableFrom(exception)) {
+            throw new IllegalArgumentException(exception.getName() + " is not assignable from Throwable");
+        }
         this.exception = exception;
     }
 
     /**
      * Creates a new guarded invocation, with a guard method handle, any number

@@ -226,10 +229,13 @@
      */
     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) {
         this.invocation = Objects.requireNonNull(invocation);
         this.guard = guard;
         this.switchPoints = switchPoints == null ? null : switchPoints.clone();
+        if (exception != null && !Throwable.class.isAssignableFrom(exception)) {
+            throw new IllegalArgumentException(exception.getName() + " is not assignable from Throwable");
+        }
         this.exception = exception;
     }
 
     /**
      * Returns the invocation method handle.
< prev index next >