8195694: ConstantBootstraps.invoke does not preserve variable arity

Reviewed-by: jrose
This commit is contained in:
Paul Sandoz 2018-02-01 14:19:04 -08:00
parent 5dc2184391
commit 00b3f917ac
2 changed files with 24 additions and 4 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -232,7 +232,10 @@ public final class ConstantBootstraps {
requireNonNull(args);
if (type != handle.type().returnType()) {
handle = handle.asType(handle.type().changeReturnType(type));
// Adjust the return type of the handle to be invoked while
// preserving variable arity if present
handle = handle.asType(handle.type().changeReturnType(type)).
withVarargs(handle.isVarargsCollector());
}
return handle.invokeWithArguments(args);