# HG changeset patch # User vromero # Date 1404488084 -3600 # Node ID 4b4841501dd9b9b3beee58213820306d7e45832b # Parent 71a31843f5502b503cd2e984b5ab2edb02415ea0 8049075: javac, wildcards and generic vararg method invocation not accepted Reviewed-by: mcimadamore diff -r 71a31843f550 -r 4b4841501dd9 src/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jun 27 20:32:12 2014 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jul 04 16:34:44 2014 +0100 @@ -96,7 +96,7 @@ public final boolean varargsEnabled; public final boolean allowMethodHandles; public final boolean allowFunctionalInterfaceMostSpecific; - public final boolean checkVarargsAccessDuringResolution; + public final boolean checkVarargsAccessAfterResolution; private final boolean debugResolve; private final boolean compactMethodDiags; final EnumSet verboseResolutionMode; @@ -138,7 +138,7 @@ Target target = Target.instance(context); allowMethodHandles = target.hasMethodHandles(); allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); - checkVarargsAccessDuringResolution = + checkVarargsAccessAfterResolution = source.allowPostApplicabilityVarargsAccessCheck(); polymorphicSignatureScope = new Scope(syms.noSymbol); @@ -837,13 +837,16 @@ Warner warn) { super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn); //should we expand formals? - if ((!checkVarargsAccessDuringResolution || - (checkVarargsAccessDuringResolution && - deferredAttrContext.mode == AttrMode.CHECK)) && - deferredAttrContext.phase.isVarargsRequired()) { - //check varargs element type accessibility - varargsAccessible(env, types.elemtype(formals.last()), - deferredAttrContext.inferenceContext); + if (deferredAttrContext.phase.isVarargsRequired()) { + Type typeToCheck = null; + if (!checkVarargsAccessAfterResolution) { + typeToCheck = types.elemtype(formals.last()); + } else if (deferredAttrContext.mode == AttrMode.CHECK) { + typeToCheck = types.erasure(types.elemtype(formals.last())); + } + if (typeToCheck != null) { + varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext); + } } } diff -r 71a31843f550 -r 4b4841501dd9 test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java Fri Jul 04 16:34:44 2014 +0100 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, 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. + * + * 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. + */ + +/* + * @test + * @bug 8049075 + * @summary javac, wildcards and generic vararg method invocation not accepted + * @compile VarargsAndWildcardParameterizedTypeTest.java + */ + +class VarargsAndWildcardParameterizedTypeTest { + interface I { + String m(T... t); + } + + void m() { + I i = null; + i.m(Integer.valueOf(1), Integer.valueOf(1)); + } +}