changeset 847:df3394337b04

Merge
author alanb
date Fri, 28 Jan 2011 12:36:34 +0000
parents babf86a1ac92 17bafae67e9d
children 7a75a1803c7a
files
diffstat 29 files changed, 421 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Fri Jan 28 09:25:20 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Fri Jan 28 12:36:34 2011 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -252,6 +252,11 @@
      */
     public static final long EFFECTIVELY_FINAL = 1L<<42;
 
+    /**
+     * Flag that marks non-override equivalent methods with the same signature
+     */
+    public static final long CLASH = 1L<<43;
+
     /** Modifier masks.
      */
     public static final int
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Jan 28 09:25:20 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Jan 28 12:36:34 2011 +0000
@@ -2259,6 +2259,13 @@
 
         @Override
         public Type visitForAll(ForAll t, Void ignored) {
+            if (Type.containsAny(to, t.tvars)) {
+                //perform alpha-renaming of free-variables in 't'
+                //if 'to' types contain variables that are free in 't'
+                List<Type> freevars = newInstances(t.tvars);
+                t = new ForAll(freevars,
+                        Types.this.subst(t.qtype, t.tvars, freevars));
+            }
             List<Type> tvars1 = substBounds(t.tvars, from, to);
             Type qtype1 = subst(t.qtype);
             if (tvars1 == t.tvars && qtype1 == t.qtype) {
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Jan 28 09:25:20 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Jan 28 12:36:34 2011 +0000
@@ -60,6 +60,7 @@
 
     private final Names names;
     private final Log log;
+    private final Resolve rs;
     private final Symtab syms;
     private final Enter enter;
     private final Infer infer;
@@ -91,6 +92,7 @@
 
         names = Names.instance(context);
         log = Log.instance(context);
+        rs = Resolve.instance(context);
         syms = Symtab.instance(context);
         enter = Enter.instance(context);
         infer = Infer.instance(context);
@@ -2121,7 +2123,7 @@
 
         public boolean accepts(Symbol s) {
             return s.kind == MTH &&
-                    (s.flags() & SYNTHETIC) == 0 &&
+                    (s.flags() & (SYNTHETIC | CLASH)) == 0 &&
                     s.isInheritedIn(site.tsym, types) &&
                     !s.isConstructor();
         }
@@ -2581,28 +2583,42 @@
         if (sym.owner.name == names.any) return false;
         for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) {
             if (sym != e.sym &&
+                (e.sym.flags() & CLASH) == 0 &&
                 sym.kind == e.sym.kind &&
                 sym.name != names.error &&
                 (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) {
-                if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS))
+                if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) {
                     varargsDuplicateError(pos, sym, e.sym);
-                else if (sym.kind == MTH && !types.overrideEquivalent(sym.type, e.sym.type))
+                    return true;
+                } else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) {
                     duplicateErasureError(pos, sym, e.sym);
-                else
+                    sym.flags_field |= CLASH;
+                    return true;
+                } else {
                     duplicateError(pos, e.sym);
-                return false;
+                    return false;
+                }
             }
         }
         return true;
     }
     //where
-    /** Report duplicate declaration error.
-     */
-    void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) {
-        if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) {
-            log.error(pos, "name.clash.same.erasure", sym1, sym2);
+        boolean hasSameSignature(Type mt1, Type mt2) {
+            if (mt1.tag == FORALL && mt2.tag == FORALL) {
+                ForAll fa1 = (ForAll)mt1;
+                ForAll fa2 = (ForAll)mt2;
+                mt2 = types.subst(fa2, fa2.tvars, fa1.tvars);
+            }
+            return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType());
         }
