changeset 883:96d4226bdd60

7007615: java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123. Summary: override clash algorithm is not implemented correctly Reviewed-by: jjg
author mcimadamore
date Mon, 07 Feb 2011 18:10:13 +0000
parents 3aa269645199
children 56b77a38618c
files src/share/classes/com/sun/tools/javac/code/Scope.java src/share/classes/com/sun/tools/javac/code/Symbol.java src/share/classes/com/sun/tools/javac/code/Symtab.java src/share/classes/com/sun/tools/javac/code/Types.java src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/Check.java src/share/classes/com/sun/tools/javac/comp/Enter.java src/share/classes/com/sun/tools/javac/comp/Lower.java src/share/classes/com/sun/tools/javac/comp/MemberEnter.java src/share/classes/com/sun/tools/javac/jvm/ClassReader.java src/share/classes/com/sun/tools/javac/resources/compiler.properties test/tools/javac/diags/examples/NameClashSameErasureNoHide.java test/tools/javac/diags/examples/NameClashSameErasureNoOverride.java test/tools/javac/diags/examples/NameClashSameErasureNoOverride1.java test/tools/javac/generics/5009937/T5009937.out test/tools/javac/generics/6182950/T6182950b.out test/tools/javac/generics/6476118/T6476118a.out test/tools/javac/generics/6476118/T6476118b.out test/tools/javac/generics/6476118/T6476118c.java test/tools/javac/generics/6476118/T6476118c.out test/tools/javac/generics/6985719/T6985719e.out test/tools/javac/generics/6985719/T6985719f.out test/tools/javac/generics/6985719/T6985719g.out test/tools/javac/generics/6985719/T6985719h.out test/tools/javac/generics/7007615/T7007615.java test/tools/javac/generics/7007615/T7007615.out test/tools/javac/generics/7007615/acc1/AccessibilityCheck01.java test/tools/javac/generics/7007615/acc1/p1/C.java test/tools/javac/generics/7007615/acc1/p1/D.java test/tools/javac/generics/7007615/acc1/p2/E.java test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.java test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.out test/tools/javac/generics/7007615/acc2/p1/C.java test/tools/javac/generics/7007615/acc2/p1/D.java test/tools/javac/generics/7007615/acc2/p2/E.java test/tools/javac/scope/HashCollisionTest.java test/tools/javac/scope/StarImportTest.java
diffstat 37 files changed, 470 insertions(+), 186 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Scope.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Scope.java	Mon Feb 07 18:10:13 2011 +0000
@@ -72,49 +72,10 @@
      */
     int nelems = 0;
 
-    /** A timestamp - useful to quickly check whether a scope has changed or not
-     */
-    public ScopeCounter scopeCounter;
-
-    static ScopeCounter dummyCounter = new ScopeCounter() {
-        @Override
-        public void inc() {
-            //do nothing
-        }
-    };
-
     /** A list of scopes to be notified if items are to be removed from this scope.
      */
     List<Scope> listeners = List.nil();
 
-    public static class ScopeCounter {
-        protected static final Context.Key<ScopeCounter> scopeCounterKey =
-            new Context.Key<ScopeCounter>();
-
-        public static ScopeCounter instance(Context context) {
-            ScopeCounter instance = context.get(scopeCounterKey);
-            if (instance == null)
-                instance = new ScopeCounter(context);
-            return instance;
-        }
-
-        protected ScopeCounter(Context context) {
-            context.put(scopeCounterKey, this);
-        }
-
-        private ScopeCounter() {};
-
-        private long val = 0;
-
-        public void inc() {
-            val++;
-        }
-
-        public long val() {
-            return val;
-        }
-    }
-
     /** Use as a "not-found" result for lookup.
      * Also used to mark deleted entries in the table.
      */
@@ -126,35 +87,30 @@
 
     /** A value for the empty scope.
      */
-    public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter);
+    public static final Scope emptyScope = new Scope(null, null, new Entry[]{});
 
     /** Construct a new scope, within scope next, with given owner, using
      *  given table. The table's length must be an exponent of 2.
      */
-    private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
+    private Scope(Scope next, Symbol owner, Entry[] table) {
         this.next = next;
         Assert.check(emptyScope == null || owner != null);
         this.owner = owner;
         this.table = table;
         this.hashMask = table.length - 1;
-        this.scopeCounter = scopeCounter;
     }
 
     /** Convenience constructor used for dup and dupUnshared. */
