# HG changeset patch # User jrose # Date 1386986791 28800 # Node ID 94181739876029b78cd6ad5c19f075f75bd18669 # Parent 911b1eb93667f47a93b6e35fbcc191c6fcb8c097 8029844: Enhance argument validation Summary: make defensive copy of a varargs array Reviewed-by: mchung, twisti, ahgross diff -r 911b1eb93667 -r 941817398760 jdk/src/share/classes/java/lang/invoke/MethodHandles.java --- a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java Fri Jan 10 13:42:44 2014 -0800 +++ b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java Fri Dec 13 18:06:31 2013 -0800 @@ -2070,6 +2070,7 @@ */ public static MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) { + reorder = reorder.clone(); checkReorder(reorder, newType, target.type()); return target.permuteArguments(newType, reorder); } @@ -2264,6 +2265,7 @@ throw newIllegalArgumentException("no argument type to remove"); ArrayList> ptypes = new ArrayList<>(oldType.parameterList()); ptypes.addAll(pos, valueTypes); + if (ptypes.size() != inargs) throw newIllegalArgumentException("valueTypes"); MethodType newType = MethodType.methodType(oldType.returnType(), ptypes); return target.dropArguments(newType, pos, dropped); }