1.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Mar 12 21:44:46 2014 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Mar 19 16:44:49 2014 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -467,11 +467,24 @@ 1.11 1.12 private boolean hiddenIn(ClassSymbol clazz, Types types) { 1.13 Symbol sym = hiddenInInternal(clazz, types); 1.14 - return sym != null && sym != this; 1.15 + Assert.check(sym != null, "the result of hiddenInInternal() can't be null"); 1.16 + /* If we find the current symbol then there is no symbol hiding it 1.17 + */ 1.18 + return sym != this; 1.19 } 1.20 1.21 - private Symbol hiddenInInternal(ClassSymbol c, Types types) { 1.22 - Scope.Entry e = c.members().lookup(name); 1.23 + /** This method looks in the supertypes graph that has the current class as the 1.24 + * initial node, till it finds the current symbol or another symbol that hides it. 1.25 + * If the current class has more than one supertype (extends one class and 1.26 + * implements one or more interfaces) then null can be returned, meaning that 1.27 + * a wrong path in the supertypes graph was selected. Null can only be returned 1.28 + * as a temporary value, as a result of the recursive call. 1.29 + */ 1.30 + private Symbol hiddenInInternal(ClassSymbol currentClass, Types types) { 1.31 + if (currentClass == owner) { 1.32 + return this; 1.33 + } 1.34 + Scope.Entry e = currentClass.members().lookup(name); 1.35 while (e.scope != null) { 1.36 if (e.sym.kind == kind && 1.37 (kind != MTH || 1.38 @@ -481,18 +494,19 @@ 1.39 } 1.40 e = e.next(); 1.41 } 1.42 - List<Symbol> hiddenSyms = List.nil(); 1.43 - for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) { 1.44 + Symbol hiddenSym = null; 1.45 + for (Type st : types.interfaces(currentClass.type) 1.46 + .prepend(types.supertype(currentClass.type))) { 1.47 if (st != null && (st.hasTag(CLASS))) { 1.48 Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types); 1.49 - if (sym != null) { 1.50 - hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types)); 1.51 + if (sym == this) { 1.52 + return this; 1.53 + } else if (sym != null) { 1.54 + hiddenSym = sym; 1.55 } 1.56 } 1.57 } 1.58 - return hiddenSyms.contains(this) ? 1.59 - this : 1.60 - (hiddenSyms.isEmpty() ? null : hiddenSyms.head); 1.61 + return hiddenSym; 1.62 } 1.63 1.64 /** Is this symbol inherited into a given class?