-    private Scope(Scope next, Symbol owner, Entry[] table) {
-        this(next, owner, table, next.scopeCounter);
-        this.nelems = next.nelems;
+    private Scope(Scope next, Symbol owner, Entry[] table, int nelems) {
+        this(next, owner, table);
+        this.nelems = nelems;
     }
 
     /** Construct a new scope, within scope next, with given owner,
      *  using a fresh table of length INITIAL_SIZE.
      */
     public Scope(Symbol owner) {
-        this(owner, dummyCounter);
-    }
-
-    protected Scope(Symbol owner, ScopeCounter scopeCounter) {
-        this(null, owner, new Entry[INITIAL_SIZE], scopeCounter);
+        this(null, owner, new Entry[INITIAL_SIZE]);
     }
 
     /** Construct a fresh scope within this scope, with same owner,
@@ -172,7 +128,7 @@
      *  of fresh tables.
      */
     public Scope dup(Symbol newOwner) {
-        Scope result = new Scope(this, newOwner, this.table);
+        Scope result = new Scope(this, newOwner, this.table, this.nelems);
         shared++;
         // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode());
         // new Error().printStackTrace(System.out);
@@ -184,7 +140,7 @@
      *  the table of its outer scope.
      */
     public Scope dupUnshared() {
-        return new Scope(this, this.owner, this.table.clone());
+        return new Scope(this, this.owner, this.table.clone(), this.nelems);
     }
 
     /** Remove all entries of this scope from its table, if shared
@@ -263,7 +219,6 @@
         Entry e = makeEntry(sym, old, elems, s, origin);
         table[hash] = e;
         elems = e;
-        scopeCounter.inc();
     }
 
     Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
@@ -278,8 +233,6 @@
         Entry e = lookup(sym.name);
         if (e.scope == null) return;
 
-        scopeCounter.inc();
-
         // remove e from table and shadowed list;
         int i = getIndex(sym.name);
         Entry te = table[i];
@@ -559,7 +512,7 @@
         public static final Entry[] emptyTable = new Entry[0];
 
         public DelegatedScope(Scope outer) {
-            super(outer, outer.owner, emptyTable, outer.scopeCounter);
+            super(outer, outer.owner, emptyTable);
             delegatee = outer;
         }
         public Scope dup() {
@@ -585,22 +538,10 @@
         }
     }
 
-    /** A class scope, for which a scope counter should be provided */
-    public static class ClassScope extends Scope {
-
-        ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
-            super(next, owner, table, scopeCounter);
-        }
-
-        public ClassScope(Symbol owner, ScopeCounter scopeCounter) {
-            super(owner, scopeCounter);
-        }
-    }
-
     /** An error scope, for which the owner should be an error symbol. */
     public static class ErrorScope extends Scope {
         ErrorScope(Scope next, Symbol errSymbol, Entry[] table) {
-            super(next, /*owner=*/errSymbol, table, dummyCounter);
+            super(next, /*owner=*/errSymbol, table);
         }
         public ErrorScope(Symbol errSymbol) {
             super(errSymbol);
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Feb 07 18:10:13 2011 +0000
@@ -729,6 +729,10 @@
          */
         public Pool pool;
 
+        /** members closure cache (set by Types.membersClosure)
+         */
+        Scope membersClosure;
+
         public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
             super(flags, name, type, owner);
             this.members_field = null;
@@ -1222,7 +1226,7 @@
             };
 
         public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
-            MethodSymbol res = types.implementation(this, origin, types, checkResult, implFilter);
+            MethodSymbol res = types.implementation(this, origin, checkResult, implFilter);
             if (res != null)
                 return res;
             // if origin is derived from a raw type, we might have missed
--- a/src/share/classes/com/sun/tools/javac/code/Symtab.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Mon Feb 07 18:10:13 2011 +0000
@@ -74,7 +74,6 @@
     public final JCNoType voidType = new JCNoType(TypeTags.VOID);
 
     private final Names names;
-    private final Scope.ScopeCounter scopeCounter;
     private final ClassReader reader;
     private final Target target;
 
@@ -343,7 +342,6 @@
         context.put(symtabKey, this);
 
         names = Names.instance(context);
-        scopeCounter = Scope.ScopeCounter.instance(context);
         target = Target.instance(context);
 
         // Create the unknown type
@@ -390,7 +388,7 @@
 
         // Create class to hold all predefined constants and operations.
         predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
-        Scope scope = new Scope.ClassScope(predefClass, scopeCounter);
+        Scope scope = new Scope(predefClass);
         predefClass.members_field = scope;
 
         // Enter symbols for basic types.
@@ -483,7 +481,7 @@
         proprietarySymbol.completer = null;
         proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
         proprietarySymbol.erasure_field = proprietaryType;
-        proprietarySymbol.members_field = new Scope.ClassScope(proprietarySymbol, scopeCounter);
+        proprietarySymbol.members_field = new Scope(proprietarySymbol);
         proprietaryType.typarams_field = List.nil();
         proprietaryType.allparams_field = List.nil();
         proprietaryType.supertype_field = annotationType;
@@ -495,7 +493,7 @@
         ClassType arrayClassType = (ClassType)arrayClass.type;
         arrayClassType.supertype_field = objectType;
         arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
-        arrayClass.members_field = new Scope.ClassScope(arrayClass, scopeCounter);
+        arrayClass.members_field = new Scope(arrayClass);
         lengthVar = new VarSymbol(
             PUBLIC | FINAL,
             names.length,
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Feb 07 18:10:13 2011 +0000
@@ -36,6 +36,7 @@
 import com.sun.tools.javac.code.Lint.LintCategory;
 import com.sun.tools.javac.comp.Check;
 
+import static com.sun.tools.javac.code.Scope.*;
 import static com.sun.tools.javac.code.Type.*;
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.code.Symbol.*;
@@ -70,7 +71,6 @@
         new Context.Key<Types>();
 
     final Symtab syms;
-    final Scope.ScopeCounter scopeCounter;
     final JavacMessages messages;
     final Names names;
     final boolean allowBoxing;
@@ -91,7 +91,6 @@
     protected Types(Context context) {
         context.put(typesKey, this);
         syms = Symtab.instance(context);
-        scopeCounter = Scope.ScopeCounter.instance(context);
         names = Names.instance(context);
         allowBoxing = Source.instance(context).allowBoxing();
         reader = ClassReader.instance(context);
@@ -2024,26 +2023,22 @@
             final MethodSymbol cachedImpl;
             final Filter<Symbol> implFilter;
             final boolean checkResult;
-            final Scope.ScopeCounter scopeCounter;
 
             public Entry(MethodSymbol cachedImpl,
                     Filter<Symbol> scopeFilter,
-                    boolean checkResult,
-                    Scope.ScopeCounter scopeCounter) {
+                    boolean checkResult) {
                 this.cachedImpl = cachedImpl;
                 this.implFilter = scopeFilter;
                 this.checkResult = checkResult;
-                this.scopeCounter = scopeCounter;
             }
 
-            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, Scope.ScopeCounter scopeCounter) {
+            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) {
                 return this.implFilter == scopeFilter &&
-                        this.checkResult == checkResult &&
-                        this.scopeCounter.val() >= scopeCounter.val();
+                        this.checkResult == checkResult;
             }
         }
 
-        MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter, Scope.ScopeCounter scopeCounter) {
+        MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
             SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
             Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
             if (cache == null) {
@@ -2052,9 +2047,9 @@
             }
             Entry e = cache.get(origin);
             if (e == null ||
-                    !e.matches(implFilter, checkResult, scopeCounter)) {
+                    !e.matches(implFilter, checkResult)) {
                 MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter);
-                cache.put(origin, new Entry(impl, implFilter, checkResult, scopeCounter));
+                cache.put(origin, new Entry(impl, implFilter, checkResult));
                 return impl;
             }
             else {
@@ -2081,9 +2076,53 @@
 
     private ImplementationCache implCache = new ImplementationCache();
 
-    public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
-        return implCache.get(ms, origin, checkResult, implFilter, scopeCounter);
+    public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
+        return implCache.get(ms, origin, checkResult, implFilter);
+    }
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
+    public Scope membersClosure(Type site) {
+        return membersClosure.visit(site);
     }
+
+    UnaryVisitor<Scope> membersClosure = new UnaryVisitor<Scope>() {
+
+        public Scope visitType(Type t, Void s) {
+            return null;
+        }
+
+        @Override
+        public Scope visitClassType(ClassType t, Void s) {
+            ClassSymbol csym = (ClassSymbol)t.tsym;
+            if (csym.membersClosure == null) {
+                Scope membersClosure = new Scope(csym);
+                for (Type i : interfaces(t)) {
+                    enterAll(visit(i), membersClosure);
+                }
+                enterAll(visit(supertype(t)), membersClosure);
+                enterAll(csym.members(), membersClosure);
+                csym.membersClosure = membersClosure;
+            }
+            return csym.membersClosure;
+        }
+
+        @Override
+        public Scope visitTypeVar(TypeVar t, Void s) {
+            return visit(t.getUpperBound());
+        }
+
+        public void enterAll(Scope s, Scope to) {
+            if (s == null) return;
+            List<Symbol> syms = List.nil();
+            for (Scope.Entry e = s.elems ; e != null ; e = e.sibling) {
+                syms = syms.prepend(e.sym);
+            }
+            for (Symbol sym : syms) {
+                to.enter(sym);
+            }
+        }
+    };
     // </editor-fold>
 
     /**
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Feb 07 18:10:13 2011 +0000
@@ -709,7 +709,11 @@
 
             // If we override any other methods, check that we do so properly.
             // JLS ???
-            chk.checkClashes(tree.pos(), env.enclClass.type, m);
+            if (m.isStatic()) {
+                chk.checkHideClashes(tree.pos(), env.enclClass.type, m);
+            } else {
+                chk.checkOverrideClashes(tree.pos(), env.enclClass.type, m);
+            }
             chk.checkOverride(tree, m);
 
             // Create a new environment with local scope
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Feb 07 18:10:13 2011 +0000
@@ -1679,7 +1679,7 @@
                             "(" + types.memberType(t2, s2).getParameterTypes() + ")");
                         return s2;
                     }
-                } else if (!checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
+                } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
                     log.error(pos,
                             "name.clash.same.erasure.no.override",
                             s1, s1.location(),
@@ -1761,18 +1761,10 @@
     }
 
     private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) {
-        if (s1.kind == MTH &&
-                    s1.isInheritedIn(origin, types) &&
-                    (s1.flags() & SYNTHETIC) == 0 &&
-                    !s2.isConstructor()) {
-            Type er1 = s2.erasure(types);
-            Type er2 = s1.erasure(types);
-            if (types.isSameTypes(er1.getParameterTypes(),
-                    er2.getParameterTypes())) {
-                    return false;
-            }
-        }
-        return true;
+        ClashFilter cf = new ClashFilter(origin.type);
+        return (cf.accepts(s1) &&
+                cf.accepts(s2) &&
+                types.hasSameArgs(s1.erasure(types), s2.erasure(types)));
     }
 
 
@@ -2111,52 +2103,82 @@
      *  @param site The class whose methods are checked.
      *  @param sym  The method symbol to be checked.
      */
-    void checkClashes(DiagnosticPosition pos, Type site, Symbol sym) {
-        List<Type> supertypes = types.closure(site);
-        for (List<Type> l = supertypes; l.nonEmpty(); l = l.tail) {
-            for (List<Type> m = supertypes; m.nonEmpty(); m = m.tail) {
-                checkClashes(pos, l.head, m.head, site, sym);
+    void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) {
+         ClashFilter cf = new ClashFilter(site);
+         //for each method m1 that is a member of 'site'...
+         for (Scope.Entry e1 = types.membersClosure(site).lookup(sym.name, cf) ;
+                e1.scope != null ; e1 = e1.next(cf)) {
+            //...find another method m2 that is overridden (directly or indirectly)
+            //by method 'sym' in 'site'
+            for (Scope.Entry e2 = types.membersClosure(site).lookup(sym.name, cf) ;
+                    e2.scope != null ; e2 = e2.next(cf)) {
+                if (e1.sym == e2.sym || !sym.overrides(e2.sym, site.tsym, types, false)) continue;
+                //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
+                //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
+                if (!types.isSubSignature(sym.type, types.memberType(site, e1.sym)) &&
+                        types.hasSameArgs(e1.sym.erasure(types), e2.sym.erasure(types))) {
+                    sym.flags_field |= CLASH;
+                    String key = e2.sym == sym ?
+                            "name.clash.same.erasure.no.override" :
+                            "name.clash.same.erasure.no.override.1";
+                    log.error(pos,
+                            key,
+                            sym, sym.location(),
+                            e1.sym, e1.sym.location(),
+                            e2.sym, e2.sym.location());
+                    return;
+                }
             }
         }
     }
 
-    /** Reports an error whenever 'sym' seen as a member of type 't1' clashes with
-     *  some unrelated method defined in 't2'.
+    /** Check that all static methods accessible from 'site' are
+     *  mutually compatible (JLS 8.4.8).
+     *
+     *  @param pos  Position to be used for error reporting.
+     *  @param site The class whose methods are checked.
+     *  @param sym  The method symbol to be checked.
      */
-    private void checkClashes(DiagnosticPosition pos, Type t1, Type t2, Type site, Symbol s1) {
+    void checkHideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) {
         ClashFilter cf = new ClashFilter(site);
-        s1 = ((MethodSymbol)s1).implementedIn(t1.tsym, types);
-        if (s1 == null) return;
-        Type st1 = types.memberType(site, s1);
-        for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name, cf); e2.scope != null; e2 = e2.next(cf)) {
-            Symbol s2 = e2.sym;
-            if (s1 == s2) continue;
-            Type st2 = types.memberType(site, s2);
-            if (!types.overrideEquivalent(st1, st2) &&
-                    !checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
+        //for each method m1 that is a member of 'site'...
+        for (Scope.Entry e = types.membersClosure(site).lookup(sym.name, cf) ;
+                e.scope != null ; e = e.next(cf)) {
+            //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
+            //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error
+            if (!types.isSubSignature(sym.type, types.memberType(site, e.sym)) &&
+                    types.hasSameArgs(e.sym.erasure(types), sym.erasure(types))) {
                 log.error(pos,
-                        "name.clash.same.erasure.no.override",
-                        s1, s1.location(),
-                        s2, s2.location());
-            }
-        }
-    }
-    //where
-    private class ClashFilter implements Filter<Symbol> {
+                        "name.clash.same.erasure.no.hide",
+                        sym, sym.location(),
+                        e.sym, e.sym.location());
+                return;
+             }
+         }
+     }
 