-    }
+
+        /** Report duplicate declaration error.
+         */
+        void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) {
+            if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) {
+                log.error(pos, "name.clash.same.erasure", sym1, sym2);
+            }
+        }
 
     /** Check that single-type import is not already imported or top-level defined,
      *  but make an exception for two single-type imports which denote the same type.
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Jan 28 09:25:20 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Jan 28 12:36:34 2011 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -485,11 +485,8 @@
                 @Override
                 public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
                     List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
-                    if (!rs.argumentsAcceptable(capturedArgs, formals,
-                           allowBoxing, useVarargs, warn)) {
-                      // inferred method is not applicable
-                      throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes);
-                    }
+                    // check that actuals conform to inferred formals
+                    checkArgumentsAcceptable(env, capturedArgs, formals, allowBoxing, useVarargs, warn);
                     // check that inferred bounds conform to their bounds
                     checkWithinBounds(all_tvars,
                            types.subst(inferredTypes, tvars, inferred), warn);
@@ -500,17 +497,27 @@
             }};
             return mt2;
         }
-        else if (!rs.argumentsAcceptable(capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn)) {
-            // inferred method is not applicable
-            throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes);
-        }
         else {
+            // check that actuals conform to inferred formals
+            checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn);
             // return instantiated version of method type
             return mt;
         }
     }
     //where
 
+        private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
+                boolean allowBoxing, boolean useVarargs, Warner warn) {
+            try {
+                rs.checkRawArgumentsAcceptable(env, actuals, formals,
+                       allowBoxing, useVarargs, warn);
+            }
+            catch (Resolve.InapplicableMethodException ex) {
+                // inferred method is not applicable
+                throw invalidInstanceException.setMessage(ex.getDiagnostic());
+            }
+        }
+
         /** Try to instantiate argument type `that' to given type `to'.
          *  If this fails, try to insantiate `that' to `to' where
          *  every occurrence of a type variable in `tvars' is replaced
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jan 28 09:25:20 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Jan 28 12:36:34 2011 +0000
@@ -278,7 +278,7 @@
             return true;
         else {
             Symbol s2 = ((MethodSymbol)sym).implementation(site.tsym, types, true);
-            return (s2 == null || s2 == sym ||
+            return (s2 == null || s2 == sym || sym.owner == s2.owner ||
                     s2.isPolymorphicSignatureGeneric() ||
                     !types.isSubSignature(types.memberType(site, s2), types.memberType(site, sym)));
         }
@@ -331,7 +331,7 @@
         throws Infer.InferenceException {
         boolean polymorphicSignature = m.isPolymorphicSignatureGeneric() && allowMethodHandles;
         if (useVarargs && (m.flags() & VARARGS) == 0)
-            throw inapplicableMethodException.setMessage(null);
+            throw inapplicableMethodException.setMessage();
         Type mt = types.memberType(site, m);
 
         // tvars is the list of formal type variables for which type arguments
@@ -386,7 +386,7 @@
                                     useVarargs,
                                     warn);
 
-        checkRawArgumentsAcceptable(argtypes, mt.getParameterTypes(),
+        checkRawArgumentsAcceptable(env, argtypes, mt.getParameterTypes(),
                                 allowBoxing, useVarargs, warn);
         return mt;
     }
@@ -411,19 +411,21 @@
 
     /** Check if a parameter list accepts a list of args.
      */
-    boolean argumentsAcceptable(List<Type> argtypes,
+    boolean argumentsAcceptable(Env<AttrContext> env,
+                                List<Type> argtypes,
                                 List<Type> formals,
                                 boolean allowBoxing,
                                 boolean useVarargs,
                                 Warner warn) {
         try {
-            checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn);
+            checkRawArgumentsAcceptable(env, argtypes, formals, allowBoxing, useVarargs, warn);
             return true;
         } catch (InapplicableMethodException ex) {
             return false;
         }
     }
-    void checkRawArgumentsAcceptable(List<Type> argtypes,
+    void checkRawArgumentsAcceptable(Env<AttrContext> env,
+                                List<Type> argtypes,
                                 List<Type> formals,
                                 boolean allowBoxing,
                                 boolean useVarargs,
@@ -460,6 +462,14 @@
                             elt);
                 argtypes = argtypes.tail;
             }
+            //check varargs element type accessibility
+            if (!isAccessible(env, elt)) {
+                Symbol location = env.enclClass.sym;
+                throw inapplicableMethodException.setMessage("inaccessible.varargs.type",
+                            elt,
+                            Kinds.kindName(location),
+                            location);
+            }
         }
         return;
     }
