MethodHandles.dropArgumentsToMatch(...) contains some assertions with possible mistakes. 1. The target's return type will be unchanged. I suppose it means 'resulting method handle have the same return type as target'. Current versions means that target return type will have no modification. But resulting method handle and target are not the same method handles. 2. Two phrases: Adapts a target method handle to match the given parameter type list newTypes - the desired argument list of the method handle contradicts explanations from first paragraph. According to these two phrases dropArgumentsToMatch(MH(int)void, 1, [String.class], 0) should return method handle of type MH(String)void According to explanations and implementstion resulting MH is MH(int, String)void (jdk9b125) 3. IAE: "if the non-skipped target parameter types match the new types at pos" According to implementation, IAE is thrown in the case non-skipped parameter types DOES NOT match the new types at pos (jdk9b125). More precisely it is thrown in the case newTypes doesn't starts with target's non-skipped parameter types.
|