8147070: Dynalink GuardedInvocation must check the Class object passed
Reviewed-by: hannesw, mhaupt, attila
--- 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;
}