8147070: Dynalink GuardedInvocation must check the Class object passed
authorsundar
Thu, 14 Jan 2016 15:35:43 +0530
changeset 34977 7c1f2143d0f6
parent 34976 62f7766a44dc
child 34978 e753c4c9f96f
8147070: Dynalink GuardedInvocation must check the Class object passed Reviewed-by: hannesw, mhaupt, attila
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java	Thu Jan 14 10:55:26 2016 +0100
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java	Thu Jan 14 15:35:43 2016 +0530
@@ -202,6 +202,9 @@
         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;
     }
 
@@ -228,6 +231,9 @@
         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;
     }