8255531: MethodHandles::permuteArguments throws NPE when duplicating dropped arguments

Reviewed-by: redestad
This commit is contained in:
Jorn Vernee 2021-01-28 12:26:32 +00:00
parent a68c6c2a13
commit d07af2b8ec
2 changed files with 9 additions and 1 deletions

View File

@ -301,7 +301,7 @@ final class LambdaFormBuffer {
int argp = firstChange, exprp = 0;
for (int i = firstChange; i < arity; i++) {
Name name = names[i];
if (name.isParam()) {
if (name != null && name.isParam()) {
names[argp++] = name;
} else {
exprs[exprp++] = name;

View File

@ -63,6 +63,8 @@ public class MethodHandlesPermuteArgumentsTest extends test.java.lang.invoke.Met
testBadReorderIndex();
testReturnTypeMismatch();
testReorderTypeMismatch();
testPermuteWithEmpty();
}
public void testPermuteArguments(int max, Class<?> type1, int t2c, Class<?> type2, int dilution) throws Throwable {
@ -227,6 +229,12 @@ public class MethodHandlesPermuteArgumentsTest extends test.java.lang.invoke.Met
IllegalArgumentException.class, ".*parameter types do not match after reorder.*");
}
// for JDK-8255531
private void testPermuteWithEmpty() {
MethodHandle mh = MethodHandles.empty(MethodType.methodType(void.class, int.class, int.class));
MethodHandles.permuteArguments(mh, MethodType.methodType(void.class, int.class), 0, 0);
}
private interface RunnableX {
void run() throws Throwable;
}