8029844: Enhance argument validation
Summary: make defensive copy of a varargs array
Reviewed-by: mchung, twisti, ahgross
--- 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<Class<?>> 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);
}