Fri, 28 Jan 2011 12:36:34 +0000
Merge
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Flags.java Fri Jan 28 09:25:20 2011 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Flags.java Fri Jan 28 12:36:34 2011 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -252,6 +252,11 @@ 1.11 */ 1.12 public static final long EFFECTIVELY_FINAL = 1L<<42; 1.13 1.14 + /** 1.15 + * Flag that marks non-override equivalent methods with the same signature 1.16 + */ 1.17 + public static final long CLASH = 1L<<43; 1.18 + 1.19 /** Modifier masks. 1.20 */ 1.21 public static final int
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Fri Jan 28 09:25:20 2011 +0000 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Fri Jan 28 12:36:34 2011 +0000 2.3 @@ -2259,6 +2259,13 @@ 2.4 2.5 @Override 2.6 public Type visitForAll(ForAll t, Void ignored) { 2.7 + if (Type.containsAny(to, t.tvars)) { 2.8 + //perform alpha-renaming of free-variables in 't' 2.9 + //if 'to' types contain variables that are free in 't' 2.10 + List<Type> freevars = newInstances(t.tvars); 2.11 + t = new ForAll(freevars, 2.12 + Types.this.subst(t.qtype, t.tvars, freevars)); 2.13 + } 2.14 List<Type> tvars1 = substBounds(t.tvars, from, to); 2.15 Type qtype1 = subst(t.qtype); 2.16 if (tvars1 == t.tvars && qtype1 == t.qtype) {
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jan 28 09:25:20 2011 +0000 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jan 28 12:36:34 2011 +0000 3.3 @@ -60,6 +60,7 @@ 3.4 3.5 private final Names names; 3.6 private final Log log; 3.7 + private final Resolve rs; 3.8 private final Symtab syms; 3.9 private final Enter enter; 3.10 private final Infer infer; 3.11 @@ -91,6 +92,7 @@ 3.12 3.13 names = Names.instance(context); 3.14 log = Log.instance(context); 3.15 + rs = Resolve.instance(context); 3.16 syms = Symtab.instance(context); 3.17 enter = Enter.instance(context); 3.18 infer = Infer.instance(context); 3.19 @@ -2121,7 +2123,7 @@ 3.20 3.21 public boolean accepts(Symbol s) { 3.22 return s.kind == MTH && 3.23 - (s.flags() & SYNTHETIC) == 0 && 3.24 + (s.flags() & (SYNTHETIC | CLASH)) == 0 && 3.25 s.isInheritedIn(site.tsym, types) && 3.26 !s.isConstructor(); 3.27 } 3.28 @@ -2581,28 +2583,42 @@ 3.29 if (sym.owner.name == names.any) return false; 3.30 for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) { 3.31 if (sym != e.sym && 3.32 + (e.sym.flags() & CLASH) == 0 && 3.33 sym.kind == e.sym.kind && 3.34 sym.name != names.error && 3.35 (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { 3.36 - if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) 3.37 + if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) { 3.38 varargsDuplicateError(pos, sym, e.sym); 3.39 - else if (sym.kind == MTH && !types.overrideEquivalent(sym.type, e.sym.type)) 3.40 + return true; 3.41 + } else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) { 3.42 duplicateErasureError(pos, sym, e.sym); 3.43 - else 3.44 + sym.flags_field |= CLASH; 3.45 + return true; 3.46 + } else { 3.47 duplicateError(pos, e.sym); 3.48 - return false; 3.49 + return false; 3.50 + } 3.51 } 3.52 } 3.53 return true; 3.54 } 3.55 //where 3.56 - /** Report duplicate declaration error. 3.57 - */ 3.58 - void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { 3.59 - if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { 3.60 - log.error(pos, "name.clash.same.erasure", sym1, sym2); 3.61 + boolean hasSameSignature(Type mt1, Type mt2) { 3.62 + if (mt1.tag == FORALL && mt2.tag == FORALL) { 3.63 + ForAll fa1 = (ForAll)mt1; 3.64 + ForAll fa2 = (ForAll)mt2; 3.65 + mt2 = types.subst(fa2, fa2.tvars, fa1.tvars); 3.66 + } 3.67 + return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType()); 3.68 } 3.69 - } 3.70 + 3.71 + /** Report duplicate declaration error. 3.72 + */ 3.73 + void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { 3.74 + if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { 3.75 + log.error(pos, "name.clash.same.erasure", sym1, sym2); 3.76 + } 3.77 + } 3.78 3.79 /** Check that single-type import is not already imported or top-level defined, 3.80 * but make an exception for two single-type imports which denote the same type.
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Jan 28 09:25:20 2011 +0000 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Jan 28 12:36:34 2011 +0000 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -485,11 +485,8 @@ 4.11 @Override 4.12 public Type inst(List<Type> inferred, Types types) throws NoInstanceException { 4.13 List<Type> formals = types.subst(mt2.argtypes, tvars, inferred); 4.14 - if (!rs.argumentsAcceptable(capturedArgs, formals, 4.15 - allowBoxing, useVarargs, warn)) { 4.16 - // inferred method is not applicable 4.17 - throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes); 4.18 - } 4.19 + // check that actuals conform to inferred formals 4.20 + checkArgumentsAcceptable(env, capturedArgs, formals, allowBoxing, useVarargs, warn); 4.21 // check that inferred bounds conform to their bounds 4.22 checkWithinBounds(all_tvars, 4.23 types.subst(inferredTypes, tvars, inferred), warn); 4.24 @@ -500,17 +497,27 @@ 4.25 }}; 4.26 return mt2; 4.27 } 4.28 - else if (!rs.argumentsAcceptable(capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn)) { 4.29 - // inferred method is not applicable 4.30 - throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes); 4.31 - } 4.32 else { 4.33 + // check that actuals conform to inferred formals 4.34 + checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn); 4.35 // return instantiated version of method type 4.36 return mt; 4.37 } 4.38 } 4.39 //where 4.40 4.41 + private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals, 4.42 + boolean allowBoxing, boolean useVarargs, Warner warn) { 4.43 + try { 4.44 + rs.checkRawArgumentsAcceptable(env, actuals, formals, 4.45 + allowBoxing, useVarargs, warn); 4.46 + } 4.47 + catch (Resolve.InapplicableMethodException ex) { 4.48 + // inferred method is not applicable 4.49 + throw invalidInstanceException.setMessage(ex.getDiagnostic()); 4.50 + } 4.51 + } 4.52 + 4.53 /** Try to instantiate argument type `that' to given type `to'. 4.54 * If this fails, try to insantiate `that' to `to' where 4.55 * every occurrence of a type variable in `tvars' is replaced
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 28 09:25:20 2011 +0000 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jan 28 12:36:34 2011 +0000 5.3 @@ -278,7 +278,7 @@ 5.4 return true; 5.5 else { 5.6 Symbol s2 = ((MethodSymbol)sym).implementation(site.tsym, types, true); 5.7 - return (s2 == null || s2 == sym || 5.8 + return (s2 == null || s2 == sym || sym.owner == s2.owner || 5.9 s2.isPolymorphicSignatureGeneric() || 5.10 !types.isSubSignature(types.memberType(site, s2), types.memberType(site, sym))); 5.11 } 5.12 @@ -331,7 +331,7 @@ 5.13 throws Infer.InferenceException { 5.14 boolean polymorphicSignature = m.isPolymorphicSignatureGeneric() && allowMethodHandles; 5.15 if (useVarargs && (m.flags() & VARARGS) == 0) 5.16 - throw inapplicableMethodException.setMessage(null); 5.17 + throw inapplicableMethodException.setMessage(); 5.18 Type mt = types.memberType(site, m); 5.19 5.20 // tvars is the list of formal type variables for which type arguments 5.21 @@ -386,7 +386,7 @@ 5.22 useVarargs, 5.23 warn); 5.24 5.25 - checkRawArgumentsAcceptable(argtypes, mt.getParameterTypes(), 5.26 + checkRawArgumentsAcceptable(env, argtypes, mt.getParameterTypes(), 5.27 allowBoxing, useVarargs, warn); 5.28 return mt; 5.29 } 5.30 @@ -411,19 +411,21 @@ 5.31 5.32 /** Check if a parameter list accepts a list of args. 5.33 */ 5.34 - boolean argumentsAcceptable(List<Type> argtypes, 5.35 + boolean argumentsAcceptable(Env<AttrContext> env, 5.36 + List<Type> argtypes, 5.37 List<Type> formals, 5.38 boolean allowBoxing, 5.39 boolean useVarargs, 5.40 Warner warn) { 5.41 try { 5.42 - checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn); 5.43 + checkRawArgumentsAcceptable(env, argtypes, formals, allowBoxing, useVarargs, warn); 5.44 return true; 5.45 } catch (InapplicableMethodException ex) { 5.46 return false; 5.47 } 5.48 } 5.49 - void checkRawArgumentsAcceptable(List<Type> argtypes, 5.50 + void checkRawArgumentsAcceptable(Env<AttrContext> env, 5.51 + List<Type> argtypes, 5.52 List<Type> formals, 5.53 boolean allowBoxing, 5.54 boolean useVarargs, 5.55 @@ -460,6 +462,14 @@ 5.56 elt); 5.57 argtypes = argtypes.tail; 5.58 } 5.59 + //check varargs element type accessibility 5.60 + if (!isAccessible(env, elt)) { 5.61 + Symbol location = env.enclClass.sym; 5.62 + throw inapplicableMethodException.setMessage("inaccessible.varargs.type", 5.63 + elt, 5.64 + Kinds.kindName(location), 5.65 + location); 5.66 + } 5.67 } 5.68 return; 5.69 } 5.70 @@ -474,6 +484,10 @@ 5.71 this.diagnostic = null; 5.72 this.diags = diags; 5.73 } 5.74 + InapplicableMethodException setMessage() { 5.75 + this.diagnostic = null; 5.76 + return this; 5.77 + } 5.78 InapplicableMethodException setMessage(String key) { 5.79 this.diagnostic = key != null ? diags.fragment(key) : null; 5.80 return this; 5.81 @@ -482,6 +496,10 @@ 5.82 this.diagnostic = key != null ? diags.fragment(key, args) : null; 5.83 return this; 5.84 } 5.85 + InapplicableMethodException setMessage(JCDiagnostic diag) { 5.86 + this.diagnostic = diag; 5.87 + return this; 5.88 + } 5.89 5.90 public JCDiagnostic getDiagnostic() { 5.91 return diagnostic; 5.92 @@ -712,13 +730,14 @@ 5.93 Type mt1 = types.memberType(site, m1); 5.94 Type mt2 = types.memberType(site, m2); 5.95 if (!types.overrideEquivalent(mt1, mt2)) 5.96 - return new AmbiguityError(m1, m2); 5.97 + return ambiguityError(m1, m2); 5.98 + 5.99 // same signature; select (a) the non-bridge method, or 5.100 // (b) the one that overrides the other, or (c) the concrete 5.101 // one, or (d) merge both abstract signatures 5.102 - if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) { 5.103 + if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) 5.104 return ((m1.flags() & BRIDGE) != 0) ? m2 : m1; 5.105 - } 5.106 + 5.107 // if one overrides or hides the other, use it 5.108 TypeSymbol m1Owner = (TypeSymbol)m1.owner; 5.109 TypeSymbol m2Owner = (TypeSymbol)m2.owner; 5.110 @@ -738,24 +757,24 @@ 5.111 if (m2Abstract && !m1Abstract) return m1; 5.112 // both abstract or both concrete 5.113 if (!m1Abstract && !m2Abstract) 5.114 - return new AmbiguityError(m1, m2); 5.115 + return ambiguityError(m1, m2); 5.116 // check that both signatures have the same erasure 5.117 if (!types.isSameTypes(m1.erasure(types).getParameterTypes(), 5.118 m2.erasure(types).getParameterTypes())) 5.119 - return new AmbiguityError(m1, m2); 5.120 + return ambiguityError(m1, m2); 5.121 // both abstract, neither overridden; merge throws clause and result type 5.122 Symbol mostSpecific; 5.123 Type result2 = mt2.getReturnType(); 5.124 if (mt2.tag == FORALL) 5.125 result2 = types.subst(result2, ((ForAll)mt2).tvars, ((ForAll)mt1).tvars); 5.126 - if (types.isSubtype(mt1.getReturnType(), result2)) { 5.127 + if (types.isSubtype(mt1.getReturnType(), result2)) 5.128 mostSpecific = m1; 5.129 - } else if (types.isSubtype(result2, mt1.getReturnType())) { 5.130 + else if (types.isSubtype(result2, mt1.getReturnType())) 5.131 mostSpecific = m2; 5.132 - } else { 5.133 + else { 5.134 // Theoretically, this can't happen, but it is possible 5.135 // due to error recovery or mixing incompatible class files 5.136 - return new AmbiguityError(m1, m2); 5.137 + return ambiguityError(m1, m2); 5.138 } 5.139 MethodSymbol result = new MethodSymbol( 5.140 mostSpecific.flags(), 5.141 @@ -777,7 +796,7 @@ 5.142 } 5.143 if (m1SignatureMoreSpecific) return m1; 5.144 if (m2SignatureMoreSpecific) return m2; 5.145 - return new AmbiguityError(m1, m2); 5.146 + return ambiguityError(m1, m2); 5.147 case AMBIGUOUS: 5.148 AmbiguityError e = (AmbiguityError)m2; 5.149 Symbol err1 = mostSpecific(m1, e.sym, env, site, allowBoxing, useVarargs); 5.150 @@ -787,9 +806,9 @@ 5.151 if (err1 instanceof AmbiguityError && 5.152 err2 instanceof AmbiguityError && 5.153 ((AmbiguityError)err1).sym == ((AmbiguityError)err2).sym) 5.154 - return new AmbiguityError(m1, m2); 5.155 + return ambiguityError(m1, m2); 5.156 else 5.157 - return new AmbiguityError(err1, err2); 5.158 + return ambiguityError(err1, err2); 5.159 default: 5.160 throw new AssertionError(); 5.161 } 5.162 @@ -844,6 +863,14 @@ 5.163 return to; 5.164 } 5.165 } 5.166 + //where 5.167 + Symbol ambiguityError(Symbol m1, Symbol m2) { 5.168 + if (((m1.flags() | m2.flags()) & CLASH) != 0) { 5.169 + return (m1.flags() & CLASH) == 0 ? m1 : m2; 5.170 + } else { 5.171 + return new AmbiguityError(m1, m2); 5.172 + } 5.173 + } 5.174 5.175 /** Find best qualified method matching given name, type and value 5.176 * arguments.
6.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Jan 28 09:25:20 2011 +0000 6.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Jan 28 12:36:34 2011 +0000 6.3 @@ -831,6 +831,10 @@ 6.4 compiler.misc.varargs.trustme.on.virtual.varargs=\ 6.5 Instance method {0} is not final. 6.6 6.7 +# 0: type, 1: kind, 2: symbol 6.8 +compiler.misc.inaccessible.varargs.type=\ 6.9 + formal varargs element type {0} is not accessible from {1} {2} 6.10 + 6.11 # In the following string, {1} will always be the detail message from 6.12 # java.io.IOException. 6.13 # 0: symbol, 1: string 6.14 @@ -1564,11 +1568,6 @@ 6.15 inferred: {0}\n\ 6.16 bound(s): {1} 6.17 6.18 -compiler.misc.inferred.do.not.conform.to.params=\ 6.19 - actual arguments do not conform to inferred formal arguments\n\ 6.20 - required: {0}\n\ 6.21 - found: {1} 6.22 - 6.23 # 0: symbol 6.24 compiler.misc.diamond=\ 6.25 {0}<>
7.1 --- a/test/tools/javac/diags/examples.not-yet.txt Fri Jan 28 09:25:20 2011 +0000 7.2 +++ b/test/tools/javac/diags/examples.not-yet.txt Fri Jan 28 12:36:34 2011 +0000 7.3 @@ -63,7 +63,6 @@ 7.4 compiler.misc.fatal.err.cant.close.loader # JavacProcessingEnvironment 7.5 compiler.misc.file.does.not.contain.package 7.6 compiler.misc.illegal.start.of.class.file 7.7 -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) 7.8 compiler.misc.kindname.annotation 7.9 compiler.misc.kindname.enum 7.10 compiler.misc.kindname.package
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java Fri Jan 28 12:36:34 2011 +0000 8.3 @@ -0,0 +1,31 @@ 8.4 +/* 8.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. 8.11 + * 8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 + * version 2 for more details (a copy is included in the LICENSE file that 8.16 + * accompanied this code). 8.17 + * 8.18 + * You should have received a copy of the GNU General Public License version 8.19 + * 2 along with this work; if not, write to the Free Software Foundation, 8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 + * 8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 + * or visit www.oracle.com if you need additional information or have any 8.24 + * questions. 8.25 + */ 8.26 + 8.27 +// key: compiler.misc.inaccessible.varargs.type 8.28 +// key: compiler.err.cant.apply.symbol.1 8.29 + 8.30 +import p1.B; 8.31 + 8.32 +class InaccessibleVarargsType { 8.33 + { new B().foo(new B(), new B()); } 8.34 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/p1/A.java Fri Jan 28 12:36:34 2011 +0000 9.3 @@ -0,0 +1,28 @@ 9.4 +/* 9.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.23 + * or visit www.oracle.com if you need additional information or have any 9.24 + * questions. 9.25 + */ 9.26 + 9.27 +package p1; 9.28 + 9.29 +class A { 9.30 + A() { } 9.31 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/p1/B.java Fri Jan 28 12:36:34 2011 +0000 10.3 @@ -0,0 +1,29 @@ 10.4 +/* 10.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +package p1; 10.28 + 10.29 +public class B extends A { 10.30 + public B() {} 10.31 + public void foo(A... args) { } 10.32 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/generics/6910550/T6910550a.java Fri Jan 28 12:36:34 2011 +0000 11.3 @@ -0,0 +1,16 @@ 11.4 +/* 11.5 + * @test /nodynamiccopyright/ 11.6 + * @bug 6910550 11.7 + * 11.8 + * @summary javac 1.5.0_17 fails with incorrect error message 11.9 + * @compile/fail/ref=T6910550a.out -XDrawDiagnostics T6910550a.java 11.10 + * 11.11 + */ 11.12 +import java.util.*; 11.13 + 11.14 +class T6910550a { 11.15 + void m(List<String> ls) {} 11.16 + void m(List<Integer> li) {} 11.17 + 11.18 + { m(Arrays.asList(12)); } 11.19 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/generics/6910550/T6910550a.out Fri Jan 28 12:36:34 2011 +0000 12.3 @@ -0,0 +1,2 @@ 12.4 +T6910550a.java:13:10: compiler.err.name.clash.same.erasure: m(java.util.List<java.lang.Integer>), m(java.util.List<java.lang.String>) 12.5 +1 error
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/generics/6910550/T6910550b.java Fri Jan 28 12:36:34 2011 +0000 13.3 @@ -0,0 +1,16 @@ 13.4 +/* 13.5 + * @test /nodynamiccopyright/ 13.6 + * @bug 6910550 13.7 + * 13.8 + * @summary javac 1.5.0_17 fails with incorrect error message 13.9 + * @compile/fail/ref=T6910550b.out -XDrawDiagnostics T6910550b.java 13.10 + * 13.11 + */ 13.12 + 13.13 +class T6910550b<X, Y, Z> { 13.14 + void m(X x) {} 13.15 + void m(Y y) {} 13.16 + void m(Z y) {} 13.17 + 13.18 + { m(null); } 13.19 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/generics/6910550/T6910550b.out Fri Jan 28 12:36:34 2011 +0000 14.3 @@ -0,0 +1,3 @@ 14.4 +T6910550b.java:12:10: compiler.err.name.clash.same.erasure: m(Y), m(X) 14.5 +T6910550b.java:13:10: compiler.err.name.clash.same.erasure: m(Z), m(X) 14.6 +2 errors
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/generics/6910550/T6910550c.java Fri Jan 28 12:36:34 2011 +0000 15.3 @@ -0,0 +1,18 @@ 15.4 +/* 15.5 + * @test /nodynamiccopyright/ 15.6 + * @bug 6910550 15.7 + * 15.8 + * @summary javac 1.5.0_17 fails with incorrect error message 15.9 + * @compile/fail/ref=T6910550c.out -XDrawDiagnostics T6910550c.java 15.10 + * 15.11 + */ 15.12 + 15.13 +class T6910550c { 15.14 + void m(Object[] x) {} 15.15 + void m(Object... x) {} 15.16 + 15.17 + { m(); } 15.18 + { m(null); } 15.19 + { m(null, null); } 15.20 + { m(null, null, null); } 15.21 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/tools/javac/generics/6910550/T6910550c.out Fri Jan 28 12:36:34 2011 +0000 16.3 @@ -0,0 +1,2 @@ 16.4 +T6910550c.java:12:10: compiler.err.array.and.varargs: m(java.lang.Object...), m(java.lang.Object[]), T6910550c 16.5 +1 error
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/tools/javac/generics/6910550/T6910550d.java Fri Jan 28 12:36:34 2011 +0000 17.3 @@ -0,0 +1,15 @@ 17.4 +/* 17.5 + * @test /nodynamiccopyright/ 17.6 + * @bug 6910550 17.7 + * 17.8 + * @summary javac 1.5.0_17 fails with incorrect error message 17.9 + * @compile/fail/ref=T6910550d.out -XDrawDiagnostics T6910550d.java 17.10 + * 17.11 + */ 17.12 + 17.13 +class T6910550d { 17.14 + <X> void m(X x) {} 17.15 + <Y> void m(Y y) {} 17.16 + 17.17 + { m(null); } 17.18 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/tools/javac/generics/6910550/T6910550d.out Fri Jan 28 12:36:34 2011 +0000 18.3 @@ -0,0 +1,2 @@ 18.4 +T6910550d.java:12:14: compiler.err.already.defined: <X>m(X), T6910550d 18.5 +1 error
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/tools/javac/generics/6910550/T6910550e.java Fri Jan 28 12:36:34 2011 +0000 19.3 @@ -0,0 +1,18 @@ 19.4 +/* 19.5 + * @test /nodynamiccopyright/ 19.6 + * @bug 6910550 19.7 + * 19.8 + * @summary javac 1.5.0_17 fails with incorrect error message 19.9 + * @compile/fail/ref=T6910550e.out -XDrawDiagnostics T6910550e.java 19.10 + * 19.11 + */ 19.12 + 19.13 +class T6910550e { 19.14 + static class Pair<X,Y> {} 19.15 + 19.16 + <X> void m(Pair<X,X> x) {} 19.17 + <X,Y> void m(Pair<X,Y> y) {} 19.18 + 19.19 + { m(new Pair<String,String>()); 19.20 + m(new Pair<String,Integer>()); } 19.21 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/tools/javac/generics/6910550/T6910550e.out Fri Jan 28 12:36:34 2011 +0000 20.3 @@ -0,0 +1,2 @@ 20.4 +T6910550e.java:14:16: compiler.err.name.clash.same.erasure: <X,Y>m(T6910550e.Pair<X,Y>), <X>m(T6910550e.Pair<X,X>) 20.5 +1 error
21.1 --- a/test/tools/javac/generics/inference/6638712/T6638712c.out Fri Jan 28 09:25:20 2011 +0000 21.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712c.out Fri Jan 28 12:36:34 2011 +0000 21.3 @@ -1,2 +1,2 @@ 21.4 -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<?>>) 21.5 +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>) 21.6 1 error
22.1 --- a/test/tools/javac/generics/inference/6638712/T6638712d.out Fri Jan 28 09:25:20 2011 +0000 22.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712d.out Fri Jan 28 12:36:34 2011 +0000 22.3 @@ -1,2 +1,2 @@ 22.4 -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>>) 22.5 +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) 22.6 1 error
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/tools/javac/generics/inference/6838943/T6838943.java Fri Jan 28 12:36:34 2011 +0000 23.3 @@ -0,0 +1,16 @@ 23.4 +/** 23.5 + * @test /nodynamiccopyright/ 23.6 + * @bug 6838943 23.7 + * @summary inference: javac is not handling type-variable substitution properly 23.8 + * @compile/fail/ref=T6838943.out -XDrawDiagnostics T6838943.java 23.9 + */ 23.10 +class T6838943 { 23.11 + static class A<X> {} 23.12 + static class B {} 23.13 + static class C<X> { 23.14 + <Z> void m(X x, Z z) { 23.15 + C<A<Z>> c = new C<A<Z>>(); 23.16 + c.m(new A<B>(), new B()); //should fail 23.17 + } 23.18 + } 23.19 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/tools/javac/generics/inference/6838943/T6838943.out Fri Jan 28 12:36:34 2011 +0000 24.3 @@ -0,0 +1,2 @@ 24.4 +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>) 24.5 +1 error
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/test/tools/javac/varargs/6313164/T6313164.java Fri Jan 28 12:36:34 2011 +0000 25.3 @@ -0,0 +1,18 @@ 25.4 +/* 25.5 + * @test /nodynamiccopyright/ 25.6 + * @bug 6313164 25.7 + * @author mcimadamore 25.8 + * @summary javac generates code that fails byte code verification for the varargs feature 25.9 + * @compile/fail/ref=T6313164.out -XDrawDiagnostics T6313164.java 25.10 + */ 25.11 +import p1.*; 25.12 + 25.13 +class T6313164 { 25.14 + { B b = new B(); 25.15 + b.foo1(new B(), new B()); //error - A not accesible 25.16 + b.foo2(new B(), new B()); //ok - A not accessible, but foo2(Object...) applicable 25.17 + b.foo3(null, null); //error - A (inferred) not accesible 25.18 + b.foo4(null, null); //error - A (inferred in 15.12.2.8 - no resolution backtrack) not accesible 25.19 + b.foo4(new B(), new C()); //ok - A (inferred in 15.12.2.7) not accessible, but foo4(Object...) applicable 25.20 + } 25.21 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/test/tools/javac/varargs/6313164/T6313164.out Fri Jan 28 12:36:34 2011 +0000 26.3 @@ -0,0 +1,6 @@ 26.4 +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) 26.5 +T6313164.java:14:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) 26.6 +T6313164.java:15:13: compiler.err.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) 26.7 +- compiler.note.unchecked.filename: B.java 26.8 +- compiler.note.unchecked.recompile 26.9 +3 errors
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/test/tools/javac/varargs/6313164/p1/A.java Fri Jan 28 12:36:34 2011 +0000 27.3 @@ -0,0 +1,28 @@ 27.4 +/* 27.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.7 + * 27.8 + * This code is free software; you can redistribute it and/or modify it 27.9 + * under the terms of the GNU General Public License version 2 only, as 27.10 + * published by the Free Software Foundation. 27.11 + * 27.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 27.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 27.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27.15 + * version 2 for more details (a copy is included in the LICENSE file that 27.16 + * accompanied this code). 27.17 + * 27.18 + * You should have received a copy of the GNU General Public License version 27.19 + * 2 along with this work; if not, write to the Free Software Foundation, 27.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 27.21 + * 27.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 27.23 + * or visit www.oracle.com if you need additional information or have any 27.24 + * questions. 27.25 + */ 27.26 + 27.27 +package p1; 27.28 + 27.29 +class A { 27.30 + A() { } 27.31 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/tools/javac/varargs/6313164/p1/B.java Fri Jan 28 12:36:34 2011 +0000 28.3 @@ -0,0 +1,35 @@ 28.4 +/* 28.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.7 + * 28.8 + * This code is free software; you can redistribute it and/or modify it 28.9 + * under the terms of the GNU General Public License version 2 only, as 28.10 + * published by the Free Software Foundation. 28.11 + * 28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 28.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28.15 + * version 2 for more details (a copy is included in the LICENSE file that 28.16 + * accompanied this code). 28.17 + * 28.18 + * You should have received a copy of the GNU General Public License version 28.19 + * 2 along with this work; if not, write to the Free Software Foundation, 28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 28.21 + * 28.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 28.23 + * or visit www.oracle.com if you need additional information or have any 28.24 + * questions. 28.25 + */ 28.26 + 28.27 +package p1; 28.28 + 28.29 +public class B extends A { 28.30 + public B() {} 28.31 + public void foo1(A... args) { } 28.32 + public void foo2(A... args) { } 28.33 + public void foo2(Object... args) { } 28.34 + public <X extends A> void foo3(X... args) { } 28.35 + public <X extends A> void foo4(X... args) { } 28.36 + public void foo4(Object... args) { } 28.37 + 28.38 +}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/test/tools/javac/varargs/6313164/p1/C.java Fri Jan 28 12:36:34 2011 +0000 29.3 @@ -0,0 +1,26 @@ 29.4 +/* 29.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.7 + * 29.8 + * This code is free software; you can redistribute it and/or modify it 29.9 + * under the terms of the GNU General Public License version 2 only, as 29.10 + * published by the Free Software Foundation. 29.11 + * 29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 29.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 29.15 + * version 2 for more details (a copy is included in the LICENSE file that 29.16 + * accompanied this code). 29.17 + * 29.18 + * You should have received a copy of the GNU General Public License version 29.19 + * 2 along with this work; if not, write to the Free Software Foundation, 29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 29.21 + * 29.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 29.23 + * or visit www.oracle.com if you need additional information or have any 29.24 + * questions. 29.25 + */ 29.26 + 29.27 +package p1; 29.28 + 29.29 +public class C extends A { }