--- old/src/java.base/share/classes/java/lang/invoke/MethodHandles.java 2014-09-05 20:41:55.000000000 +0400 +++ new/src/java.base/share/classes/java/lang/invoke/MethodHandles.java 2014-09-05 20:41:55.000000000 +0400 @@ -2024,8 +2024,11 @@ */ public static MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) { - if (!target.type().isCastableTo(newType)) { - throw new WrongMethodTypeException("cannot explicitly cast "+target+" to "+newType); + MethodType oldType = target.type(); + // use the asTypeCache when possible: + if (oldType == newType) return target; + if (oldType.explicitCastEquivalentToAsType(newType)) { + return target.asType(newType); } return MethodHandleImpl.makePairwiseConvert(target, newType, false); }