8158171: MethodHandles.dropArgumentsToMatch(...) non-documented IAE
Reviewed-by: sundar, mhaupt
--- 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);
+ }
}