8000233: Fix issues in recent push

Forgot to incorporate review comments in pushed changesets

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2012-09-28 16:56:53 +01:00
parent 5f629e503c
commit 7f58c7c7ad
4 changed files with 34 additions and 44 deletions

View File

@ -27,18 +27,19 @@ package com.sun.tools.javac.code;
import java.util.Collections;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.util.*;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
import javax.lang.model.type.*;
import static com.sun.tools.javac.code.BoundKind.*;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
import static com.sun.tools.javac.code.BoundKind.*;
import static com.sun.tools.javac.code.TypeTags.*;
/** This class represents Java types. The class itself defines the behavior of

View File

@ -27,8 +27,8 @@ package com.sun.tools.javac.comp;
import com.sun.tools.javac.api.Formattable.LocalizedString;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.comp.Attr.ResultInfo;
import com.sun.tools.javac.comp.Check.CheckContext;
import com.sun.tools.javac.comp.Infer.InferenceContext;
@ -48,6 +48,7 @@ import java.util.Collection;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -60,7 +61,6 @@ import static com.sun.tools.javac.code.Kinds.ERRONEOUS;
import static com.sun.tools.javac.code.TypeTags.*;
import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
import java.util.Iterator;
/** Helper class for name resolution, used mostly by the attribution phase.
*
@ -1200,7 +1200,10 @@ public class Resolve {
for (TypeSymbol s : superclasses(intype)) {
bestSoFar = lookupMethod(env, site, name, argtypes, typeargtypes,
s.members(), bestSoFar, allowBoxing, useVarargs, operator, true);
abstractOk &= excludeAbstractsFilter.accepts(s);
//We should not look for abstract methods if receiver is a concrete class
//(as concrete classes are expected to implement all abstracts coming
//from superinterfaces)
abstractOk &= (s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0;
if (abstractOk) {
for (Type itype : types.interfaces(s.type)) {
itypes = types.union(types.closure(itype), itypes);
@ -1247,53 +1250,47 @@ public class Resolve {
return new Iterator<TypeSymbol>() {
List<TypeSymbol> seen = List.nil();
TypeSymbol currentSym = getSymbol(intype);
TypeSymbol currentSym = symbolFor(intype);
TypeSymbol prevSym = null;
public boolean hasNext() {
if (currentSym == syms.noSymbol) {
currentSym = symbolFor(types.supertype(prevSym.type));
}
return currentSym != null;
}
public TypeSymbol next() {
TypeSymbol prevSym = currentSym;
currentSym = getSymbol(types.supertype(currentSym.type));
prevSym = currentSym;
currentSym = syms.noSymbol;
Assert.check(prevSym != null || prevSym != syms.noSymbol);
return prevSym;
}
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
throw new UnsupportedOperationException();
}
TypeSymbol getSymbol(Type intype) {
if (intype.tag != CLASS &&
intype.tag != TYPEVAR) {
TypeSymbol symbolFor(Type t) {
if (t.tag != CLASS &&
t.tag != TYPEVAR) {
return null;
}
while (intype.tag == TYPEVAR)
intype = intype.getUpperBound();
if (seen.contains(intype.tsym)) {
while (t.tag == TYPEVAR)
t = t.getUpperBound();
if (seen.contains(t.tsym)) {
//degenerate case in which we have a circular
//class hierarchy - because of ill-formed classfiles
return null;
}
seen = seen.prepend(intype.tsym);
return intype.tsym;
seen = seen.prepend(t.tsym);
return t.tsym;
}
};
}
};
}
/**
* We should not look for abstract methods if receiver is a concrete class
* (as concrete classes are expected to implement all abstracts coming
* from superinterfaces)
*/
Filter<Symbol> excludeAbstractsFilter = new Filter<Symbol>() {
public boolean accepts(Symbol s) {
return (s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0;
}
};
/**
* Lookup a method with given name and argument types in a given scope
*/

View File

@ -27,17 +27,17 @@ package com.sun.tools.javac.jvm;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Kinds;
import java.util.*;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.util.ArrayUtils;
import com.sun.tools.javac.util.Assert;
import com.sun.tools.javac.util.Filter;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Names;
import java.util.*;
/** An internal structure that corresponds to the constant pool of a classfile.
*
* <p><b>This is NOT part of any supported API.
@ -177,13 +177,9 @@ public class Pool {
/** Reference symbol */
Symbol refSym;
/** Reference to the name table */
Names names;
public MethodHandle(int refKind, Symbol refSym, Names names) {
public MethodHandle(int refKind, Symbol refSym) {
this.refKind = refKind;
this.refSym = refSym;
this.names = names;
checkConsistent();
}
public boolean equals(Object other) {
@ -244,13 +240,13 @@ public class Pool {
//where
Filter<Name> nonInitFilter = new Filter<Name>() {
public boolean accepts(Name n) {
return n != names.init && n != names.clinit;
return n != n.table.names.init && n != n.table.names.clinit;
}
};
Filter<Name> initFilter = new Filter<Name>() {
public boolean accepts(Name n) {
return n == names.init;
return n == n.table.names.init;
}
};
}

View File

@ -118,6 +118,7 @@ public class Names {
// attribute names
public final Name Annotation;
public final Name AnnotationDefault;
public final Name BootstrapMethods;
public final Name Bridge;
public final Name CharacterRangeTable;
public final Name Code;
@ -169,9 +170,6 @@ public class Names {
public final Name ex;
public final Name package_info;
// lambda-related
public final Name BootstrapMethods;
public final Name.Table table;
public Names(Context context) {
@ -249,6 +247,7 @@ public class Names {
// attribute names
Annotation = fromString("Annotation");
AnnotationDefault = fromString("AnnotationDefault");
BootstrapMethods = fromString("BootstrapMethods");
Bridge = fromString("Bridge");
CharacterRangeTable = fromString("CharacterRangeTable");
Code = fromString("Code");
@ -299,9 +298,6 @@ public class Names {
deprecated = fromString("deprecated");
ex = fromString("ex");
package_info = fromString("package-info");
//lambda-related
BootstrapMethods = fromString("BootstrapMethods");
}
protected Name.Table createTable(Options options) {