-        Type site;
+     //where
+     private class ClashFilter implements Filter<Symbol> {
+
+         Type site;
 
-        ClashFilter(Type site) {
-            this.site = site;
-        }
+         ClashFilter(Type site) {
+             this.site = site;
+         }
+
+         boolean shouldSkip(Symbol s) {
+             return (s.flags() & CLASH) != 0 &&
+                s.owner == site.tsym;
+         }
 
-        public boolean accepts(Symbol s) {
-            return s.kind == MTH &&
-                    (s.flags() & (SYNTHETIC | CLASH)) == 0 &&
-                    s.isInheritedIn(site.tsym, types) &&
-                    !s.isConstructor();
-        }
-    }
+         public boolean accepts(Symbol s) {
+             return s.kind == MTH &&
+                     (s.flags() & SYNTHETIC) == 0 &&
+                     !shouldSkip(s) &&
+                     s.isInheritedIn(site.tsym, types) &&
+                     !s.isConstructor();
+         }
+     }
 
     /** Report a conflict between a user symbol and a synthetic symbol.
      */
@@ -2638,10 +2660,10 @@
         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)))) {
+                    (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)) {
                     varargsDuplicateError(pos, sym, e.sym);
                     return true;
@@ -2667,13 +2689,13 @@
             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);
