JDK-8152008 : asSpreader() & asCollector() WMTE assertions probably not needed
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • Submitted: 2016-03-16
  • Updated: 2016-03-22
  • Resolved: 2016-03-22
Description
MethodHandle.asSpreader() and MethodHandle.asCollector() have the assertion:
"WrongMethodTypeException - if the implied asType call fails"

MethodHandle.asType() assertion:
"WrongMethodTypeException - if the conversion cannot be made"

Which is probably covered by IllegalArgumentException of asSpreader() and asCollector(). If there are any cases which lead to WrongMethodTypeException thrown by asSpreader() or asCollector(), I will be grateful for them.
Comments
Given that tests exist that successfully provoke and catch WMTE, I'm closing this as "not an issue". [~kfertikov], please reopen if this assessment is wrong.
22-03-2016

There is at least one test (in SpreadCollectTest.java) that expects a WMTE from an asSpreader invocation: @Test(expectedExceptions = {WrongMethodTypeException.class}) public static void testAsSpreaderIllegalMethodType() { MethodHandle h = MethodHandles.dropArguments(MethodHandles.constant(String.class, ""), 0, int.class, int.class); MethodHandle s = h.asSpreader(String[].class, 1); }
22-03-2016