# HG changeset patch # User mcimadamore # Date 1478534898 0 # Node ID a4ee110842fb074b79b8165b3612b17807d32547 # Parent 260c724e5614bf2acdba934ead9daf6530aa7ece 8169093: Generics, javac not matching actual and formal arguments. Summary: Make diagnostic for type-args arity mismatch consistent with the class case Reviewed-by: vromero diff -r 260c724e5614 -r a4ee110842fb langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Nov 07 11:16:23 2016 +0000 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Nov 07 16:08:18 2016 +0000 @@ -554,7 +554,8 @@ } else if (mt.hasTag(FORALL) && typeargtypes.nonEmpty()) { ForAll pmt = (ForAll) mt; if (typeargtypes.length() != pmt.tvars.length()) - throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args + // not enough args + throw inapplicableMethodException.setMessage("wrong.number.type.args", Integer.toString(pmt.tvars.length())); // Check type arguments are within bounds List formals = pmt.tvars; List actuals = typeargtypes; diff -r 260c724e5614 -r a4ee110842fb langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Nov 07 11:16:23 2016 +0000 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Nov 07 16:08:18 2016 +0000 @@ -2124,6 +2124,10 @@ compiler.misc.arg.length.mismatch=\ actual and formal argument lists differ in length +# 0: string +compiler.misc.wrong.number.type.args=\ + wrong number of type arguments; required {0} + # 0: message segment compiler.misc.no.conforming.assignment.exists=\ argument mismatch; {0} diff -r 260c724e5614 -r a4ee110842fb langtools/test/tools/javac/diags/examples/WrongNumberTypeArgsFragment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/diags/examples/WrongNumberTypeArgsFragment.java Mon Nov 07 16:08:18 2016 +0000 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.cant.apply.symbol +// key: compiler.misc.wrong.number.type.args + +import java.util.*; + +class WrongNumberTypeArgsFragment { + void test() { + Arrays.asList(""); + } +}