Skip to content

Commit d07af2b

Browse files
committedJan 28, 2021
8255531: MethodHandles::permuteArguments throws NPE when duplicating dropped arguments
Reviewed-by: redestad
1 parent a68c6c2 commit d07af2b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ LambdaForm endEdit() {
301301
int argp = firstChange, exprp = 0;
302302
for (int i = firstChange; i < arity; i++) {
303303
Name name = names[i];
304-
if (name.isParam()) {
304+
if (name != null && name.isParam()) {
305305
names[argp++] = name;
306306
} else {
307307
exprs[exprp++] = name;

‎test/jdk/java/lang/invoke/MethodHandlesPermuteArgumentsTest.java

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public void testPermuteArguments0() throws Throwable {
6363
testBadReorderIndex();
6464
testReturnTypeMismatch();
6565
testReorderTypeMismatch();
66+
67+
testPermuteWithEmpty();
6668
}
6769

6870
public void testPermuteArguments(int max, Class<?> type1, int t2c, Class<?> type2, int dilution) throws Throwable {
@@ -227,6 +229,12 @@ public void testReorderTypeMismatch() throws Throwable {
227229
IllegalArgumentException.class, ".*parameter types do not match after reorder.*");
228230
}
229231

232+
// for JDK-8255531
233+
private void testPermuteWithEmpty() {
234+
MethodHandle mh = MethodHandles.empty(MethodType.methodType(void.class, int.class, int.class));
235+
MethodHandles.permuteArguments(mh, MethodType.methodType(void.class, int.class), 0, 0);
236+
}
237+
230238
private interface RunnableX {
231239
void run() throws Throwable;
232240
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Jan 28, 2021

@openjdk-notifier[bot]
Please sign in to comment.