jdk/test/java/lang/invoke/JavaDocExamplesTest.java
changeset 20530 b54a1f5cd35f
parent 19388 188246066dbb
child 20531 14c2a04f21e6
--- a/jdk/test/java/lang/invoke/JavaDocExamplesTest.java	Sat Oct 05 05:30:39 2013 -0700
+++ b/jdk/test/java/lang/invoke/JavaDocExamplesTest.java	Sat Oct 05 05:30:39 2013 -0700
@@ -264,6 +264,12 @@
 MethodHandle eq2 = equals.asSpreader(Object[].class, 2);
 assert( (boolean) eq2.invokeExact(new Object[]{ "me", "me" }));
 assert(!(boolean) eq2.invokeExact(new Object[]{ "me", "thee" }));
+// try to spread from anything but a 2-array:
+for (int n = 0; n <= 10; n++) {
+  Object[] badArityArgs = (n == 2 ? null : new Object[n]);
+  try { assert((boolean) eq2.invokeExact(badArityArgs) && false); }
+  catch (IllegalArgumentException ex) { } // OK
+}
 // spread both arguments from a String array:
 MethodHandle eq2s = equals.asSpreader(String[].class, 2);
 assert( (boolean) eq2s.invokeExact(new String[]{ "me", "me" }));