diff -r 2ca5866a8dfb -r b1c98bfd4709 src/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Dec 10 15:23:42 2010 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Dec 10 15:24:17 2010 +0000 @@ -470,7 +470,9 @@ throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args if (useVarargs) { - Type elt = types.elemtype(varargsFormal); + //note: if applicability check is triggered by most specific test, + //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5) + Type elt = types.elemtypeOrType(varargsFormal); while (argtypes.nonEmpty()) { if (!types.isConvertible(argtypes.head, elt, warn)) throw inapplicableMethodException.setMessage("varargs.argument.mismatch", @@ -827,24 +829,30 @@ List fromArgs = from.type.getParameterTypes(); List toArgs = to.type.getParameterTypes(); if (useVarargs && - toArgs.length() < fromArgs.length() && (from.flags() & VARARGS) != 0 && (to.flags() & VARARGS) != 0) { - //if we are checking a varargs method 'from' against another varargs - //method 'to' (where arity of 'to' < arity of 'from') then expand signature - //of 'to' to 'fit' arity of 'from' (this means adding fake formals to 'to' - //until 'to' signature has the same arity as 'from') - ListBuffer args = ListBuffer.lb(); Type varargsTypeFrom = fromArgs.last(); Type varargsTypeTo = toArgs.last(); - while (fromArgs.head != varargsTypeFrom) { - args.append(toArgs.head == varargsTypeTo ? types.elemtype(varargsTypeTo) : toArgs.head); - fromArgs = fromArgs.tail; - toArgs = toArgs.head == varargsTypeTo ? - toArgs : - toArgs.tail; + ListBuffer args = ListBuffer.lb(); + if (toArgs.length() < fromArgs.length()) { + //if we are checking a varargs method 'from' against another varargs + //method 'to' (where arity of 'to' < arity of 'from') then expand signature + //of 'to' to 'fit' arity of 'from' (this means adding fake formals to 'to' + //until 'to' signature has the same arity as 'from') + while (fromArgs.head != varargsTypeFrom) { + args.append(toArgs.head == varargsTypeTo ? types.elemtype(varargsTypeTo) : toArgs.head); + fromArgs = fromArgs.tail; + toArgs = toArgs.head == varargsTypeTo ? + toArgs : + toArgs.tail; + } + } else { + //formal argument list is same as original list where last + //argument (array type) is removed + args.appendList(toArgs.reverse().tail.reverse()); } - args.append(varargsTypeTo); + //append varargs element type as last synthetic formal + args.append(types.elemtype(varargsTypeTo)); MethodSymbol msym = new MethodSymbol(to.flags_field, to.name, (Type)to.type.clone(), //see: 6990136