changeset 34977:7c1f2143d0f6

8147070: Dynalink GuardedInvocation must check the Class object passed Reviewed-by: hannesw, mhaupt, attila
author sundar
date Thu, 14 Jan 2016 15:35:43 +0530
parents 62f7766a44dc
children e753c4c9f96f
files nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;
     }