Fri, 28 Sep 2012 16:56:53 +0100
8000233: Fix issues in recent push
Summary: Forgot to incorporate review comments in pushed changesets
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Wed Sep 26 14:22:41 2012 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Fri Sep 28 16:56:53 2012 +0100 1.3 @@ -27,18 +27,19 @@ 1.4 1.5 import java.util.Collections; 1.6 1.7 +import com.sun.tools.javac.code.Symbol.*; 1.8 import com.sun.tools.javac.util.*; 1.9 -import com.sun.tools.javac.code.Symbol.*; 1.10 1.11 import java.util.EnumMap; 1.12 import java.util.EnumSet; 1.13 import java.util.Map; 1.14 import java.util.Set; 1.15 + 1.16 import javax.lang.model.type.*; 1.17 1.18 +import static com.sun.tools.javac.code.BoundKind.*; 1.19 import static com.sun.tools.javac.code.Flags.*; 1.20 import static com.sun.tools.javac.code.Kinds.*; 1.21 -import static com.sun.tools.javac.code.BoundKind.*; 1.22 import static com.sun.tools.javac.code.TypeTags.*; 1.23 1.24 /** This class represents Java types. The class itself defines the behavior of
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Sep 26 14:22:41 2012 +0100 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Sep 28 16:56:53 2012 +0100 2.3 @@ -27,8 +27,8 @@ 2.4 2.5 import com.sun.tools.javac.api.Formattable.LocalizedString; 2.6 import com.sun.tools.javac.code.*; 2.7 +import com.sun.tools.javac.code.Symbol.*; 2.8 import com.sun.tools.javac.code.Type.*; 2.9 -import com.sun.tools.javac.code.Symbol.*; 2.10 import com.sun.tools.javac.comp.Attr.ResultInfo; 2.11 import com.sun.tools.javac.comp.Check.CheckContext; 2.12 import com.sun.tools.javac.comp.Infer.InferenceContext; 2.13 @@ -48,6 +48,7 @@ 2.14 import java.util.EnumMap; 2.15 import java.util.EnumSet; 2.16 import java.util.HashSet; 2.17 +import java.util.Iterator; 2.18 import java.util.Map; 2.19 import java.util.Set; 2.20 2.21 @@ -60,7 +61,6 @@ 2.22 import static com.sun.tools.javac.code.TypeTags.*; 2.23 import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*; 2.24 import static com.sun.tools.javac.tree.JCTree.Tag.*; 2.25 -import java.util.Iterator; 2.26 2.27 /** Helper class for name resolution, used mostly by the attribution phase. 2.28 * 2.29 @@ -1200,7 +1200,10 @@ 2.30 for (TypeSymbol s : superclasses(intype)) { 2.31 bestSoFar = lookupMethod(env, site, name, argtypes, typeargtypes, 2.32 s.members(), bestSoFar, allowBoxing, useVarargs, operator, true); 2.33 - abstractOk &= excludeAbstractsFilter.accepts(s); 2.34 + //We should not look for abstract methods if receiver is a concrete class 2.35 + //(as concrete classes are expected to implement all abstracts coming 2.36 + //from superinterfaces) 2.37 + abstractOk &= (s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0; 2.38 if (abstractOk) { 2.39 for (Type itype : types.interfaces(s.type)) { 2.40 itypes = types.union(types.closure(itype), itypes); 2.41 @@ -1247,36 +1250,41 @@ 2.42 return new Iterator<TypeSymbol>() { 2.43 2.44 List<TypeSymbol> seen = List.nil(); 2.45 - TypeSymbol currentSym = getSymbol(intype); 2.46 + TypeSymbol currentSym = symbolFor(intype); 2.47 + TypeSymbol prevSym = null; 2.48 2.49 public boolean hasNext() { 2.50 + if (currentSym == syms.noSymbol) { 2.51 + currentSym = symbolFor(types.supertype(prevSym.type)); 2.52 + } 2.53 return currentSym != null; 2.54 } 2.55 2.56 public TypeSymbol next() { 2.57 - TypeSymbol prevSym = currentSym; 2.58 - currentSym = getSymbol(types.supertype(currentSym.type)); 2.59 + prevSym = currentSym; 2.60 + currentSym = syms.noSymbol; 2.61 + Assert.check(prevSym != null || prevSym != syms.noSymbol); 2.62 return prevSym; 2.63 } 2.64 2.65 public void remove() { 2.66 - throw new UnsupportedOperationException("Not supported yet."); 2.67 + throw new UnsupportedOperationException(); 2.68 } 2.69 2.70 - TypeSymbol getSymbol(Type intype) { 2.71 - if (intype.tag != CLASS && 2.72 - intype.tag != TYPEVAR) { 2.73 + TypeSymbol symbolFor(Type t) { 2.74 + if (t.tag != CLASS && 2.75 + t.tag != TYPEVAR) { 2.76 return null; 2.77 } 2.78 - while (intype.tag == TYPEVAR) 2.79 - intype = intype.getUpperBound(); 2.80 - if (seen.contains(intype.tsym)) { 2.81 + while (t.tag == TYPEVAR) 2.82 + t = t.getUpperBound(); 2.83 + if (seen.contains(t.tsym)) { 2.84 //degenerate case in which we have a circular 2.85 //class hierarchy - because of ill-formed classfiles 2.86 return null; 2.87 } 2.88 - seen = seen.prepend(intype.tsym); 2.89 - return intype.tsym; 2.90 + seen = seen.prepend(t.tsym); 2.91 + return t.tsym; 2.92 } 2.93 }; 2.94 } 2.95 @@ -1284,17 +1292,6 @@ 2.96 } 2.97 2.98 /** 2.99 - * We should not look for abstract methods if receiver is a concrete class 2.100 - * (as concrete classes are expected to implement all abstracts coming 2.101 - * from superinterfaces) 2.102 - */ 2.103 - Filter<Symbol> excludeAbstractsFilter = new Filter<Symbol>() { 2.104 - public boolean accepts(Symbol s) { 2.105 - return (s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0; 2.106 - } 2.107 - }; 2.108 - 2.109 - /** 2.110 * Lookup a method with given name and argument types in a given scope 2.111 */ 2.112 Symbol lookupMethod(Env<AttrContext> env,
3.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Pool.java Wed Sep 26 14:22:41 2012 +0100 3.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Pool.java Fri Sep 28 16:56:53 2012 +0100 3.3 @@ -27,17 +27,17 @@ 3.4 3.5 import com.sun.tools.javac.code.Flags; 3.6 import com.sun.tools.javac.code.Kinds; 3.7 -import java.util.*; 3.8 - 3.9 import com.sun.tools.javac.code.Symbol; 3.10 import com.sun.tools.javac.code.Symbol.*; 3.11 import com.sun.tools.javac.code.Type; 3.12 -import com.sun.tools.javac.util.ArrayUtils; 3.13 + 3.14 import com.sun.tools.javac.util.Assert; 3.15 import com.sun.tools.javac.util.Filter; 3.16 import com.sun.tools.javac.util.Name; 3.17 import com.sun.tools.javac.util.Names; 3.18 3.19 +import java.util.*; 3.20 + 3.21 /** An internal structure that corresponds to the constant pool of a classfile. 3.22 * 3.23 * <p><b>This is NOT part of any supported API. 3.24 @@ -177,13 +177,9 @@ 3.25 /** Reference symbol */ 3.26 Symbol refSym; 3.27 3.28 - /** Reference to the name table */ 3.29 - Names names; 3.30 - 3.31 - public MethodHandle(int refKind, Symbol refSym, Names names) { 3.32 + public MethodHandle(int refKind, Symbol refSym) { 3.33 this.refKind = refKind; 3.34 this.refSym = refSym; 3.35 - this.names = names; 3.36 checkConsistent(); 3.37 } 3.38 public boolean equals(Object other) { 3.39 @@ -244,13 +240,13 @@ 3.40 //where 3.41 Filter<Name> nonInitFilter = new Filter<Name>() { 3.42 public boolean accepts(Name n) { 3.43 - return n != names.init && n != names.clinit; 3.44 + return n != n.table.names.init && n != n.table.names.clinit; 3.45 } 3.46 }; 3.47 3.48 Filter<Name> initFilter = new Filter<Name>() { 3.49 public boolean accepts(Name n) { 3.50 - return n == names.init; 3.51 + return n == n.table.names.init; 3.52 } 3.53 }; 3.54 }
4.1 --- a/src/share/classes/com/sun/tools/javac/util/Names.java Wed Sep 26 14:22:41 2012 +0100 4.2 +++ b/src/share/classes/com/sun/tools/javac/util/Names.java Fri Sep 28 16:56:53 2012 +0100 4.3 @@ -118,6 +118,7 @@ 4.4 // attribute names 4.5 public final Name Annotation; 4.6 public final Name AnnotationDefault; 4.7 + public final Name BootstrapMethods; 4.8 public final Name Bridge; 4.9 public final Name CharacterRangeTable; 4.10 public final Name Code; 4.11 @@ -169,9 +170,6 @@ 4.12 public final Name ex; 4.13 public final Name package_info; 4.14 4.15 - // lambda-related 4.16 - public final Name BootstrapMethods; 4.17 - 4.18 public final Name.Table table; 4.19 4.20 public Names(Context context) { 4.21 @@ -249,6 +247,7 @@ 4.22 // attribute names 4.23 Annotation = fromString("Annotation"); 4.24 AnnotationDefault = fromString("AnnotationDefault"); 4.25 + BootstrapMethods = fromString("BootstrapMethods"); 4.26 Bridge = fromString("Bridge"); 4.27 CharacterRangeTable = fromString("CharacterRangeTable"); 4.28 Code = fromString("Code"); 4.29 @@ -299,9 +298,6 @@ 4.30 deprecated = fromString("deprecated"); 4.31 ex = fromString("ex"); 4.32 package_info = fromString("package-info"); 4.33 - 4.34 - //lambda-related 4.35 - BootstrapMethods = fromString("BootstrapMethods"); 4.36 } 4.37 4.38 protected Name.Table createTable(Options options) {