changeset 7005:ea6ec524d828

8029844: Enhance argument validation Summary: make defensive copy of a varargs array Reviewed-by: mchung, twisti, ahgross
author jrose
date Fri, 13 Dec 2013 18:03:41 -0800
parents c7c231608e20
children 54c9fea273a1
files src/share/classes/java/lang/invoke/MethodHandles.java
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/invoke/MethodHandles.java	Wed Nov 13 17:51:30 2013 +0000
+++ b/src/share/classes/java/lang/invoke/MethodHandles.java	Fri Dec 13 18:03:41 2013 -0800
@@ -1616,6 +1616,7 @@
      */
     public static
     MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
+        reorder = reorder.clone();
         checkReorder(reorder, newType, target.type());
         return target.permuteArguments(newType, reorder);
     }
@@ -1810,6 +1811,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);
     }