jdk/src/share/classes/java/lang/invoke/MethodHandles.java
changeset 9730 e4b334d47f4b
parent 9646 5ebbe5ab084f
child 9731 d0f7a3e441c4
--- a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java	Thu May 12 19:27:49 2011 -0700
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java	Tue May 17 19:48:14 2011 -0700
@@ -1377,6 +1377,9 @@
      */
     public static
     MethodHandle convertArguments(MethodHandle target, MethodType newType) {
+        if (!target.type().isConvertibleTo(newType)) {
+            throw new WrongMethodTypeException("cannot convert "+target+" to "+newType);
+        }
         return MethodHandleImpl.convertArguments(target, newType, 1);
     }
 
@@ -1567,7 +1570,7 @@
         int numSpread = (outargs - spreadPos);
         MethodHandle res = null;
         if (spreadPos >= 0 && numSpread >= 0) {
-            res = MethodHandleImpl.spreadArguments(target, newType, spreadPos);
+            res = MethodHandleImpl.spreadArgumentsFromPos(target, newType, spreadPos);
         }
         if (res == null) {
             throw newIllegalArgumentException("cannot spread "+newType+" to " +oldType);
@@ -2135,7 +2138,7 @@
             int hpc = hargs.size(), tpc = targs.size();
             if (hpc >= tpc || !targs.subList(0, hpc).equals(hargs))
                 throw misMatchedTypes("target and handler types", ttype, htype);
-            handler = dropArguments(handler, hpc, hargs.subList(hpc, tpc));
+            handler = dropArguments(handler, 1+hpc, targs.subList(hpc, tpc));
             htype = handler.type();
         }
         return MethodHandleImpl.makeGuardWithCatch(target, exType, handler);