8029844: Enhance argument validation
authorjrose
Fri, 13 Dec 2013 18:06:31 -0800
changeset 23898 941817398760
parent 23897 911b1eb93667
child 23899 a926ecef7eb3
8029844: Enhance argument validation Summary: make defensive copy of a varargs array Reviewed-by: mchung, twisti, ahgross
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<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);
     }