changeset 9347:317d55ff8423

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:06:31 -0800
parents 5cd7b63e7ce2
children fa2d5a06308f
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	Mon Dec 16 08:18:55 2013 -0800
+++ b/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);
     }