@@ -474,6 +484,10 @@
                 this.diagnostic = null;
                 this.diags = diags;
             }
+            InapplicableMethodException setMessage() {
+                this.diagnostic = null;
+                return this;
+            }
             InapplicableMethodException setMessage(String key) {
                 this.diagnostic = key != null ? diags.fragment(key) : null;
                 return this;
@@ -482,6 +496,10 @@
                 this.diagnostic = key != null ? diags.fragment(key, args) : null;
                 return this;
             }
+            InapplicableMethodException setMessage(JCDiagnostic diag) {
+                this.diagnostic = diag;
+                return this;
+            }
 
             public JCDiagnostic getDiagnostic() {
                 return diagnostic;
@@ -712,13 +730,14 @@
                 Type mt1 = types.memberType(site, m1);
                 Type mt2 = types.memberType(site, m2);
                 if (!types.overrideEquivalent(mt1, mt2))
-                    return new AmbiguityError(m1, m2);
+                    return ambiguityError(m1, m2);
+
                 // same signature; select (a) the non-bridge method, or
                 // (b) the one that overrides the other, or (c) the concrete
                 // one, or (d) merge both abstract signatures
-                if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) {
+                if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE))
                     return ((m1.flags() & BRIDGE) != 0) ? m2 : m1;
-                }
+
                 // if one overrides or hides the other, use it
                 TypeSymbol m1Owner = (TypeSymbol)m1.owner;
                 TypeSymbol m2Owner = (TypeSymbol)m2.owner;
@@ -738,24 +757,24 @@
                 if (m2Abstract && !m1Abstract) return m1;
                 // both abstract or both concrete
                 if (!m1Abstract && !m2Abstract)
-                    return new AmbiguityError(m1, m2);
+                    return ambiguityError(m1, m2);
                 // check that both signatures have the same erasure
                 if (!types.isSameTypes(m1.erasure(types).getParameterTypes(),
                                        m2.erasure(types).getParameterTypes()))
-                    return new AmbiguityError(m1, m2);
+                    return ambiguityError(m1, m2);
                 // both abstract, neither overridden; merge throws clause and result type
                 Symbol mostSpecific;
                 Type result2 = mt2.getReturnType();
                 if (mt2.tag == FORALL)
                     result2 = types.subst(result2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars);
-                if (types.isSubtype(mt1.getReturnType(), result2)) {
+                if (types.isSubtype(mt1.getReturnType(), result2))
                     mostSpecific = m1;
-                } else if (types.isSubtype(result2, mt1.getReturnType())) {
+                else if (types.isSubtype(result2, mt1.getReturnType()))
                     mostSpecific = m2;
-                } else {
+                else {
                     // Theoretically, this can't happen, but it is possible
                     // due to error recovery or mixing incompatible class files
-                    return new AmbiguityError(m1, m2);
+                    return ambiguityError(m1, m2);
                 }
                 MethodSymbol result = new MethodSymbol(
                         mostSpecific.flags(),
@@ -777,7 +796,7 @@
             }
             if (m1SignatureMoreSpecific) return m1;
             if (m2SignatureMoreSpecific) return m2;
-            return new AmbiguityError(m1, m2);
+            return ambiguityError(m1, m2);
         case AMBIGUOUS:
             AmbiguityError e = (AmbiguityError)m2;
             Symbol err1 = mostSpecific(m1, e.sym, env, site, allowBoxing, useVarargs);
@@ -787,9 +806,9 @@
             if (err1 instanceof AmbiguityError &&
                 err2 instanceof AmbiguityError &&
                 ((AmbiguityError)err1).sym == ((AmbiguityError)err2).sym)
-                return new AmbiguityError(m1, m2);
+                return ambiguityError(m1, m2);
             else
-                return new AmbiguityError(err1, err2);
+                return ambiguityError(err1, err2);
         default:
             throw new AssertionError();
         }
@@ -844,6 +863,14 @@
             return to;
         }
     }
