8259922: MethodHandles.collectArguments does not throw IAE if pos is outside the arity range

Reviewed-by: mchung
This commit is contained in:
Johannes Kuhn 2021-01-22 17:18:06 +00:00 committed by Mandy Chung
parent 0ea5862670
commit bf5e801501
2 changed files with 86 additions and 0 deletions

View file

@ -5748,6 +5748,10 @@ assertEquals("[top, [[up, down, strange], charm], bottom]",
MethodType filterType = filter.type();
Class<?> rtype = filterType.returnType();
List<Class<?>> filterArgs = filterType.parameterList();
if (pos < 0 || (rtype == void.class && pos > targetType.parameterCount()) ||
(rtype != void.class && pos >= targetType.parameterCount())) {
throw newIllegalArgumentException("position is out of range for target", target, pos);
}
if (rtype == void.class) {
return targetType.insertParameterTypes(pos, filterArgs);
}