aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvromero <none@none>2014-07-04 16:34:44 +0100
committervromero <none@none>2014-07-04 16:34:44 +0100
commit8a07e32c76d6408447fefa34e8bd974434ae4dda (patch)
tree82351cb836ba684a2f456b43ed41398eb8ec8cb0
parent202eb3e4f8bc099b2ab5f7c8783b45e931958bf1 (diff)
8049075: javac, wildcards and generic vararg method invocation not accepted
Reviewed-by: mcimadamore
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Resolve.java21
-rw-r--r--test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java40
2 files changed, 52 insertions, 9 deletions
diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
index 043833e5..39faf362 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -96,7 +96,7 @@ public class Resolve {
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> verboseResolutionMode;
@@ -138,7 +138,7 @@ public class Resolve {
Target target = Target.instance(context);
allowMethodHandles = target.hasMethodHandles();
allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific();
- checkVarargsAccessDuringResolution =
+ checkVarargsAccessAfterResolution =
source.allowPostApplicabilityVarargsAccessCheck();
polymorphicSignatureScope = new Scope(syms.noSymbol);
@@ -837,13 +837,16 @@ public class Resolve {
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 --git a/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java b/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java
new file mode 100644
index 00000000..c9618766
--- /dev/null
+++ b/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java
@@ -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<T> {
+ String m(T... t);
+ }
+
+ void m() {
+ I<? super Integer> i = null;
+ i.m(Integer.valueOf(1), Integer.valueOf(1));
+ }
+}