+    //where
+    Symbol ambiguityError(Symbol m1, Symbol m2) {
+        if (((m1.flags() | m2.flags()) & CLASH) != 0) {
+            return (m1.flags() & CLASH) == 0 ? m1 : m2;
+        } else {
+            return new AmbiguityError(m1, m2);
+        }
+    }
 
     /** Find best qualified method matching given name, type and value
      *  arguments.
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jan 28 09:25:20 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Jan 28 12:36:34 2011 +0000
@@ -831,6 +831,10 @@
 compiler.misc.varargs.trustme.on.virtual.varargs=\
     Instance method {0} is not final.
 
+# 0: type, 1: kind, 2: symbol
+compiler.misc.inaccessible.varargs.type=\
+    formal varargs element type {0} is not accessible from {1} {2}
+
 # In the following string, {1} will always be the detail message from
 # java.io.IOException.
 # 0: symbol, 1: string
@@ -1564,11 +1568,6 @@
     inferred: {0}\n\
     bound(s): {1}
 
-compiler.misc.inferred.do.not.conform.to.params=\
-    actual arguments do not conform to inferred formal arguments\n\
-    required: {0}\n\
-    found: {1}
-
 # 0: symbol
 compiler.misc.diamond=\
     {0}<>
--- a/test/tools/javac/diags/examples.not-yet.txt	Fri Jan 28 09:25:20 2011 +0000
+++ b/test/tools/javac/diags/examples.not-yet.txt	Fri Jan 28 12:36:34 2011 +0000
@@ -63,7 +63,6 @@
 compiler.misc.fatal.err.cant.close.loader               # JavacProcessingEnvironment
 compiler.misc.file.does.not.contain.package
 compiler.misc.illegal.start.of.class.file
-compiler.misc.inferred.do.not.conform.to.params         # UNUSED (hard to see if very complex inference scenario might require this though, so leaving it in, as per JLS3)
 compiler.misc.kindname.annotation
 compiler.misc.kindname.enum
 compiler.misc.kindname.package
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+// key: compiler.misc.inaccessible.varargs.type
+// key: compiler.err.cant.apply.symbol.1
+
+import p1.B;
+
+class InaccessibleVarargsType {
+    { new B().foo(new B(), new B()); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/p1/A.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package p1;
+
+class A {
+    A() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/p1/B.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package p1;
+
+public class B extends A {
+    public B() {}
+    public void foo(A... args) { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550a.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550a.out -XDrawDiagnostics T6910550a.java
+ *
+ */
+import java.util.*;
+
+class T6910550a {
+    void m(List<String> ls) {}
+    void m(List<Integer> li) {}
+
+    { m(Arrays.asList(12)); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550a.out	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,2 @@
+T6910550a.java:13:10: compiler.err.name.clash.same.erasure: m(java.util.List<java.lang.Integer>), m(java.util.List<java.lang.String>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550b.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550b.out -XDrawDiagnostics T6910550b.java
+ *
+ */
+
+class T6910550b<X, Y, Z> {
+    void m(X x) {}
+    void m(Y y) {}
+    void m(Z y) {}
+
+    { m(null); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550b.out	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,3 @@
+T6910550b.java:12:10: compiler.err.name.clash.same.erasure: m(Y), m(X)
+T6910550b.java:13:10: compiler.err.name.clash.same.erasure: m(Z), m(X)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550c.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550c.out -XDrawDiagnostics T6910550c.java
+ *
+ */
+
+class T6910550c {
+    void m(Object[] x) {}
+    void m(Object... x) {}
+
+    { m(); }
+    { m(null); }
+    { m(null, null); }
+    { m(null, null, null); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550c.out	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,2 @@
+T6910550c.java:12:10: compiler.err.array.and.varargs: m(java.lang.Object...), m(java.lang.Object[]), T6910550c
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550d.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550d.out -XDrawDiagnostics T6910550d.java
+ *
+ */
+
+class T6910550d {
+    <X> void m(X x) {}
+    <Y> void m(Y y) {}
+
+    { m(null); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550d.out	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,2 @@
+T6910550d.java:12:14: compiler.err.already.defined: <X>m(X), T6910550d
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550e.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6910550
+ *
+ * @summary javac 1.5.0_17 fails with incorrect error message
+ * @compile/fail/ref=T6910550e.out -XDrawDiagnostics T6910550e.java
+ *
+ */
+
+class T6910550e {
+    static class Pair<X,Y> {}
+
+    <X> void m(Pair<X,X> x) {}
+    <X,Y> void m(Pair<X,Y> y) {}
+
+   { m(new Pair<String,String>());
+     m(new Pair<String,Integer>()); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/6910550/T6910550e.out	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,2 @@
+T6910550e.java:14:16: compiler.err.name.clash.same.erasure: <X,Y>m(T6910550e.Pair<X,Y>), <X>m(T6910550e.Pair<X,X>)
+1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712c.out	Fri Jan 28 09:25:20 2011 +0000
+++ b/test/tools/javac/generics/inference/6638712/T6638712c.out	Fri Jan 28 12:36:34 2011 +0000
@@ -1,2 +1,2 @@
-T6638712c.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Enum[],java.util.Comparator<? super java.lang.Enum>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>)
+T6638712c.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.no.conforming.assignment.exists: java.util.Comparator<java.lang.Enum<?>>, java.util.Comparator<? super java.lang.Enum>)
 1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712d.out	Fri Jan 28 09:25:20 2011 +0000
+++ b/test/tools/javac/generics/inference/6638712/T6638712d.out	Fri Jan 28 12:36:34 2011 +0000
@@ -1,2 +1,2 @@
-T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.params: java.lang.String,java.util.List<java.util.List<java.lang.String>>, int,java.util.List<java.util.List<java.lang.String>>)
+T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.no.conforming.assignment.exists: int, java.lang.String)
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6838943/T6838943.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,16 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6838943
+ * @summary inference: javac is not handling type-variable substitution properly
+ * @compile/fail/ref=T6838943.out -XDrawDiagnostics T6838943.java
+ */
+class T6838943 {
+    static class A<X> {}
+    static class B {}
+    static class C<X> {
+        <Z> void m(X x, Z z) {
+            C<A<Z>> c = new C<A<Z>>();
+            c.m(new A<B>(), new B()); //should fail
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/6838943/T6838943.out	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,2 @@
+T6838943.java:13:14: compiler.err.cant.apply.symbol.1: kindname.method, m, T6838943.A<Z>,Z, T6838943.A<T6838943.B>,T6838943.B, kindname.class, T6838943.C<X>, (compiler.misc.infer.no.conforming.assignment.exists: Z, T6838943.A<T6838943.B>, T6838943.A<Z>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/varargs/6313164/T6313164.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     6313164
+ * @author mcimadamore
+ * @summary  javac generates code that fails byte code verification for the varargs feature
+ * @compile/fail/ref=T6313164.out -XDrawDiagnostics T6313164.java
+ */
+import p1.*;
+
+class T6313164 {
+    { B b = new B();
+      b.foo1(new B(), new B()); //error - A not accesible
+      b.foo2(new B(), new B()); //ok - A not accessible, but foo2(Object...) applicable
+      b.foo3(null, null); //error - A (inferred) not accesible
+      b.foo4(null, null); //error - A (inferred in 15.12.2.8 - no resolution backtrack) not accesible
+      b.foo4(new B(), new C()); //ok - A (inferred in 15.12.2.7) not accessible, but foo4(Object...) applicable
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/varargs/6313164/T6313164.out	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,6 @@
+T6313164.java:12:8: compiler.err.cant.apply.symbol.1: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:14:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:15:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+- compiler.note.unchecked.filename: B.java
+- compiler.note.unchecked.recompile
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/varargs/6313164/p1/A.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package p1;
+
+class A {
+    A() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/varargs/6313164/p1/B.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package p1;
+
+public class B extends A {
+    public B() {}
+    public void foo1(A... args) { }
+    public void foo2(A... args) { }
+    public void foo2(Object... args) { }
+    public <X extends A> void foo3(X... args) { }
+    public <X extends A> void foo4(X... args) { }
+    public void foo4(Object... args) { }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/varargs/6313164/p1/C.java	Fri Jan 28 12:36:34 2011 +0000
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package p1;
+
+public class C extends A { }