-            }
+    /** 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/Enter.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java	Mon Feb 07 18:10:13 2011 +0000
@@ -95,7 +95,6 @@
 
     Log log;
     Symtab syms;
-    Scope.ScopeCounter scopeCounter;
     Check chk;
     TreeMaker make;
     ClassReader reader;
@@ -123,7 +122,6 @@
         reader = ClassReader.instance(context);
         make = TreeMaker.instance(context);
         syms = Symtab.instance(context);
-        scopeCounter = Scope.ScopeCounter.instance(context);
         chk = Check.instance(context);
         memberEnter = MemberEnter.instance(context);
         types = Types.instance(context);
@@ -192,7 +190,7 @@
      */
     public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) {
         Env<AttrContext> localEnv =
-            env.dup(tree, env.info.dup(new Scope.ClassScope(tree.sym, scopeCounter)));
+            env.dup(tree, env.info.dup(new Scope(tree.sym)));
         localEnv.enclClass = tree;
         localEnv.outer = env;
         localEnv.info.isSelfCall = false;
@@ -328,7 +326,7 @@
             c.flatname = names.fromString(tree.packge + "." + name);
             c.sourcefile = tree.sourcefile;
             c.completer = null;
-            c.members_field = new Scope.ClassScope(c, scopeCounter);
+            c.members_field = new Scope(c);
             tree.packge.package_info = c;
         }
         classEnter(tree.defs, topEnv);
