On Tue, 12 Jan 2021 16:58:45 GMT, Jorn Vernee <jver...@openjdk.org> wrote:
> Hi, > > This small patch fixes the NPE in the following case: > > MethodHandle mh = MethodHandles.empty(MethodType.methodType(void.class, > int.class, int.class)); > MethodHandles.permuteArguments(mh, MethodType.methodType(void.class, > int.class), 0, 0); > > If a parameter name was changed by a lambda form edit, `LambdaForm::endEdit` > will try to sort the names that fall into the old range of parameter names > (starting from `firstChanged` and up to `arity` in the code) to make sure > that non-parameter names (`exprs`) properly appear after parameter names. > But, if a parameter was dropped, and there are no non-paramter names, a > `null` will fall into the range that is being sorted, and the call to > `name.isParam()` in the sorting algorithm will result in an NPE. > > We can just add a `name != null` check there, since `null` is definitely not > a parameter. However, we still need to do the loop in order to get an > accurate `exprp` value, which is later used to adjust the `arity` after > sorting (there are other ways to get there that don't involve copying the > extra `null`, but they are more convoluted, so I elected to go for this > solution). > > Thanks, > Jorn > > Testing: tier1-tier2 This pull request has now been integrated. Changeset: d07af2b8 Author: Jorn Vernee <jver...@openjdk.org> URL: https://git.openjdk.java.net/jdk/commit/d07af2b8 Stats: 9 lines in 2 files changed: 8 ins; 0 del; 1 mod 8255531: MethodHandles::permuteArguments throws NPE when duplicating dropped arguments Reviewed-by: redestad ------------- PR: https://git.openjdk.java.net/jdk/pull/2054