This commit is contained in:
Lana Steuck 2010-12-12 21:58:56 -08:00
commit 1cf7cebcc8
6 changed files with 39 additions and 37 deletions

View File

@ -51,16 +51,16 @@ import com.sun.tools.javac.parser.DocCommentScanner;
* or deletion without notice.</b>
*/
@SuppressWarnings("deprecation")
public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
/** The context key for the compiler. */
protected static final Context.Key<JavaCompiler> compilerKey =
new Context.Key<JavaCompiler>();
protected static final Context.Key<AptJavaCompiler> compilerKey =
new Context.Key<AptJavaCompiler>();
/** Get the JavaCompiler instance for this context. */
public static JavaCompiler instance(Context context) {
JavaCompiler instance = context.get(compilerKey);
public static AptJavaCompiler instance(Context context) {
AptJavaCompiler instance = context.get(compilerKey);
if (instance == null)
instance = new JavaCompiler(context);
instance = new AptJavaCompiler(context);
return instance;
}
@ -107,7 +107,7 @@ public class JavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
/** Construct a new compiler from a shared context.
*/
public JavaCompiler(Context context) {
public AptJavaCompiler(Context context) {
super(preRegister(context));
context.put(compilerKey, this);

View File

@ -421,7 +421,7 @@ public class Main {
},
new AptOption("-version", "opt.version") {
boolean process(String option) {
Bark.printLines(out, ownName + " " + JavaCompiler.version());
Bark.printLines(out, ownName + " " + AptJavaCompiler.version());
return super.process(option);
}
},
@ -1111,11 +1111,11 @@ public class Main {
}
int exitCode = EXIT_OK;
JavaCompiler comp = null;
AptJavaCompiler comp = null;
try {
context.put(Bark.outKey, out);
comp = JavaCompiler.instance(context);
comp = AptJavaCompiler.instance(context);
if (comp == null)
return EXIT_SYSERR;
@ -1184,7 +1184,7 @@ public class Main {
*/
void bugMessage(Throwable ex) {
Bark.printLines(out, getLocalizedString("msg.bug",
JavaCompiler.version()));
AptJavaCompiler.version()));
ex.printStackTrace(out);
}

View File

@ -120,7 +120,7 @@ public class FilerImpl implements Filer {
private final Options opts;
private final DeclarationMaker declMaker;
private final com.sun.tools.apt.main.JavaCompiler comp;
private final com.sun.tools.apt.main.AptJavaCompiler comp;
// Platform's default encoding
private final static String DEFAULT_ENCODING =
@ -177,7 +177,7 @@ public class FilerImpl implements Filer {
opts = Options.instance(context);
declMaker = DeclarationMaker.instance(context);
bark = Bark.instance(context);
comp = com.sun.tools.apt.main.JavaCompiler.instance(context);
comp = com.sun.tools.apt.main.AptJavaCompiler.instance(context);
roundOver = false;
this.filesCreated = comp.getAggregateGenFiles();

View File

@ -245,7 +245,7 @@ public class Type implements PrimitiveType {
public String argtypes(boolean varargs) {
List<Type> args = getParameterTypes();
if (!varargs) return args.toString();
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
while (args.tail.nonEmpty()) {
buf.append(args.head);
args = args.tail;
@ -935,7 +935,7 @@ public class Type implements PrimitiveType {
public static class TypeVar extends Type implements TypeVariable {
/** The bound of this type variable; set from outside.
/** The upper bound of this type variable; set from outside.
* Must be nonempty once it is set.
* For a bound, `bound' is the bound type itself.
* Multiple bounds are expressed as a single class type which has the
@ -946,6 +946,12 @@ public class Type implements PrimitiveType {
* points to the first class or interface bound.
*/
public Type bound = null;
/** The lower bound of this type variable.
* TypeVars don't normally have a lower bound, so it is normally set
* to syms.botType.
* Subtypes, such as CapturedType, may provide a different value.
*/
public Type lower;
public TypeVar(Name name, Symbol owner, Type lower) {
@ -965,10 +971,12 @@ public class Type implements PrimitiveType {
return v.visitTypeVar(this, s);
}
@Override
public Type getUpperBound() { return bound; }
int rank_field = -1;
@Override
public Type getLowerBound() {
return lower;
}
@ -992,7 +1000,6 @@ public class Type implements PrimitiveType {
*/
public static class CapturedType extends TypeVar {
public Type lower;
public WildcardType wildcard;
public CapturedType(Name name,
@ -1012,10 +1019,6 @@ public class Type implements PrimitiveType {
return v.visitCapturedType(this, s);
}
public Type getLowerBound() {
return lower;
}
@Override
public boolean isCaptured() {
return true;

View File

@ -641,7 +641,7 @@ public class Types {
if (!set.remove(new SingletonType(x)))
return false;
}
return (set.size() == 0);
return (set.isEmpty());
}
return t.tsym == s.tsym
&& visit(t.getEnclosingType(), s.getEnclosingType())
@ -838,26 +838,26 @@ public class Types {
return isSameType(t, s);
}
void debugContainsType(WildcardType t, Type s) {
System.err.println();
System.err.format(" does %s contain %s?%n", t, s);
System.err.format(" %s U(%s) <: U(%s) %s = %s%n",
upperBound(s), s, t, U(t),
t.isSuperBound()
|| isSubtypeNoCapture(upperBound(s), U(t)));
System.err.format(" %s L(%s) <: L(%s) %s = %s%n",
L(t), t, s, lowerBound(s),
t.isExtendsBound()
|| isSubtypeNoCapture(L(t), lowerBound(s)));
System.err.println();
}
// void debugContainsType(WildcardType t, Type s) {
// System.err.println();
// System.err.format(" does %s contain %s?%n", t, s);
// System.err.format(" %s U(%s) <: U(%s) %s = %s%n",
// upperBound(s), s, t, U(t),
// t.isSuperBound()
// || isSubtypeNoCapture(upperBound(s), U(t)));
// System.err.format(" %s L(%s) <: L(%s) %s = %s%n",
// L(t), t, s, lowerBound(s),
// t.isExtendsBound()
// || isSubtypeNoCapture(L(t), lowerBound(s)));
// System.err.println();
// }
@Override
public Boolean visitWildcardType(WildcardType t, Type s) {
if (s.tag >= firstPartialTag)
return containedBy(s, t);
else {
// debugContainsType(t, s);
// debugContainsType(t, s);
return isSameWildcard(t, s)
|| isCaptureOf(s, t)
|| ((t.isExtendsBound() || isSubtypeNoCapture(L(t), lowerBound(s))) &&

View File

@ -197,7 +197,7 @@ public class Resolve {
}
return (checkInner == false || c.type.getEnclosingType() == Type.noType) ?
isAccessible :
isAccessible & isAccessible(env, c.type.getEnclosingType(), checkInner);
isAccessible && isAccessible(env, c.type.getEnclosingType(), checkInner);
}
//where
/** Is given class a subclass of given base class, or an inner class
@ -234,7 +234,6 @@ public class Resolve {
}
public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym, boolean checkInner) {
if (sym.name == names.init && sym.owner != site.tsym) return false;
ClassSymbol sub;
switch ((short)(sym.flags() & AccessFlags)) {
case PRIVATE:
return