@@ -396,7 +394,7 @@
         c.completer = memberEnter;
         c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree);
         c.sourcefile = env.toplevel.sourcefile;
-        c.members_field = new Scope.ClassScope(c, scopeCounter);
+        c.members_field = new Scope(c);
 
         ClassType ct = (ClassType)c.type;
         if (owner.kind != PCK && (c.flags_field & STATIC) == 0) {
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Feb 07 18:10:13 2011 +0000
@@ -68,7 +68,6 @@
     private Names names;
     private Log log;
     private Symtab syms;
-    private Scope.ScopeCounter scopeCounter;
     private Resolve rs;
     private Check chk;
     private Attr attr;
@@ -91,7 +90,6 @@
         names = Names.instance(context);
         log = Log.instance(context);
         syms = Symtab.instance(context);
-        scopeCounter = Scope.ScopeCounter.instance(context);
         rs = Resolve.instance(context);
         chk = Check.instance(context);
         attr = Attr.instance(context);
@@ -571,7 +569,7 @@
         c.flatname = chk.localClassName(c);
         c.sourcefile = owner.sourcefile;
         c.completer = null;
-        c.members_field = new Scope.ClassScope(c, scopeCounter);
+        c.members_field = new Scope(c);
         c.flags_field = flags;
         ClassType ctype = (ClassType) c.type;
         ctype.supertype_field = syms.objectType;
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Feb 07 18:10:13 2011 +0000
@@ -67,7 +67,6 @@
     private final Check chk;
     private final Attr attr;
     private final Symtab syms;
-    private final Scope.ScopeCounter scopeCounter;
     private final TreeMaker make;
     private final ClassReader reader;
     private final Todo todo;
@@ -94,7 +93,6 @@
         chk = Check.instance(context);
         attr = Attr.instance(context);
         syms = Symtab.instance(context);
-        scopeCounter = Scope.ScopeCounter.instance(context);
         make = TreeMaker.instance(context);
         reader = ClassReader.instance(context);
         todo = Todo.instance(context);
@@ -1023,7 +1021,7 @@
     }
 
     private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
