Mon, 07 Feb 2011 18:10:13 +0000
7007615: java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
Summary: override clash algorithm is not implemented correctly
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Scope.java Mon Feb 07 18:09:46 2011 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Scope.java Mon Feb 07 18:10:13 2011 +0000 1.3 @@ -72,49 +72,10 @@ 1.4 */ 1.5 int nelems = 0; 1.6 1.7 - /** A timestamp - useful to quickly check whether a scope has changed or not 1.8 - */ 1.9 - public ScopeCounter scopeCounter; 1.10 - 1.11 - static ScopeCounter dummyCounter = new ScopeCounter() { 1.12 - @Override 1.13 - public void inc() { 1.14 - //do nothing 1.15 - } 1.16 - }; 1.17 - 1.18 /** A list of scopes to be notified if items are to be removed from this scope. 1.19 */ 1.20 List<Scope> listeners = List.nil(); 1.21 1.22 - public static class ScopeCounter { 1.23 - protected static final Context.Key<ScopeCounter> scopeCounterKey = 1.24 - new Context.Key<ScopeCounter>(); 1.25 - 1.26 - public static ScopeCounter instance(Context context) { 1.27 - ScopeCounter instance = context.get(scopeCounterKey); 1.28 - if (instance == null) 1.29 - instance = new ScopeCounter(context); 1.30 - return instance; 1.31 - } 1.32 - 1.33 - protected ScopeCounter(Context context) { 1.34 - context.put(scopeCounterKey, this); 1.35 - } 1.36 - 1.37 - private ScopeCounter() {}; 1.38 - 1.39 - private long val = 0; 1.40 - 1.41 - public void inc() { 1.42 - val++; 1.43 - } 1.44 - 1.45 - public long val() { 1.46 - return val; 1.47 - } 1.48 - } 1.49 - 1.50 /** Use as a "not-found" result for lookup. 1.51 * Also used to mark deleted entries in the table. 1.52 */ 1.53 @@ -126,35 +87,30 @@ 1.54 1.55 /** A value for the empty scope. 1.56 */ 1.57 - public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter); 1.58 + public static final Scope emptyScope = new Scope(null, null, new Entry[]{}); 1.59 1.60 /** Construct a new scope, within scope next, with given owner, using 1.61 * given table. The table's length must be an exponent of 2. 1.62 */ 1.63 - private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { 1.64 + private Scope(Scope next, Symbol owner, Entry[] table) { 1.65 this.next = next; 1.66 Assert.check(emptyScope == null || owner != null); 1.67 this.owner = owner; 1.68 this.table = table; 1.69 this.hashMask = table.length - 1; 1.70 - this.scopeCounter = scopeCounter; 1.71 } 1.72 1.73 /** Convenience constructor used for dup and dupUnshared. */ 1.74 - private Scope(Scope next, Symbol owner, Entry[] table) { 1.75 - this(next, owner, table, next.scopeCounter); 1.76 - this.nelems = next.nelems; 1.77 + private Scope(Scope next, Symbol owner, Entry[] table, int nelems) { 1.78 + this(next, owner, table); 1.79 + this.nelems = nelems; 1.80 } 1.81 1.82 /** Construct a new scope, within scope next, with given owner, 1.83 * using a fresh table of length INITIAL_SIZE. 1.84 */ 1.85 public Scope(Symbol owner) { 1.86 - this(owner, dummyCounter); 1.87 - } 1.88 - 1.89 - protected Scope(Symbol owner, ScopeCounter scopeCounter) { 1.90 - this(null, owner, new Entry[INITIAL_SIZE], scopeCounter); 1.91 + this(null, owner, new Entry[INITIAL_SIZE]); 1.92 } 1.93 1.94 /** Construct a fresh scope within this scope, with same owner, 1.95 @@ -172,7 +128,7 @@ 1.96 * of fresh tables. 1.97 */ 1.98 public Scope dup(Symbol newOwner) { 1.99 - Scope result = new Scope(this, newOwner, this.table); 1.100 + Scope result = new Scope(this, newOwner, this.table, this.nelems); 1.101 shared++; 1.102 // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); 1.103 // new Error().printStackTrace(System.out); 1.104 @@ -184,7 +140,7 @@ 1.105 * the table of its outer scope. 1.106 */ 1.107 public Scope dupUnshared() { 1.108 - return new Scope(this, this.owner, this.table.clone()); 1.109 + return new Scope(this, this.owner, this.table.clone(), this.nelems); 1.110 } 1.111 1.112 /** Remove all entries of this scope from its table, if shared 1.113 @@ -263,7 +219,6 @@ 1.114 Entry e = makeEntry(sym, old, elems, s, origin); 1.115 table[hash] = e; 1.116 elems = e; 1.117 - scopeCounter.inc(); 1.118 } 1.119 1.120 Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { 1.121 @@ -278,8 +233,6 @@ 1.122 Entry e = lookup(sym.name); 1.123 if (e.scope == null) return; 1.124 1.125 - scopeCounter.inc(); 1.126 - 1.127 // remove e from table and shadowed list; 1.128 int i = getIndex(sym.name); 1.129 Entry te = table[i]; 1.130 @@ -559,7 +512,7 @@ 1.131 public static final Entry[] emptyTable = new Entry[0]; 1.132 1.133 public DelegatedScope(Scope outer) { 1.134 - super(outer, outer.owner, emptyTable, outer.scopeCounter); 1.135 + super(outer, outer.owner, emptyTable); 1.136 delegatee = outer; 1.137 } 1.138 public Scope dup() { 1.139 @@ -585,22 +538,10 @@ 1.140 } 1.141 } 1.142 1.143 - /** A class scope, for which a scope counter should be provided */ 1.144 - public static class ClassScope extends Scope { 1.145 - 1.146 - ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) { 1.147 - super(next, owner, table, scopeCounter); 1.148 - } 1.149 - 1.150 - public ClassScope(Symbol owner, ScopeCounter scopeCounter) { 1.151 - super(owner, scopeCounter); 1.152 - } 1.153 - } 1.154 - 1.155 /** An error scope, for which the owner should be an error symbol. */ 1.156 public static class ErrorScope extends Scope { 1.157 ErrorScope(Scope next, Symbol errSymbol, Entry[] table) { 1.158 - super(next, /*owner=*/errSymbol, table, dummyCounter); 1.159 + super(next, /*owner=*/errSymbol, table); 1.160 } 1.161 public ErrorScope(Symbol errSymbol) { 1.162 super(errSymbol);
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Feb 07 18:09:46 2011 +0000 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Mon Feb 07 18:10:13 2011 +0000 2.3 @@ -729,6 +729,10 @@ 2.4 */ 2.5 public Pool pool; 2.6 2.7 + /** members closure cache (set by Types.membersClosure) 2.8 + */ 2.9 + Scope membersClosure; 2.10 + 2.11 public ClassSymbol(long flags, Name name, Type type, Symbol owner) { 2.12 super(flags, name, type, owner); 2.13 this.members_field = null; 2.14 @@ -1222,7 +1226,7 @@ 2.15 }; 2.16 2.17 public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) { 2.18 - MethodSymbol res = types.implementation(this, origin, types, checkResult, implFilter); 2.19 + MethodSymbol res = types.implementation(this, origin, checkResult, implFilter); 2.20 if (res != null) 2.21 return res; 2.22 // if origin is derived from a raw type, we might have missed
3.1 --- a/src/share/classes/com/sun/tools/javac/code/Symtab.java Mon Feb 07 18:09:46 2011 +0000 3.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java Mon Feb 07 18:10:13 2011 +0000 3.3 @@ -74,7 +74,6 @@ 3.4 public final JCNoType voidType = new JCNoType(TypeTags.VOID); 3.5 3.6 private final Names names; 3.7 - private final Scope.ScopeCounter scopeCounter; 3.8 private final ClassReader reader; 3.9 private final Target target; 3.10 3.11 @@ -343,7 +342,6 @@ 3.12 context.put(symtabKey, this); 3.13 3.14 names = Names.instance(context); 3.15 - scopeCounter = Scope.ScopeCounter.instance(context); 3.16 target = Target.instance(context); 3.17 3.18 // Create the unknown type 3.19 @@ -390,7 +388,7 @@ 3.20 3.21 // Create class to hold all predefined constants and operations. 3.22 predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage); 3.23 - Scope scope = new Scope.ClassScope(predefClass, scopeCounter); 3.24 + Scope scope = new Scope(predefClass); 3.25 predefClass.members_field = scope; 3.26 3.27 // Enter symbols for basic types. 3.28 @@ -483,7 +481,7 @@ 3.29 proprietarySymbol.completer = null; 3.30 proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE; 3.31 proprietarySymbol.erasure_field = proprietaryType; 3.32 - proprietarySymbol.members_field = new Scope.ClassScope(proprietarySymbol, scopeCounter); 3.33 + proprietarySymbol.members_field = new Scope(proprietarySymbol); 3.34 proprietaryType.typarams_field = List.nil(); 3.35 proprietaryType.allparams_field = List.nil(); 3.36 proprietaryType.supertype_field = annotationType; 3.37 @@ -495,7 +493,7 @@ 3.38 ClassType arrayClassType = (ClassType)arrayClass.type; 3.39 arrayClassType.supertype_field = objectType; 3.40 arrayClassType.interfaces_field = List.of(cloneableType, serializableType); 3.41 - arrayClass.members_field = new Scope.ClassScope(arrayClass, scopeCounter); 3.42 + arrayClass.members_field = new Scope(arrayClass); 3.43 lengthVar = new VarSymbol( 3.44 PUBLIC | FINAL, 3.45 names.length,
4.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Mon Feb 07 18:09:46 2011 +0000 4.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Mon Feb 07 18:10:13 2011 +0000 4.3 @@ -36,6 +36,7 @@ 4.4 import com.sun.tools.javac.code.Lint.LintCategory; 4.5 import com.sun.tools.javac.comp.Check; 4.6 4.7 +import static com.sun.tools.javac.code.Scope.*; 4.8 import static com.sun.tools.javac.code.Type.*; 4.9 import static com.sun.tools.javac.code.TypeTags.*; 4.10 import static com.sun.tools.javac.code.Symbol.*; 4.11 @@ -70,7 +71,6 @@ 4.12 new Context.Key<Types>(); 4.13 4.14 final Symtab syms; 4.15 - final Scope.ScopeCounter scopeCounter; 4.16 final JavacMessages messages; 4.17 final Names names; 4.18 final boolean allowBoxing; 4.19 @@ -91,7 +91,6 @@ 4.20 protected Types(Context context) { 4.21 context.put(typesKey, this); 4.22 syms = Symtab.instance(context); 4.23 - scopeCounter = Scope.ScopeCounter.instance(context); 4.24 names = Names.instance(context); 4.25 allowBoxing = Source.instance(context).allowBoxing(); 4.26 reader = ClassReader.instance(context); 4.27 @@ -2024,26 +2023,22 @@ 4.28 final MethodSymbol cachedImpl; 4.29 final Filter<Symbol> implFilter; 4.30 final boolean checkResult; 4.31 - final Scope.ScopeCounter scopeCounter; 4.32 4.33 public Entry(MethodSymbol cachedImpl, 4.34 Filter<Symbol> scopeFilter, 4.35 - boolean checkResult, 4.36 - Scope.ScopeCounter scopeCounter) { 4.37 + boolean checkResult) { 4.38 this.cachedImpl = cachedImpl; 4.39 this.implFilter = scopeFilter; 4.40 this.checkResult = checkResult; 4.41 - this.scopeCounter = scopeCounter; 4.42 } 4.43 4.44 - boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, Scope.ScopeCounter scopeCounter) { 4.45 + boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) { 4.46 return this.implFilter == scopeFilter && 4.47 - this.checkResult == checkResult && 4.48 - this.scopeCounter.val() >= scopeCounter.val(); 4.49 + this.checkResult == checkResult; 4.50 } 4.51 } 4.52 4.53 - MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter, Scope.ScopeCounter scopeCounter) { 4.54 + MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) { 4.55 SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms); 4.56 Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null; 4.57 if (cache == null) { 4.58 @@ -2052,9 +2047,9 @@ 4.59 } 4.60 Entry e = cache.get(origin); 4.61 if (e == null || 4.62 - !e.matches(implFilter, checkResult, scopeCounter)) { 4.63 + !e.matches(implFilter, checkResult)) { 4.64 MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter); 4.65 - cache.put(origin, new Entry(impl, implFilter, checkResult, scopeCounter)); 4.66 + cache.put(origin, new Entry(impl, implFilter, checkResult)); 4.67 return impl; 4.68 } 4.69 else { 4.70 @@ -2081,11 +2076,55 @@ 4.71 4.72 private ImplementationCache implCache = new ImplementationCache(); 4.73 4.74 - public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) { 4.75 - return implCache.get(ms, origin, checkResult, implFilter, scopeCounter); 4.76 + public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) { 4.77 + return implCache.get(ms, origin, checkResult, implFilter); 4.78 } 4.79 // </editor-fold> 4.80 4.81 + // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site"> 4.82 + public Scope membersClosure(Type site) { 4.83 + return membersClosure.visit(site); 4.84 + } 4.85 + 4.86 + UnaryVisitor<Scope> membersClosure = new UnaryVisitor<Scope>() { 4.87 + 4.88 + public Scope visitType(Type t, Void s) { 4.89 + return null; 4.90 + } 4.91 + 4.92 + @Override 4.93 + public Scope visitClassType(ClassType t, Void s) { 4.94 + ClassSymbol csym = (ClassSymbol)t.tsym; 4.95 + if (csym.membersClosure == null) { 4.96 + Scope membersClosure = new Scope(csym); 4.97 + for (Type i : interfaces(t)) { 4.98 + enterAll(visit(i), membersClosure); 4.99 + } 4.100 + enterAll(visit(supertype(t)), membersClosure); 4.101 + enterAll(csym.members(), membersClosure); 4.102 + csym.membersClosure = membersClosure; 4.103 + } 4.104 + return csym.membersClosure; 4.105 + } 4.106 + 4.107 + @Override 4.108 + public Scope visitTypeVar(TypeVar t, Void s) { 4.109 + return visit(t.getUpperBound()); 4.110 + } 4.111 + 4.112 + public void enterAll(Scope s, Scope to) { 4.113 + if (s == null) return; 4.114 + List<Symbol> syms = List.nil(); 4.115 + for (Scope.Entry e = s.elems ; e != null ; e = e.sibling) { 4.116 + syms = syms.prepend(e.sym); 4.117 + } 4.118 + for (Symbol sym : syms) { 4.119 + to.enter(sym); 4.120 + } 4.121 + } 4.122 + }; 4.123 + // </editor-fold> 4.124 + 4.125 /** 4.126 * Does t have the same arguments as s? It is assumed that both 4.127 * types are (possibly polymorphic) method types. Monomorphic
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Feb 07 18:09:46 2011 +0000 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Feb 07 18:10:13 2011 +0000 5.3 @@ -709,7 +709,11 @@ 5.4 5.5 // If we override any other methods, check that we do so properly. 5.6 // JLS ??? 5.7 - chk.checkClashes(tree.pos(), env.enclClass.type, m); 5.8 + if (m.isStatic()) { 5.9 + chk.checkHideClashes(tree.pos(), env.enclClass.type, m); 5.10 + } else { 5.11 + chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m); 5.12 + } 5.13 chk.checkOverride(tree, m); 5.14 5.15 // Create a new environment with local scope
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Feb 07 18:09:46 2011 +0000 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Feb 07 18:10:13 2011 +0000 6.3 @@ -1679,7 +1679,7 @@ 6.4 "(" + types.memberType(t2, s2).getParameterTypes() + ")"); 6.5 return s2; 6.6 } 6.7 - } else if (!checkNameClash((ClassSymbol)site.tsym, s1, s2)) { 6.8 + } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2)) { 6.9 log.error(pos, 6.10 "name.clash.same.erasure.no.override", 6.11 s1, s1.location(), 6.12 @@ -1761,18 +1761,10 @@ 6.13 } 6.14 6.15 private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) { 6.16 - if (s1.kind == MTH && 6.17 - s1.isInheritedIn(origin, types) && 6.18 - (s1.flags() & SYNTHETIC) == 0 && 6.19 - !s2.isConstructor()) { 6.20 - Type er1 = s2.erasure(types); 6.21 - Type er2 = s1.erasure(types); 6.22 - if (types.isSameTypes(er1.getParameterTypes(), 6.23 - er2.getParameterTypes())) { 6.24 - return false; 6.25 - } 6.26 - } 6.27 - return true; 6.28 + ClashFilter cf = new ClashFilter(origin.type); 6.29 + return (cf.accepts(s1) && 6.30 + cf.accepts(s2) && 6.31 + types.hasSameArgs(s1.erasure(types), s2.erasure(types))); 6.32 } 6.33 6.34 6.35 @@ -2111,52 +2103,82 @@ 6.36 * @param site The class whose methods are checked. 6.37 * @param sym The method symbol to be checked. 6.38 */ 6.39 - void checkClashes(DiagnosticPosition pos, Type site, Symbol sym) { 6.40 - List<Type> supertypes = types.closure(site); 6.41 - for (List<Type> l = supertypes; l.nonEmpty(); l = l.tail) { 6.42 - for (List<Type> m = supertypes; m.nonEmpty(); m = m.tail) { 6.43 - checkClashes(pos, l.head, m.head, site, sym); 6.44 + void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) { 6.45 + ClashFilter cf = new ClashFilter(site); 6.46 + //for each method m1 that is a member of 'site'... 6.47 + for (Scope.Entry e1 = types.membersClosure(site).lookup(sym.name, cf) ; 6.48 + e1.scope != null ; e1 = e1.next(cf)) { 6.49 + //...find another method m2 that is overridden (directly or indirectly) 6.50 + //by method 'sym' in 'site' 6.51 + for (Scope.Entry e2 = types.membersClosure(site).lookup(sym.name, cf) ; 6.52 + e2.scope != null ; e2 = e2.next(cf)) { 6.53 + if (e1.sym == e2.sym || !sym.overrides(e2.sym, site.tsym, types, false)) continue; 6.54 + //if (i) the signature of 'sym' is not a subsignature of m1 (seen as 6.55 + //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error 6.56 + if (!types.isSubSignature(sym.type, types.memberType(site, e1.sym)) && 6.57 + types.hasSameArgs(e1.sym.erasure(types), e2.sym.erasure(types))) { 6.58 + sym.flags_field |= CLASH; 6.59 + String key = e2.sym == sym ? 6.60 + "name.clash.same.erasure.no.override" : 6.61 + "name.clash.same.erasure.no.override.1"; 6.62 + log.error(pos, 6.63 + key, 6.64 + sym, sym.location(), 6.65 + e1.sym, e1.sym.location(), 6.66 + e2.sym, e2.sym.location()); 6.67 + return; 6.68 + } 6.69 } 6.70 } 6.71 } 6.72 6.73 - /** Reports an error whenever 'sym' seen as a member of type 't1' clashes with 6.74 - * some unrelated method defined in 't2'. 6.75 + /** Check that all static methods accessible from 'site' are 6.76 + * mutually compatible (JLS 8.4.8). 6.77 + * 6.78 + * @param pos Position to be used for error reporting. 6.79 + * @param site The class whose methods are checked. 6.80 + * @param sym The method symbol to be checked. 6.81 */ 6.82 - private void checkClashes(DiagnosticPosition pos, Type t1, Type t2, Type site, Symbol s1) { 6.83 + void checkHideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) { 6.84 ClashFilter cf = new ClashFilter(site); 6.85 - s1 = ((MethodSymbol)s1).implementedIn(t1.tsym, types); 6.86 - if (s1 == null) return; 6.87 - Type st1 = types.memberType(site, s1); 6.88 - for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name, cf); e2.scope != null; e2 = e2.next(cf)) { 6.89 - Symbol s2 = e2.sym; 6.90 - if (s1 == s2) continue; 6.91 - Type st2 = types.memberType(site, s2); 6.92 - if (!types.overrideEquivalent(st1, st2) && 6.93 - !checkNameClash((ClassSymbol)site.tsym, s1, s2)) { 6.94 + //for each method m1 that is a member of 'site'... 6.95 + for (Scope.Entry e = types.membersClosure(site).lookup(sym.name, cf) ; 6.96 + e.scope != null ; e = e.next(cf)) { 6.97 + //if (i) the signature of 'sym' is not a subsignature of m1 (seen as 6.98 + //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error 6.99 + if (!types.isSubSignature(sym.type, types.memberType(site, e.sym)) && 6.100 + types.hasSameArgs(e.sym.erasure(types), sym.erasure(types))) { 6.101 log.error(pos, 6.102 - "name.clash.same.erasure.no.override", 6.103 - s1, s1.location(), 6.104 - s2, s2.location()); 6.105 - } 6.106 - } 6.107 - } 6.108 - //where 6.109 - private class ClashFilter implements Filter<Symbol> { 6.110 + "name.clash.same.erasure.no.hide", 6.111 + sym, sym.location(), 6.112 + e.sym, e.sym.location()); 6.113 + return; 6.114 + } 6.115 + } 6.116 + } 6.117 6.118 - Type site; 6.119 + //where 6.120 + private class ClashFilter implements Filter<Symbol> { 6.121 6.122 - ClashFilter(Type site) { 6.123 - this.site = site; 6.124 - } 6.125 + Type site; 6.126 6.127 - public boolean accepts(Symbol s) { 6.128 - return s.kind == MTH && 6.129 - (s.flags() & (SYNTHETIC | CLASH)) == 0 && 6.130 - s.isInheritedIn(site.tsym, types) && 6.131 - !s.isConstructor(); 6.132 - } 6.133 - } 6.134 + ClashFilter(Type site) { 6.135 + this.site = site; 6.136 + } 6.137 + 6.138 + boolean shouldSkip(Symbol s) { 6.139 + return (s.flags() & CLASH) != 0 && 6.140 + s.owner == site.tsym; 6.141 + } 6.142 + 6.143 + public boolean accepts(Symbol s) { 6.144 + return s.kind == MTH && 6.145 + (s.flags() & SYNTHETIC) == 0 && 6.146 + !shouldSkip(s) && 6.147 + s.isInheritedIn(site.tsym, types) && 6.148 + !s.isConstructor(); 6.149 + } 6.150 + } 6.151 6.152 /** Report a conflict between a user symbol and a synthetic symbol. 6.153 */ 6.154 @@ -2638,10 +2660,10 @@ 6.155 if (sym.owner.name == names.any) return false; 6.156 for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) { 6.157 if (sym != e.sym && 6.158 - (e.sym.flags() & CLASH) == 0 && 6.159 - sym.kind == e.sym.kind && 6.160 - sym.name != names.error && 6.161 - (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { 6.162 + (e.sym.flags() & CLASH) == 0 && 6.163 + sym.kind == e.sym.kind && 6.164 + sym.name != names.error && 6.165 + (sym.kind != MTH || types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { 6.166 if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) { 6.167 varargsDuplicateError(pos, sym, e.sym); 6.168 return true; 6.169 @@ -2667,13 +2689,13 @@ 6.170 return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType()); 6.171 } 6.172 6.173 - /** Report duplicate declaration error. 6.174 - */ 6.175 - void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { 6.176 - if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { 6.177 - log.error(pos, "name.clash.same.erasure", sym1, sym2); 6.178 - } 6.179 + /** Report duplicate declaration error. 6.180 + */ 6.181 + void duplicateErasureError(DiagnosticPosition pos, Symbol sym1, Symbol sym2) { 6.182 + if (!sym1.type.isErroneous() && !sym2.type.isErroneous()) { 6.183 + log.error(pos, "name.clash.same.erasure", sym1, sym2); 6.184 } 6.185 + } 6.186 6.187 /** Check that single-type import is not already imported or top-level defined, 6.188 * but make an exception for two single-type imports which denote the same type.
7.1 --- a/src/share/classes/com/sun/tools/javac/comp/Enter.java Mon Feb 07 18:09:46 2011 +0000 7.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java Mon Feb 07 18:10:13 2011 +0000 7.3 @@ -95,7 +95,6 @@ 7.4 7.5 Log log; 7.6 Symtab syms; 7.7 - Scope.ScopeCounter scopeCounter; 7.8 Check chk; 7.9 TreeMaker make; 7.10 ClassReader reader; 7.11 @@ -123,7 +122,6 @@ 7.12 reader = ClassReader.instance(context); 7.13 make = TreeMaker.instance(context); 7.14 syms = Symtab.instance(context); 7.15 - scopeCounter = Scope.ScopeCounter.instance(context); 7.16 chk = Check.instance(context); 7.17 memberEnter = MemberEnter.instance(context); 7.18 types = Types.instance(context); 7.19 @@ -192,7 +190,7 @@ 7.20 */ 7.21 public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) { 7.22 Env<AttrContext> localEnv = 7.23 - env.dup(tree, env.info.dup(new Scope.ClassScope(tree.sym, scopeCounter))); 7.24 + env.dup(tree, env.info.dup(new Scope(tree.sym))); 7.25 localEnv.enclClass = tree; 7.26 localEnv.outer = env; 7.27 localEnv.info.isSelfCall = false; 7.28 @@ -328,7 +326,7 @@ 7.29 c.flatname = names.fromString(tree.packge + "." + name); 7.30 c.sourcefile = tree.sourcefile; 7.31 c.completer = null; 7.32 - c.members_field = new Scope.ClassScope(c, scopeCounter); 7.33 + c.members_field = new Scope(c); 7.34 tree.packge.package_info = c; 7.35 } 7.36 classEnter(tree.defs, topEnv); 7.37 @@ -396,7 +394,7 @@ 7.38 c.completer = memberEnter; 7.39 c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree); 7.40 c.sourcefile = env.toplevel.sourcefile; 7.41 - c.members_field = new Scope.ClassScope(c, scopeCounter); 7.42 + c.members_field = new Scope(c); 7.43 7.44 ClassType ct = (ClassType)c.type; 7.45 if (owner.kind != PCK && (c.flags_field & STATIC) == 0) {
8.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Feb 07 18:09:46 2011 +0000 8.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Mon Feb 07 18:10:13 2011 +0000 8.3 @@ -68,7 +68,6 @@ 8.4 private Names names; 8.5 private Log log; 8.6 private Symtab syms; 8.7 - private Scope.ScopeCounter scopeCounter; 8.8 private Resolve rs; 8.9 private Check chk; 8.10 private Attr attr; 8.11 @@ -91,7 +90,6 @@ 8.12 names = Names.instance(context); 8.13 log = Log.instance(context); 8.14 syms = Symtab.instance(context); 8.15 - scopeCounter = Scope.ScopeCounter.instance(context); 8.16 rs = Resolve.instance(context); 8.17 chk = Check.instance(context); 8.18 attr = Attr.instance(context); 8.19 @@ -571,7 +569,7 @@ 8.20 c.flatname = chk.localClassName(c); 8.21 c.sourcefile = owner.sourcefile; 8.22 c.completer = null; 8.23 - c.members_field = new Scope.ClassScope(c, scopeCounter); 8.24 + c.members_field = new Scope(c); 8.25 c.flags_field = flags; 8.26 ClassType ctype = (ClassType) c.type; 8.27 ctype.supertype_field = syms.objectType;
9.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Feb 07 18:09:46 2011 +0000 9.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Feb 07 18:10:13 2011 +0000 9.3 @@ -67,7 +67,6 @@ 9.4 private final Check chk; 9.5 private final Attr attr; 9.6 private final Symtab syms; 9.7 - private final Scope.ScopeCounter scopeCounter; 9.8 private final TreeMaker make; 9.9 private final ClassReader reader; 9.10 private final Todo todo; 9.11 @@ -94,7 +93,6 @@ 9.12 chk = Check.instance(context); 9.13 attr = Attr.instance(context); 9.14 syms = Symtab.instance(context); 9.15 - scopeCounter = Scope.ScopeCounter.instance(context); 9.16 make = TreeMaker.instance(context); 9.17 reader = ClassReader.instance(context); 9.18 todo = Todo.instance(context); 9.19 @@ -1023,7 +1021,7 @@ 9.20 } 9.21 9.22 private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) { 9.23 - Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter); 9.24 + Scope baseScope = new Scope(tree.sym); 9.25 //import already entered local classes into base scope 9.26 for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) { 9.27 if (e.sym.isLocal()) {
10.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Feb 07 18:09:46 2011 +0000 10.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Mon Feb 07 18:10:13 2011 +0000 10.3 @@ -138,9 +138,6 @@ 10.4 /** The symbol table. */ 10.5 Symtab syms; 10.6 10.7 - /** The scope counter */ 10.8 - Scope.ScopeCounter scopeCounter; 10.9 - 10.10 Types types; 10.11 10.12 /** The name table. */ 10.13 @@ -264,7 +261,6 @@ 10.14 10.15 names = Names.instance(context); 10.16 syms = Symtab.instance(context); 10.17 - scopeCounter = Scope.ScopeCounter.instance(context); 10.18 types = Types.instance(context); 10.19 fileManager = context.get(JavaFileManager.class); 10.20 if (fileManager == null) 10.21 @@ -1881,7 +1877,7 @@ 10.22 ClassType ct = (ClassType)c.type; 10.23 10.24 // allocate scope for members 10.25 - c.members_field = new Scope.ClassScope(c, scopeCounter); 10.26 + c.members_field = new Scope(c); 10.27 10.28 // prepare type variable table 10.29 typevars = typevars.dup(currentOwner);
11.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Feb 07 18:09:46 2011 +0000 11.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Mon Feb 07 18:10:13 2011 +0000 11.3 @@ -521,10 +521,20 @@ 11.4 compiler.err.name.clash.same.erasure=\ 11.5 name clash: {0} and {1} have the same erasure 11.6 11.7 -# 0: symbol, 1: symbol, 2: symbol, 3: symbol 11.8 +# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: unused, 5: unused 11.9 compiler.err.name.clash.same.erasure.no.override=\ 11.10 name clash: {0} in {1} and {2} in {3} have the same erasure, yet neither overrides the other 11.11 11.12 +# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: symbol, 5: symbol 11.13 +compiler.err.name.clash.same.erasure.no.override.1=\ 11.14 + name clash: {0} in {1} overrides a method whose erasure is the same as another method, yet neither overrides the other\n\ 11.15 + first method: {2} in {3}\n\ 11.16 + second method: {4} in {5} 11.17 + 11.18 +# 0: symbol, 1: symbol, 2: symbol, 3: symbol 11.19 +compiler.err.name.clash.same.erasure.no.hide=\ 11.20 + name clash: {0} in {1} and {2} in {3} have the same erasure, yet neither hides the other 11.21 + 11.22 compiler.err.name.reserved.for.internal.use=\ 11.23 {0} is reserved for internal use 11.24
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/diags/examples/NameClashSameErasureNoHide.java Mon Feb 07 18:10:13 2011 +0000 12.3 @@ -0,0 +1,34 @@ 12.4 +/* 12.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + */ 12.26 + 12.27 +// key: compiler.err.name.clash.same.erasure.no.hide 12.28 + 12.29 +public class NameClashSameErasureNoHide<X> { 12.30 + static class A { 12.31 + static void m(NameClashSameErasureNoHide<String> l) {} 12.32 + } 12.33 + 12.34 + static class B extends A { 12.35 + static void m(NameClashSameErasureNoHide<Integer> l) {} 12.36 + } 12.37 +}
13.1 --- a/test/tools/javac/diags/examples/NameClashSameErasureNoOverride.java Mon Feb 07 18:09:46 2011 +0000 13.2 +++ b/test/tools/javac/diags/examples/NameClashSameErasureNoOverride.java Mon Feb 07 18:10:13 2011 +0000 13.3 @@ -1,5 +1,5 @@ 13.4 /* 13.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 13.6 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.8 * 13.9 * This code is free software; you can redistribute it and/or modify it 13.10 @@ -25,10 +25,10 @@ 13.11 13.12 public class NameClashSameErasureNoOverride<X> { 13.13 static class A { 13.14 - static void m(NameClashSameErasureNoOverride<String> l) {} 13.15 + void m(NameClashSameErasureNoOverride<String> l) {} 13.16 } 13.17 13.18 static class B extends A { 13.19 - static void m(NameClashSameErasureNoOverride<Integer> l) {} 13.20 + void m(NameClashSameErasureNoOverride<Integer> l) {} 13.21 } 13.22 }
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/diags/examples/NameClashSameErasureNoOverride1.java Mon Feb 07 18:10:13 2011 +0000 14.3 @@ -0,0 +1,39 @@ 14.4 +/* 14.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 + * 14.8 + * This code is free software; you can redistribute it and/or modify it 14.9 + * under the terms of the GNU General Public License version 2 only, as 14.10 + * published by the Free Software Foundation. 14.11 + * 14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.15 + * version 2 for more details (a copy is included in the LICENSE file that 14.16 + * accompanied this code). 14.17 + * 14.18 + * You should have received a copy of the GNU General Public License version 14.19 + * 2 along with this work; if not, write to the Free Software Foundation, 14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.21 + * 14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 14.23 + * or visit www.oracle.com if you need additional information or have any 14.24 + * questions. 14.25 + */ 14.26 + 14.27 +// key: compiler.err.name.clash.same.erasure.no.override.1 14.28 + 14.29 +public class NameClashSameErasureNoOverride1 { 14.30 + 14.31 + interface I<X> { 14.32 + void m(X l); 14.33 + } 14.34 + 14.35 + class A { 14.36 + void m(Object l) {} 14.37 + } 14.38 + 14.39 + class B extends A implements I<Integer> { 14.40 + public void m(Integer l) {} 14.41 + } 14.42 +}
15.1 --- a/test/tools/javac/generics/5009937/T5009937.out Mon Feb 07 18:09:46 2011 +0000 15.2 +++ b/test/tools/javac/generics/5009937/T5009937.out Mon Feb 07 18:10:13 2011 +0000 15.3 @@ -1,2 +1,2 @@ 15.4 -T5009937.java:16:21: compiler.err.name.clash.same.erasure.no.override: m(T5009937<java.lang.Integer>), T5009937.B, m(T5009937<java.lang.String>), T5009937.A 15.5 +T5009937.java:16:21: compiler.err.name.clash.same.erasure.no.hide: m(T5009937<java.lang.Integer>), T5009937.B, m(T5009937<java.lang.String>), T5009937.A 15.6 1 error
16.1 --- a/test/tools/javac/generics/6182950/T6182950b.out Mon Feb 07 18:09:46 2011 +0000 16.2 +++ b/test/tools/javac/generics/6182950/T6182950b.out Mon Feb 07 18:10:13 2011 +0000 16.3 @@ -1,2 +1,2 @@ 16.4 -T6182950b.java:15:16: compiler.err.name.clash.same.erasure.no.override: m(java.util.List<java.lang.Integer>), T6182950b.B, m(java.util.List<java.lang.String>), T6182950b.A 16.5 +T6182950b.java:15:16: compiler.err.name.clash.same.erasure.no.override: m(java.util.List<java.lang.Integer>), T6182950b.B, m(java.util.List<java.lang.String>), T6182950b.A, m(java.util.List<java.lang.Integer>), T6182950b.B 16.6 1 error
17.1 --- a/test/tools/javac/generics/6476118/T6476118a.out Mon Feb 07 18:09:46 2011 +0000 17.2 +++ b/test/tools/javac/generics/6476118/T6476118a.out Mon Feb 07 18:10:13 2011 +0000 17.3 @@ -1,2 +1,2 @@ 17.4 -T6476118a.java:14:20: compiler.err.name.clash.same.erasure.no.override: compareTo(T), java.lang.Comparable, compareTo(java.lang.Object), T6476118a.A 17.5 +T6476118a.java:14:20: compiler.err.name.clash.same.erasure.no.override.1: compareTo(T6476118a.B), T6476118a.B, compareTo(java.lang.Object), T6476118a.A, compareTo(T), java.lang.Comparable 17.6 1 error
18.1 --- a/test/tools/javac/generics/6476118/T6476118b.out Mon Feb 07 18:09:46 2011 +0000 18.2 +++ b/test/tools/javac/generics/6476118/T6476118b.out Mon Feb 07 18:10:13 2011 +0000 18.3 @@ -1,2 +1,2 @@ 18.4 -T6476118b.java:12:20: compiler.err.name.clash.same.erasure.no.override: compareTo(T), java.lang.Comparable, compareTo(java.lang.Object), T6476118b 18.5 +T6476118b.java:12:20: compiler.err.name.clash.same.erasure.no.override.1: compareTo(T6476118b.B), T6476118b.B, compareTo(java.lang.Object), T6476118b, compareTo(T), java.lang.Comparable 18.6 1 error
19.1 --- a/test/tools/javac/generics/6476118/T6476118c.java Mon Feb 07 18:09:46 2011 +0000 19.2 +++ b/test/tools/javac/generics/6476118/T6476118c.java Mon Feb 07 18:10:13 2011 +0000 19.3 @@ -5,7 +5,7 @@ 19.4 * @compile/fail/ref=T6476118c.out -XDrawDiagnostics T6476118c.java 19.5 */ 19.6 19.7 -class T6476118b { 19.8 +class T6476118c { 19.9 static class A<T> { 19.10 public void foo(T t) { } 19.11 }
20.1 --- a/test/tools/javac/generics/6476118/T6476118c.out Mon Feb 07 18:09:46 2011 +0000 20.2 +++ b/test/tools/javac/generics/6476118/T6476118c.out Mon Feb 07 18:10:13 2011 +0000 20.3 @@ -1,3 +1,3 @@ 20.4 -T6476118c.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Object), T6476118b.C, foo(T), T6476118b.A 20.5 -T6476118c.java:19:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6476118b.C, foo(T), T6476118b.B 20.6 +T6476118c.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Object), T6476118c.C, foo(T), T6476118c.A, foo(java.lang.Object), T6476118c.C 20.7 +T6476118c.java:19:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6476118c.C, foo(T), T6476118c.B, foo(java.lang.Number), T6476118c.C 20.8 2 errors
21.1 --- a/test/tools/javac/generics/6985719/T6985719e.out Mon Feb 07 18:09:46 2011 +0000 21.2 +++ b/test/tools/javac/generics/6985719/T6985719e.out Mon Feb 07 18:10:13 2011 +0000 21.3 @@ -1,2 +1,2 @@ 21.4 -T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719e.B, f(java.util.List<java.lang.String>), T6985719e.A 21.5 +T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719e.B, f(java.util.List<java.lang.String>), T6985719e.A, f(java.util.List<java.lang.Integer>), T6985719e.B 21.6 1 error
22.1 --- a/test/tools/javac/generics/6985719/T6985719f.out Mon Feb 07 18:09:46 2011 +0000 22.2 +++ b/test/tools/javac/generics/6985719/T6985719f.out Mon Feb 07 18:10:13 2011 +0000 22.3 @@ -1,2 +1,2 @@ 22.4 -T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719f.B, f(java.util.List<java.lang.String>), T6985719f.A 22.5 +T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719f.B, f(java.util.List<java.lang.String>), T6985719f.A, f(java.util.List<java.lang.Integer>), T6985719f.B 22.6 1 error
23.1 --- a/test/tools/javac/generics/6985719/T6985719g.out Mon Feb 07 18:09:46 2011 +0000 23.2 +++ b/test/tools/javac/generics/6985719/T6985719g.out Mon Feb 07 18:10:13 2011 +0000 23.3 @@ -1,2 +1,2 @@ 23.4 -T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719g.B, f(java.util.List<X>), T6985719g.A 23.5 +T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719g.B, f(java.util.List<X>), T6985719g.A, f(java.util.List<java.lang.Integer>), T6985719g.B 23.6 1 error
24.1 --- a/test/tools/javac/generics/6985719/T6985719h.out Mon Feb 07 18:09:46 2011 +0000 24.2 +++ b/test/tools/javac/generics/6985719/T6985719h.out Mon Feb 07 18:10:13 2011 +0000 24.3 @@ -1,2 +1,2 @@ 24.4 -T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719h.B, f(java.util.List<X>), T6985719h.A 24.5 +T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719h.B, f(java.util.List<X>), T6985719h.A, f(java.util.List<java.lang.Integer>), T6985719h.B 24.6 1 error
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/test/tools/javac/generics/7007615/T7007615.java Mon Feb 07 18:10:13 2011 +0000 25.3 @@ -0,0 +1,27 @@ 25.4 +/* 25.5 + * @test /nodynamiccopyright/ 25.6 + * @bug 7007615 25.7 + * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123. 25.8 + * @author mcimadamore 25.9 + * @compile/fail/ref=T7007615.out -XDrawDiagnostics T7007615.java 25.10 + */ 25.11 + 25.12 +class T6985719a { 25.13 + class AX<T extends Number> { 25.14 + void foo(T t) { } 25.15 + } 25.16 + 25.17 + class BX<S extends Integer> extends AX<S> { 25.18 + @Override 25.19 + void foo(S t) { } 25.20 + void bar(BX bx){} 25.21 + } 25.22 + 25.23 + class DX extends BX<Integer> { 25.24 + void foo(Number t) { } 25.25 + void bar(BX<?> bx) { } 25.26 + 25.27 + @Override 25.28 + void foo(Integer t) { } 25.29 + } 25.30 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/test/tools/javac/generics/7007615/T7007615.out Mon Feb 07 18:10:13 2011 +0000 26.3 @@ -0,0 +1,3 @@ 26.4 +T7007615.java:21:14: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6985719a.DX, foo(T), T6985719a.AX, foo(java.lang.Number), T6985719a.DX 26.5 +T7007615.java:22:14: compiler.err.name.clash.same.erasure.no.override: bar(T6985719a.BX<?>), T6985719a.DX, bar(T6985719a.BX), T6985719a.BX, bar(T6985719a.BX<?>), T6985719a.DX 26.6 +2 errors
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/test/tools/javac/generics/7007615/acc1/AccessibilityCheck01.java Mon Feb 07 18:10:13 2011 +0000 27.3 @@ -0,0 +1,12 @@ 27.4 +/* 27.5 + * @test /nodynamiccopyright/ 27.6 + * @bug 7007615 27.7 + * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123. 27.8 + * @author dlsmith 27.9 + * @compile AccessibilityCheck01.java 27.10 + */ 27.11 + 27.12 +public class AccessibilityCheck01 extends p2.E { 27.13 + String m(Object o) { return "hi"; } // this is okay 27.14 + int m(String s) { return 3; } // this overrides m(String) illegally 27.15 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/tools/javac/generics/7007615/acc1/p1/C.java Mon Feb 07 18:10:13 2011 +0000 28.3 @@ -0,0 +1,25 @@ 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 +public class C<T> { void m(T arg) { } /* implicit: m(Object) */ }
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/test/tools/javac/generics/7007615/acc1/p1/D.java Mon Feb 07 18:10:13 2011 +0000 29.3 @@ -0,0 +1,25 @@ 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 +public class D<T> extends C<T> { /* inherits m(T), implicit m(Object) */ }
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/test/tools/javac/generics/7007615/acc1/p2/E.java Mon Feb 07 18:10:13 2011 +0000 30.3 @@ -0,0 +1,25 @@ 30.4 +/* 30.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 30.7 + * 30.8 + * This code is free software; you can redistribute it and/or modify it 30.9 + * under the terms of the GNU General Public License version 2 only, as 30.10 + * published by the Free Software Foundation. 30.11 + * 30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 30.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 30.15 + * version 2 for more details (a copy is included in the LICENSE file that 30.16 + * accompanied this code). 30.17 + * 30.18 + * You should have received a copy of the GNU General Public License version 30.19 + * 2 along with this work; if not, write to the Free Software Foundation, 30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 30.21 + * 30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 30.23 + * or visit www.oracle.com if you need additional information or have any 30.24 + * questions. 30.25 + */ 30.26 + 30.27 +package p2; 30.28 +public class E<T> extends p1.D<T> { /* inherits nothing */ }
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.java Mon Feb 07 18:10:13 2011 +0000 31.3 @@ -0,0 +1,13 @@ 31.4 +/* 31.5 + * @test /nodynamiccopyright/ 31.6 + * @bug 7007615 31.7 + * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123. 31.8 + * @author dlsmith 31.9 + * @compile/fail/ref=AccessibilityCheck02.out -XDrawDiagnostics AccessibilityCheck02.java 31.10 + */ 31.11 + 31.12 +public class AccessibilityCheck02 extends p2.E { 31.13 + String m(Object o) { return "hi"; } // this is okay 31.14 + public int m(String s) { return 3; } // this overrides m(String) illegally 31.15 +} 31.16 +
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.out Mon Feb 07 18:10:13 2011 +0000 32.3 @@ -0,0 +1,2 @@ 32.4 +AccessibilityCheck02.java:11:14: compiler.err.override.incompatible.ret: (compiler.misc.cant.override: m(java.lang.String), AccessibilityCheck02, m(java.lang.String), p1.D), int, void 32.5 +1 error
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/test/tools/javac/generics/7007615/acc2/p1/C.java Mon Feb 07 18:10:13 2011 +0000 33.3 @@ -0,0 +1,25 @@ 33.4 +/* 33.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.7 + * 33.8 + * This code is free software; you can redistribute it and/or modify it 33.9 + * under the terms of the GNU General Public License version 2 only, as 33.10 + * published by the Free Software Foundation. 33.11 + * 33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 33.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 33.15 + * version 2 for more details (a copy is included in the LICENSE file that 33.16 + * accompanied this code). 33.17 + * 33.18 + * You should have received a copy of the GNU General Public License version 33.19 + * 2 along with this work; if not, write to the Free Software Foundation, 33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 33.21 + * 33.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 33.23 + * or visit www.oracle.com if you need additional information or have any 33.24 + * questions. 33.25 + */ 33.26 + 33.27 +package p1; 33.28 +public class C<T> { void m(T arg) { } /* implicit: m(Object) */ }
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/test/tools/javac/generics/7007615/acc2/p1/D.java Mon Feb 07 18:10:13 2011 +0000 34.3 @@ -0,0 +1,25 @@ 34.4 +/* 34.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.7 + * 34.8 + * This code is free software; you can redistribute it and/or modify it 34.9 + * under the terms of the GNU General Public License version 2 only, as 34.10 + * published by the Free Software Foundation. 34.11 + * 34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 34.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34.15 + * version 2 for more details (a copy is included in the LICENSE file that 34.16 + * accompanied this code). 34.17 + * 34.18 + * You should have received a copy of the GNU General Public License version 34.19 + * 2 along with this work; if not, write to the Free Software Foundation, 34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 34.21 + * 34.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 34.23 + * or visit www.oracle.com if you need additional information or have any 34.24 + * questions. 34.25 + */ 34.26 + 34.27 +package p1; 34.28 +public class D extends C<String> { public void m(String arg) {} /* implicit bridge: m(Object) */ }
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 35.2 +++ b/test/tools/javac/generics/7007615/acc2/p2/E.java Mon Feb 07 18:10:13 2011 +0000 35.3 @@ -0,0 +1,25 @@ 35.4 +/* 35.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 35.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.7 + * 35.8 + * This code is free software; you can redistribute it and/or modify it 35.9 + * under the terms of the GNU General Public License version 2 only, as 35.10 + * published by the Free Software Foundation. 35.11 + * 35.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 35.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 35.15 + * version 2 for more details (a copy is included in the LICENSE file that 35.16 + * accompanied this code). 35.17 + * 35.18 + * You should have received a copy of the GNU General Public License version 35.19 + * 2 along with this work; if not, write to the Free Software Foundation, 35.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 35.21 + * 35.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 35.23 + * or visit www.oracle.com if you need additional information or have any 35.24 + * questions. 35.25 + */ 35.26 + 35.27 +package p2; 35.28 +public class E extends p1.D { /* inherits m(String) but not m(Object) */ }
36.1 --- a/test/tools/javac/scope/HashCollisionTest.java Mon Feb 07 18:09:46 2011 +0000 36.2 +++ b/test/tools/javac/scope/HashCollisionTest.java Mon Feb 07 18:10:13 2011 +0000 36.3 @@ -47,7 +47,6 @@ 36.4 JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab 36.5 names = Names.instance(context); // Name.Table impls tied to an instance of Names 36.6 symtab = Symtab.instance(context); 36.7 - scopeCounter = ScopeCounter.instance(context); 36.8 36.9 // determine hashMask for an empty scope 36.10 Scope emptyScope = new Scope(symtab.unnamedPackage); // any owner will do 36.11 @@ -171,7 +170,7 @@ 36.12 */ 36.13 ClassSymbol createClass(Name name, Symbol owner) { 36.14 ClassSymbol sym = new ClassSymbol(0, name, owner); 36.15 - sym.members_field = new ClassScope(sym, scopeCounter); 36.16 + sym.members_field = new Scope(sym); 36.17 if (owner != symtab.unnamedPackage) 36.18 owner.members().enter(sym); 36.19 return sym; 36.20 @@ -247,5 +246,4 @@ 36.21 36.22 Names names; 36.23 Symtab symtab; 36.24 - ScopeCounter scopeCounter; 36.25 }
37.1 --- a/test/tools/javac/scope/StarImportTest.java Mon Feb 07 18:09:46 2011 +0000 37.2 +++ b/test/tools/javac/scope/StarImportTest.java Mon Feb 07 18:10:13 2011 +0000 37.3 @@ -136,7 +136,6 @@ 37.4 JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab 37.5 names = Names.instance(context); // Name.Table impls tied to an instance of Names 37.6 symtab = Symtab.instance(context); 37.7 - scopeCounter = ScopeCounter.instance(context); 37.8 int setupCount = rgen.nextInt(MAX_SETUP_COUNT); 37.9 for (int i = 0; i < setupCount; i++) { 37.10 switch (random(SetupKind.values())) { 37.11 @@ -303,7 +302,7 @@ 37.12 37.13 ClassSymbol createClass(Name name, Symbol owner) { 37.14 ClassSymbol sym = new ClassSymbol(0, name, owner); 37.15 - sym.members_field = new ClassScope(sym, scopeCounter); 37.16 + sym.members_field = new Scope(sym); 37.17 if (owner != symtab.unnamedPackage) 37.18 owner.members().enter(sym); 37.19 return sym; 37.20 @@ -311,7 +310,6 @@ 37.21 37.22 Context context; 37.23 Symtab symtab; 37.24 - ScopeCounter scopeCounter; 37.25 Names names; 37.26 int nextNameSerial; 37.27 List<PackageSymbol> packages = new ArrayList<PackageSymbol>();