8158171: MethodHandles.dropArgumentsToMatch(...) non-documented IAE
authorsrastogi
Mon, 06 Jun 2016 09:13:35 +0200
changeset 38785 dacdc5add5eb
parent 38784 c0a88deb692a
child 38786 8e7b0ac05815
child 38797 a203173038f4
8158171: MethodHandles.dropArgumentsToMatch(...) non-documented IAE Reviewed-by: sundar, mhaupt
jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
jdk/test/java/lang/invoke/DropArgumentsTest.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Fri Jun 03 17:01:23 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Mon Jun 06 09:13:35 2016 +0200
@@ -3360,9 +3360,9 @@
      * @param pos place in {@code newTypes} where the non-skipped target parameters must occur
      * @return a possibly adapted method handle
      * @throws NullPointerException if either argument is null
-     * @throws IllegalArgumentException
-     *         if either index is out of range in its corresponding list, or
-     *         if the non-skipped target parameter types match the new types at {@code pos}
+     * @throws IllegalArgumentException if any element of {@code newTypes} is {@code void.class},
+     *         or if either index is out of range in its corresponding list,
+     *         or if the non-skipped target parameter types match the new types at {@code pos}
      * @since 9
      */
     public static
--- a/jdk/test/java/lang/invoke/DropArgumentsTest.java	Fri Jun 03 17:01:23 2016 -0700
+++ b/jdk/test/java/lang/invoke/DropArgumentsTest.java	Mon Jun 06 09:13:35 2016 +0200
@@ -25,7 +25,7 @@
 
 /* @test
  * @summary unit tests for java.lang.invoke.MethodHandles
- * @run testng/othervm -ea -esa test.java.lang.invoke.DropArgumentsTest
+ * @run testng test.java.lang.invoke.DropArgumentsTest
  */
 package test.java.lang.invoke;
 
@@ -87,4 +87,13 @@
     public void dropArgumentsToMatchIAE(MethodHandle target, int pos, List<Class<?>> valueType, int skip) {
         MethodHandles.dropArgumentsToMatch(target, pos, valueType , skip);
     }
+
+    @Test
+    @ExpectedExceptions(IllegalArgumentException.class)
+    public void dropArgumentsToMatchTestWithVoid() throws Throwable {
+        MethodHandle cat = lookup().findVirtual(String.class, "concat",
+                                   MethodType.methodType(String.class, String.class));
+        MethodType bigTypewithVoid = cat.type().insertParameterTypes(0, void.class, String.class, int.class);
+        MethodHandle handle2 = MethodHandles.dropArgumentsToMatch(cat, 0, bigTypewithVoid.parameterList(), 1);
+    }
 }