-
Bug
-
Resolution: Fixed
-
P5
-
9
-
b01
"Arity limits" section of MethodHandle Javadoc (http://download.java.net/java/jdk9/docs/api/java/lang/invoke/MethodHandle.html#maxarity) discusses the general constraint on the arity of method handles.
Many adapter methods of MethodHandle and MethodHandles explicitly specify IllegalArgumentException if the constraint is violated, but some don't.
Lookup.find*(...) factories don't specify the possibility of exceeding the arity limit when a method with 255 parameters is looked up.
Several methods in MethodHandles class also don't specify that IAE:
dropArgumentsToMatch
empty
explicitCastArguments
permuteArguments
varHandleInvoker
varHandleExactInvoker
Examples of the calls that lead to IAE:
===============================================
Class<?>[] classes254 = IntStream.range(0, 254)
.mapToObj(i -> int.class)
.toArray(Class[]::new);
MethodType mt254 = methodType(void.class, classes254);
MethodType mt255 = mt254.appendParameterTypes(int.class);
// all calls below throw IllegalArgumentException
dropArgumentsToMatch(
empty(mt254),
0,
mt255.parameterList(),
0
);
empty(mt255);
explicitCastArguments(
empty(mt254),
mt254.dropParameterTypes(0, 1).insertParameterTypes(0, long.class)
);
permuteArguments(
empty(methodType(void.class)),
mt255
);
varHandleInvoker(VarHandle.AccessMode.GET, mt254);
varHandleExactInvoker(VarHandle.AccessMode.GET, mt254);
===============================================
Many adapter methods of MethodHandle and MethodHandles explicitly specify IllegalArgumentException if the constraint is violated, but some don't.
Lookup.find*(...) factories don't specify the possibility of exceeding the arity limit when a method with 255 parameters is looked up.
Several methods in MethodHandles class also don't specify that IAE:
dropArgumentsToMatch
empty
explicitCastArguments
permuteArguments
varHandleInvoker
varHandleExactInvoker
Examples of the calls that lead to IAE:
===============================================
Class<?>[] classes254 = IntStream.range(0, 254)
.mapToObj(i -> int.class)
.toArray(Class[]::new);
MethodType mt254 = methodType(void.class, classes254);
MethodType mt255 = mt254.appendParameterTypes(int.class);
// all calls below throw IllegalArgumentException
dropArgumentsToMatch(
empty(mt254),
0,
mt255.parameterList(),
0
);
empty(mt255);
explicitCastArguments(
empty(mt254),
mt254.dropParameterTypes(0, 1).insertParameterTypes(0, long.class)
);
permuteArguments(
empty(methodType(void.class)),
mt255
);
varHandleInvoker(VarHandle.AccessMode.GET, mt254);
varHandleExactInvoker(VarHandle.AccessMode.GET, mt254);
===============================================
- csr for
-
JDK-8205917 IllegalArgumentException when MH would have too many parameters is not specified for several methods
- Closed