-        Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter);
+        Scope baseScope = new Scope(tree.sym);
         //import already entered local classes into base scope
         for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) {
             if (e.sym.isLocal()) {
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Feb 07 18:10:13 2011 +0000
@@ -138,9 +138,6 @@
     /** The symbol table. */
     Symtab syms;
 
-    /** The scope counter */
-    Scope.ScopeCounter scopeCounter;
-
     Types types;
 
     /** The name table. */
@@ -264,7 +261,6 @@
 
         names = Names.instance(context);
         syms = Symtab.instance(context);
-        scopeCounter = Scope.ScopeCounter.instance(context);
         types = Types.instance(context);
         fileManager = context.get(JavaFileManager.class);
         if (fileManager == null)
@@ -1881,7 +1877,7 @@
         ClassType ct = (ClassType)c.type;
 
         // allocate scope for members
-        c.members_field = new Scope.ClassScope(c, scopeCounter);
+        c.members_field = new Scope(c);
 
         // prepare type variable table
         typevars = typevars.dup(currentOwner);
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Feb 07 18:09:46 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Feb 07 18:10:13 2011 +0000
@@ -521,10 +521,20 @@
 compiler.err.name.clash.same.erasure=\
     name clash: {0} and {1} have the same erasure
 
-# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: unused, 5: unused
 compiler.err.name.clash.same.erasure.no.override=\
     name clash: {0} in {1} and {2} in {3} have the same erasure, yet neither overrides the other
 
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: symbol, 5: symbol
+compiler.err.name.clash.same.erasure.no.override.1=\
+    name clash: {0} in {1} overrides a method whose erasure is the same as another method, yet neither overrides the other\n\
+    first method:  {2} in {3}\n\
+    second method: {4} in {5}
+
+# 0: symbol, 1: symbol, 2: symbol, 3: symbol
+compiler.err.name.clash.same.erasure.no.hide=\
+    name clash: {0} in {1} and {2} in {3} have the same erasure, yet neither hides the other
+
 compiler.err.name.reserved.for.internal.use=\
     {0} is reserved for internal use
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NameClashSameErasureNoHide.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,34 @@
+/*
+ * 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.err.name.clash.same.erasure.no.hide
+
+public class NameClashSameErasureNoHide<X> {
+    static class A {
+        static void m(NameClashSameErasureNoHide<String> l) {}
+    }
+
+    static class B extends A {
+        static void m(NameClashSameErasureNoHide<Integer> l) {}
+    }
+}
--- a/test/tools/javac/diags/examples/NameClashSameErasureNoOverride.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/diags/examples/NameClashSameErasureNoOverride.java	Mon Feb 07 18:10:13 2011 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -25,10 +25,10 @@
 
 public class NameClashSameErasureNoOverride<X> {
     static class A {
-        static void m(NameClashSameErasureNoOverride<String> l) {}
+        void m(NameClashSameErasureNoOverride<String> l) {}
     }
 
     static class B extends A {
-        static void m(NameClashSameErasureNoOverride<Integer> l) {}
+        void m(NameClashSameErasureNoOverride<Integer> l) {}
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NameClashSameErasureNoOverride1.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,39 @@
+/*
+ * 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.err.name.clash.same.erasure.no.override.1
+
+public class NameClashSameErasureNoOverride1 {
+
+    interface I<X> {
+        void m(X l);
+    }
+
+    class A {
+        void m(Object l) {}
+    }
+
+    class B extends A implements I<Integer> {
+        public void m(Integer l) {}
+    }
+}
--- a/test/tools/javac/generics/5009937/T5009937.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/5009937/T5009937.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-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
+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
 1 error
--- a/test/tools/javac/generics/6182950/T6182950b.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6182950/T6182950b.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-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
+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
 1 error
--- a/test/tools/javac/generics/6476118/T6476118a.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6476118/T6476118a.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-T6476118a.java:14:20: compiler.err.name.clash.same.erasure.no.override: compareTo(T), java.lang.Comparable, compareTo(java.lang.Object), T6476118a.A
+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
 1 error
--- a/test/tools/javac/generics/6476118/T6476118b.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6476118/T6476118b.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-T6476118b.java:12:20: compiler.err.name.clash.same.erasure.no.override: compareTo(T), java.lang.Comparable, compareTo(java.lang.Object), T6476118b
+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
 1 error
--- a/test/tools/javac/generics/6476118/T6476118c.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6476118/T6476118c.java	Mon Feb 07 18:10:13 2011 +0000
@@ -5,7 +5,7 @@
  * @compile/fail/ref=T6476118c.out -XDrawDiagnostics T6476118c.java
  */
 
-class T6476118b {
+class T6476118c {
     static class A<T> {
         public void foo(T t) { }
     }
--- a/test/tools/javac/generics/6476118/T6476118c.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6476118/T6476118c.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,3 +1,3 @@
-T6476118c.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Object), T6476118b.C, foo(T), T6476118b.A
-T6476118c.java:19:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6476118b.C, foo(T), T6476118b.B
+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
+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
 2 errors
--- a/test/tools/javac/generics/6985719/T6985719e.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6985719/T6985719e.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-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
+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
 1 error
--- a/test/tools/javac/generics/6985719/T6985719f.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6985719/T6985719f.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-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
+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
 1 error
--- a/test/tools/javac/generics/6985719/T6985719g.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6985719/T6985719g.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-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
+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
 1 error
--- a/test/tools/javac/generics/6985719/T6985719h.out	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/generics/6985719/T6985719h.out	Mon Feb 07 18:10:13 2011 +0000
@@ -1,2 +1,2 @@
-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
+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
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/T7007615.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7007615
+ * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
+ * @author  mcimadamore
+ * @compile/fail/ref=T7007615.out -XDrawDiagnostics T7007615.java
+ */
+
+class T6985719a {
+    class AX<T extends Number> {
+        void foo(T t) { }
+    }
+
+    class BX<S extends Integer> extends AX<S> {
+        @Override
+        void foo(S t) { }
+        void bar(BX bx){}
+    }
+
+    class DX extends BX<Integer> {
+        void foo(Number t) { }
+        void bar(BX<?> bx) { }
+
+        @Override
+        void foo(Integer t) { }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/T7007615.out	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,3 @@
+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
+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
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc1/AccessibilityCheck01.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7007615
+ * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
+ * @author  dlsmith
+ * @compile AccessibilityCheck01.java
+ */
+
+public class AccessibilityCheck01 extends p2.E {
+  String m(Object o) { return "hi"; } // this is okay
+  int m(String s) { return 3; } // this overrides m(String) illegally
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc1/p1/C.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,25 @@
+/*
+ * 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<T> { void m(T arg) { } /* implicit: m(Object) */ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc1/p1/D.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,25 @@
+/*
+ * 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 D<T> extends C<T> { /* inherits m(T), implicit m(Object) */ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc1/p2/E.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,25 @@
+/*
+ * 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 p2;
+public class E<T> extends p1.D<T> { /* inherits nothing */ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7007615
+ * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
+ * @author  dlsmith
+ * @compile/fail/ref=AccessibilityCheck02.out -XDrawDiagnostics AccessibilityCheck02.java
+ */
+
+public class AccessibilityCheck02 extends p2.E {
+  String m(Object o) { return "hi"; } // this is okay
+  public int m(String s) { return 3; } // this overrides m(String) illegally
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc2/AccessibilityCheck02.out	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,2 @@
+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
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc2/p1/C.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,25 @@
+/*
+ * 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<T> { void m(T arg) { } /* implicit: m(Object) */ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc2/p1/D.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,25 @@
+/*
+ * 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 D extends C<String> { public void m(String arg) {} /* implicit bridge: m(Object) */ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/7007615/acc2/p2/E.java	Mon Feb 07 18:10:13 2011 +0000
@@ -0,0 +1,25 @@
+/*
+ * 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 p2;
+public class E extends p1.D { /* inherits m(String) but not m(Object) */ }
--- a/test/tools/javac/scope/HashCollisionTest.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/scope/HashCollisionTest.java	Mon Feb 07 18:10:13 2011 +0000
@@ -47,7 +47,6 @@
         JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
         names = Names.instance(context);       // Name.Table impls tied to an instance of Names
         symtab = Symtab.instance(context);
-        scopeCounter = ScopeCounter.instance(context);
 
         // determine hashMask for an empty scope
         Scope emptyScope = new Scope(symtab.unnamedPackage); // any owner will do
@@ -171,7 +170,7 @@
      */
     ClassSymbol createClass(Name name, Symbol owner) {
         ClassSymbol sym = new ClassSymbol(0, name, owner);
-        sym.members_field = new ClassScope(sym, scopeCounter);
+        sym.members_field = new Scope(sym);
         if (owner != symtab.unnamedPackage)
             owner.members().enter(sym);
         return sym;
@@ -247,5 +246,4 @@
 
     Names names;
     Symtab symtab;
-    ScopeCounter scopeCounter;
 }
--- a/test/tools/javac/scope/StarImportTest.java	Mon Feb 07 18:09:46 2011 +0000
+++ b/test/tools/javac/scope/StarImportTest.java	Mon Feb 07 18:10:13 2011 +0000
@@ -136,7 +136,6 @@
             JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab
             names = Names.instance(context);       // Name.Table impls tied to an instance of Names
             symtab = Symtab.instance(context);
-            scopeCounter = ScopeCounter.instance(context);
             int setupCount = rgen.nextInt(MAX_SETUP_COUNT);
             for (int i = 0; i < setupCount; i++) {
                 switch (random(SetupKind.values())) {
@@ -303,7 +302,7 @@
 
         ClassSymbol createClass(Name name, Symbol owner) {
             ClassSymbol sym = new ClassSymbol(0, name, owner);
-            sym.members_field = new ClassScope(sym, scopeCounter);
+            sym.members_field = new Scope(sym);
             if (owner != symtab.unnamedPackage)
                 owner.members().enter(sym);
             return sym;
@@ -311,7 +310,6 @@
 
         Context context;
         Symtab symtab;
-        ScopeCounter scopeCounter;
         Names names;
         int nextNameSerial;
         List<PackageSymbol> packages = new ArrayList<PackageSymbol>();