Merge
This commit is contained in:
commit
b670ed41d6
@ -66,7 +66,7 @@ javac.no.jdk.warnings = -XDignore.symbol.file=true
|
|||||||
# set the following to -version to verify the versions of javac being used
|
# set the following to -version to verify the versions of javac being used
|
||||||
javac.version.opt =
|
javac.version.opt =
|
||||||
# in time, there should be no exceptions to -Xlint:all
|
# in time, there should be no exceptions to -Xlint:all
|
||||||
javac.lint.opts = -Xlint:all,-deprecation,-fallthrough,-serial,-unchecked,-cast
|
javac.lint.opts = -Xlint:all,-deprecation,-fallthrough,-serial,-unchecked,-cast,-rawtypes
|
||||||
|
|
||||||
# options for the <javadoc> task for javac
|
# options for the <javadoc> task for javac
|
||||||
javadoc.jls3.url=http://java.sun.com/docs/books/jls/
|
javadoc.jls3.url=http://java.sun.com/docs/books/jls/
|
||||||
|
@ -474,23 +474,22 @@ public class JavacTaskImpl extends JavacTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Filter {
|
abstract class Filter {
|
||||||
void run(ListBuffer<Env<AttrContext>> list, Iterable<? extends TypeElement> classes) {
|
void run(Queue<Env<AttrContext>> list, Iterable<? extends TypeElement> classes) {
|
||||||
Set<TypeElement> set = new HashSet<TypeElement>();
|
Set<TypeElement> set = new HashSet<TypeElement>();
|
||||||
for (TypeElement item: classes)
|
for (TypeElement item: classes)
|
||||||
set.add(item);
|
set.add(item);
|
||||||
|
|
||||||
List<Env<AttrContext>> defer = List.<Env<AttrContext>>nil();
|
ListBuffer<Env<AttrContext>> defer = ListBuffer.<Env<AttrContext>>lb();
|
||||||
while (list.nonEmpty()) {
|
while (list.peek() != null) {
|
||||||
Env<AttrContext> env = list.next();
|
Env<AttrContext> env = list.remove();
|
||||||
ClassSymbol csym = env.enclClass.sym;
|
ClassSymbol csym = env.enclClass.sym;
|
||||||
if (csym != null && set.contains(csym.outermostClass()))
|
if (csym != null && set.contains(csym.outermostClass()))
|
||||||
process(env);
|
process(env);
|
||||||
else
|
else
|
||||||
defer = defer.prepend(env);
|
defer = defer.append(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (List<Env<AttrContext>> l = defer; l.nonEmpty(); l = l.tail)
|
list.addAll(defer);
|
||||||
list.prepend(l.head);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void process(Env<AttrContext> env);
|
abstract void process(Env<AttrContext> env);
|
||||||
|
@ -175,6 +175,11 @@ public class Lint
|
|||||||
*/
|
*/
|
||||||
PATH("path"),
|
PATH("path"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warn about issues regarding annotation processing.
|
||||||
|
*/
|
||||||
|
PROCESSING("processing"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warn about Serializable classes that do not provide a serial version ID.
|
* Warn about Serializable classes that do not provide a serial version ID.
|
||||||
*/
|
*/
|
||||||
@ -183,7 +188,12 @@ public class Lint
|
|||||||
/**
|
/**
|
||||||
* Warn about unchecked operations on raw types.
|
* Warn about unchecked operations on raw types.
|
||||||
*/
|
*/
|
||||||
UNCHECKED("unchecked");
|
UNCHECKED("unchecked"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warn about unchecked operations on raw types.
|
||||||
|
*/
|
||||||
|
RAW("rawtypes");
|
||||||
|
|
||||||
LintCategory(String option) {
|
LintCategory(String option) {
|
||||||
this.option = option;
|
this.option = option;
|
||||||
|
@ -132,6 +132,10 @@ public abstract class Symbol implements Element {
|
|||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitSymbol(this, p);
|
||||||
|
}
|
||||||
|
|
||||||
/** The Java source which this symbol represents.
|
/** The Java source which this symbol represents.
|
||||||
* A description of this symbol; overrides Object.
|
* A description of this symbol; overrides Object.
|
||||||
*/
|
*/
|
||||||
@ -477,6 +481,10 @@ public abstract class Symbol implements Element {
|
|||||||
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
|
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
|
||||||
return other.accept(v, p);
|
return other.accept(v, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitSymbol(other, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A class for type symbols. Type variables are represented by instances
|
/** A class for type symbols. Type variables are represented by instances
|
||||||
@ -570,6 +578,10 @@ public abstract class Symbol implements Element {
|
|||||||
return v.visitTypeParameter(this, p);
|
return v.visitTypeParameter(this, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitTypeSymbol(this, p);
|
||||||
|
}
|
||||||
|
|
||||||
public List<Type> getBounds() {
|
public List<Type> getBounds() {
|
||||||
TypeVar t = (TypeVar)type;
|
TypeVar t = (TypeVar)type;
|
||||||
Type bound = t.getUpperBound();
|
Type bound = t.getUpperBound();
|
||||||
@ -653,6 +665,10 @@ public abstract class Symbol implements Element {
|
|||||||
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
|
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
|
||||||
return v.visitPackage(this, p);
|
return v.visitPackage(this, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitPackageSymbol(this, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A class for class symbols
|
/** A class for class symbols
|
||||||
@ -843,6 +859,10 @@ public abstract class Symbol implements Element {
|
|||||||
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
|
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
|
||||||
return v.visitType(this, p);
|
return v.visitType(this, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitClassSymbol(this, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -969,6 +989,10 @@ public abstract class Symbol implements Element {
|
|||||||
assert !(data instanceof Env<?>) : this;
|
assert !(data instanceof Env<?>) : this;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitVarSymbol(this, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A class for method symbols.
|
/** A class for method symbols.
|
||||||
@ -1232,6 +1256,10 @@ public abstract class Symbol implements Element {
|
|||||||
return v.visitExecutable(this, p);
|
return v.visitExecutable(this, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitMethodSymbol(this, p);
|
||||||
|
}
|
||||||
|
|
||||||
public Type getReturnType() {
|
public Type getReturnType() {
|
||||||
return asType().getReturnType();
|
return asType().getReturnType();
|
||||||
}
|
}
|
||||||
@ -1251,6 +1279,10 @@ public abstract class Symbol implements Element {
|
|||||||
super(PUBLIC | STATIC, name, type, owner);
|
super(PUBLIC | STATIC, name, type, owner);
|
||||||
this.opcode = opcode;
|
this.opcode = opcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
|
||||||
|
return v.visitOperatorSymbol(this, p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Symbol completer interface.
|
/** Symbol completer interface.
|
||||||
@ -1308,4 +1340,28 @@ public abstract class Symbol implements Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A visitor for symbols. A visitor is used to implement operations
|
||||||
|
* (or relations) on symbols. Most common operations on types are
|
||||||
|
* binary relations and this interface is designed for binary
|
||||||
|
* relations, that is, operations on the form
|
||||||
|
* Symbol × P → R.
|
||||||
|
* <!-- In plain text: Type x P -> R -->
|
||||||
|
*
|
||||||
|
* @param <R> the return type of the operation implemented by this
|
||||||
|
* visitor; use Void if no return type is needed.
|
||||||
|
* @param <P> the type of the second argument (the first being the
|
||||||
|
* symbol itself) of the operation implemented by this visitor; use
|
||||||
|
* Void if a second argument is not needed.
|
||||||
|
*/
|
||||||
|
public interface Visitor<R,P> {
|
||||||
|
R visitClassSymbol(ClassSymbol s, P arg);
|
||||||
|
R visitMethodSymbol(MethodSymbol s, P arg);
|
||||||
|
R visitPackageSymbol(PackageSymbol s, P arg);
|
||||||
|
R visitOperatorSymbol(OperatorSymbol s, P arg);
|
||||||
|
R visitVarSymbol(VarSymbol s, P arg);
|
||||||
|
R visitTypeSymbol(TypeSymbol s, P arg);
|
||||||
|
R visitSymbol(Symbol s, P arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ public class Types {
|
|||||||
new Context.Key<Types>();
|
new Context.Key<Types>();
|
||||||
|
|
||||||
final Symtab syms;
|
final Symtab syms;
|
||||||
|
final Messages messages;
|
||||||
final Names names;
|
final Names names;
|
||||||
final boolean allowBoxing;
|
final boolean allowBoxing;
|
||||||
final ClassReader reader;
|
final ClassReader reader;
|
||||||
@ -92,6 +93,7 @@ public class Types {
|
|||||||
source = Source.instance(context);
|
source = Source.instance(context);
|
||||||
chk = Check.instance(context);
|
chk = Check.instance(context);
|
||||||
capturedName = names.fromString("<captured wildcard>");
|
capturedName = names.fromString("<captured wildcard>");
|
||||||
|
messages = Messages.instance(context);
|
||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
@ -2249,10 +2251,234 @@ public class Types {
|
|||||||
}
|
}
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="printType">
|
||||||
|
/**
|
||||||
|
* Visitor for generating a string representation of a given type
|
||||||
|
* accordingly to a given locale
|
||||||
|
*/
|
||||||
|
public String toString(Type t, Locale locale) {
|
||||||
|
return typePrinter.visit(t, locale);
|
||||||
|
}
|
||||||
|
// where
|
||||||
|
private TypePrinter typePrinter = new TypePrinter();
|
||||||
|
|
||||||
|
public class TypePrinter extends DefaultTypeVisitor<String, Locale> {
|
||||||
|
|
||||||
|
public String visit(List<Type> ts, Locale locale) {
|
||||||
|
ListBuffer<String> sbuf = lb();
|
||||||
|
for (Type t : ts) {
|
||||||
|
sbuf.append(visit(t, locale));
|
||||||
|
}
|
||||||
|
return sbuf.toList().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitCapturedType(CapturedType t, Locale locale) {
|
||||||
|
return messages.getLocalizedString("compiler.misc.type.captureof",
|
||||||
|
(t.hashCode() & 0xFFFFFFFFL) % Type.CapturedType.PRIME,
|
||||||
|
visit(t.wildcard, locale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitForAll(ForAll t, Locale locale) {
|
||||||
|
return "<" + visit(t.tvars, locale) + ">" + visit(t.qtype, locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitUndetVar(UndetVar t, Locale locale) {
|
||||||
|
if (t.inst != null) {
|
||||||
|
return visit(t.inst, locale);
|
||||||
|
} else {
|
||||||
|
return visit(t.qtype, locale) + "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitArrayType(ArrayType t, Locale locale) {
|
||||||
|
return visit(t.elemtype, locale) + "[]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitClassType(ClassType t, Locale locale) {
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
if (t.getEnclosingType().tag == CLASS && t.tsym.owner.kind == Kinds.TYP) {
|
||||||
|
buf.append(visit(t.getEnclosingType(), locale));
|
||||||
|
buf.append(".");
|
||||||
|
buf.append(className(t, false, locale));
|
||||||
|
} else {
|
||||||
|
buf.append(className(t, true, locale));
|
||||||
|
}
|
||||||
|
if (t.getTypeArguments().nonEmpty()) {
|
||||||
|
buf.append('<');
|
||||||
|
buf.append(visit(t.getTypeArguments(), locale));
|
||||||
|
buf.append(">");
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitMethodType(MethodType t, Locale locale) {
|
||||||
|
return "(" + printMethodArgs(t.argtypes, false, locale) + ")" + visit(t.restype, locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitPackageType(PackageType t, Locale locale) {
|
||||||
|
return t.tsym.getQualifiedName().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitWildcardType(WildcardType t, Locale locale) {
|
||||||
|
StringBuffer s = new StringBuffer();
|
||||||
|
s.append(t.kind);
|
||||||
|
if (t.kind != UNBOUND) {
|
||||||
|
s.append(visit(t.type, locale));
|
||||||
|
}
|
||||||
|
return s.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String visitType(Type t, Locale locale) {
|
||||||
|
String s = (t.tsym == null || t.tsym.name == null)
|
||||||
|
? messages.getLocalizedString("compiler.misc.type.none")
|
||||||
|
: t.tsym.name.toString();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String className(ClassType t, boolean longform, Locale locale) {
|
||||||
|
Symbol sym = t.tsym;
|
||||||
|
if (sym.name.length() == 0 && (sym.flags() & COMPOUND) != 0) {
|
||||||
|
StringBuffer s = new StringBuffer(visit(supertype(t), locale));
|
||||||
|
for (List<Type> is = interfaces(t); is.nonEmpty(); is = is.tail) {
|
||||||
|
s.append("&");
|
||||||
|
s.append(visit(is.head, locale));
|
||||||
|
}
|
||||||
|
return s.toString();
|
||||||
|
} else if (sym.name.length() == 0) {
|
||||||
|
String s;
|
||||||
|
ClassType norm = (ClassType) t.tsym.type;
|
||||||
|
if (norm == null) {
|
||||||
|
s = getLocalizedString(locale, "compiler.misc.anonymous.class", (Object) null);
|
||||||
|
} else if (interfaces(norm).nonEmpty()) {
|
||||||
|
s = getLocalizedString(locale, "compiler.misc.anonymous.class",
|
||||||
|
visit(interfaces(norm).head, locale));
|
||||||
|
} else {
|
||||||
|
s = getLocalizedString(locale, "compiler.misc.anonymous.class",
|
||||||
|
visit(supertype(norm), locale));
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
} else if (longform) {
|
||||||
|
return sym.getQualifiedName().toString();
|
||||||
|
} else {
|
||||||
|
return sym.name.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String printMethodArgs(List<Type> args, boolean varArgs, Locale locale) {
|
||||||
|
if (!varArgs) {
|
||||||
|
return visit(args, locale);
|
||||||
|
} else {
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
while (args.tail.nonEmpty()) {
|
||||||
|
buf.append(visit(args.head, locale));
|
||||||
|
args = args.tail;
|
||||||
|
buf.append(',');
|
||||||
|
}
|
||||||
|
if (args.head.tag == ARRAY) {
|
||||||
|
buf.append(visit(((ArrayType) args.head).elemtype, locale));
|
||||||
|
buf.append("...");
|
||||||
|
} else {
|
||||||
|
buf.append(visit(args.head, locale));
|
||||||
|
}
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getLocalizedString(Locale locale, String key, Object... args) {
|
||||||
|
return messages.getLocalizedString(key, args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// </editor-fold>
|
||||||
|
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="printSymbol">
|
||||||
|
/**
|
||||||
|
* Visitor for generating a string representation of a given symbol
|
||||||
|
* accordingly to a given locale
|
||||||
|
*/
|
||||||
|
public String toString(Symbol t, Locale locale) {
|
||||||
|
return symbolPrinter.visit(t, locale);
|
||||||
|
}
|
||||||
|
// where
|
||||||
|
private SymbolPrinter symbolPrinter = new SymbolPrinter();
|
||||||
|
|
||||||
|
public class SymbolPrinter extends DefaultSymbolVisitor<String, Locale> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitClassSymbol(ClassSymbol sym, Locale locale) {
|
||||||
|
return sym.name.isEmpty()
|
||||||
|
? getLocalizedString(locale, "compiler.misc.anonymous.class", sym.flatname)
|
||||||
|
: sym.fullname.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitMethodSymbol(MethodSymbol s, Locale locale) {
|
||||||
|
if ((s.flags() & BLOCK) != 0) {
|
||||||
|
return s.owner.name.toString();
|
||||||
|
} else {
|
||||||
|
String ms = (s.name == names.init)
|
||||||
|
? s.owner.name.toString()
|
||||||
|
: s.name.toString();
|
||||||
|
if (s.type != null) {
|
||||||
|
if (s.type.tag == FORALL) {
|
||||||
|
ms = "<" + typePrinter.visit(s.type.getTypeArguments(), locale) + ">" + ms;
|
||||||
|
}
|
||||||
|
ms += "(" + typePrinter.printMethodArgs(
|
||||||
|
s.type.getParameterTypes(),
|
||||||
|
(s.flags() & VARARGS) != 0,
|
||||||
|
locale) + ")";
|
||||||
|
}
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitOperatorSymbol(OperatorSymbol s, Locale locale) {
|
||||||
|
return visitMethodSymbol(s, locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitPackageSymbol(PackageSymbol s, Locale locale) {
|
||||||
|
return s.name.isEmpty()
|
||||||
|
? getLocalizedString(locale, "compiler.misc.unnamed.package")
|
||||||
|
: s.fullname.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String visitSymbol(Symbol s, Locale locale) {
|
||||||
|
return s.name.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String visit(List<Symbol> ts, Locale locale) {
|
||||||
|
ListBuffer<String> sbuf = lb();
|
||||||
|
for (Symbol t : ts) {
|
||||||
|
sbuf.append(visit(t, locale));
|
||||||
|
}
|
||||||
|
return sbuf.toList().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getLocalizedString(Locale locale, String key, Object... args) {
|
||||||
|
return messages.getLocalizedString(key, args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// </editor-fold>
|
||||||
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="toString">
|
// <editor-fold defaultstate="collapsed" desc="toString">
|
||||||
/**
|
/**
|
||||||
* This toString is slightly more descriptive than the one on Type.
|
* This toString is slightly more descriptive than the one on Type.
|
||||||
|
*
|
||||||
|
* @deprecated Types.toString(Type t, Locale l) provides better support
|
||||||
|
* for localization
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public String toString(Type t) {
|
public String toString(Type t) {
|
||||||
if (t.tag == FORALL) {
|
if (t.tag == FORALL) {
|
||||||
ForAll forAll = (ForAll)t;
|
ForAll forAll = (ForAll)t;
|
||||||
@ -3235,6 +3461,28 @@ public class Types {
|
|||||||
public R visitErrorType(ErrorType t, S s) { return visitType(t, s); }
|
public R visitErrorType(ErrorType t, S s) { return visitType(t, s); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A default visitor for symbols. All visitor methods except
|
||||||
|
* visitSymbol are implemented by delegating to visitSymbol. Concrete
|
||||||
|
* subclasses must provide an implementation of visitSymbol and can
|
||||||
|
* override other methods as needed.
|
||||||
|
*
|
||||||
|
* @param <R> the return type of the operation implemented by this
|
||||||
|
* visitor; use Void if no return type is needed.
|
||||||
|
* @param <S> the type of the second argument (the first being the
|
||||||
|
* symbol itself) of the operation implemented by this visitor; use
|
||||||
|
* Void if a second argument is not needed.
|
||||||
|
*/
|
||||||
|
public static abstract class DefaultSymbolVisitor<R,S> implements Symbol.Visitor<R,S> {
|
||||||
|
final public R visit(Symbol s, S arg) { return s.accept(this, arg); }
|
||||||
|
public R visitClassSymbol(ClassSymbol s, S arg) { return visitSymbol(s, arg); }
|
||||||
|
public R visitMethodSymbol(MethodSymbol s, S arg) { return visitSymbol(s, arg); }
|
||||||
|
public R visitOperatorSymbol(OperatorSymbol s, S arg) { return visitSymbol(s, arg); }
|
||||||
|
public R visitPackageSymbol(PackageSymbol s, S arg) { return visitSymbol(s, arg); }
|
||||||
|
public R visitTypeSymbol(TypeSymbol s, S arg) { return visitSymbol(s, arg); }
|
||||||
|
public R visitVarSymbol(VarSymbol s, S arg) { return visitSymbol(s, arg); }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <em>simple</em> visitor for types. This visitor is simple as
|
* A <em>simple</em> visitor for types. This visitor is simple as
|
||||||
* captured wildcards, for-all types (generic methods), and
|
* captured wildcards, for-all types (generic methods), and
|
||||||
|
@ -614,14 +614,14 @@ public class Attr extends JCTree.Visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that type parameters are well-formed.
|
// Check that type parameters are well-formed.
|
||||||
chk.validateTypeParams(tree.typarams);
|
chk.validate(tree.typarams, localEnv);
|
||||||
if ((owner.flags() & ANNOTATION) != 0 &&
|
if ((owner.flags() & ANNOTATION) != 0 &&
|
||||||
tree.typarams.nonEmpty())
|
tree.typarams.nonEmpty())
|
||||||
log.error(tree.typarams.head.pos(),
|
log.error(tree.typarams.head.pos(),
|
||||||
"intf.annotation.members.cant.have.type.params");
|
"intf.annotation.members.cant.have.type.params");
|
||||||
|
|
||||||
// Check that result type is well-formed.
|
// Check that result type is well-formed.
|
||||||
chk.validate(tree.restype);
|
chk.validate(tree.restype, localEnv);
|
||||||
if ((owner.flags() & ANNOTATION) != 0)
|
if ((owner.flags() & ANNOTATION) != 0)
|
||||||
chk.validateAnnotationType(tree.restype);
|
chk.validateAnnotationType(tree.restype);
|
||||||
|
|
||||||
@ -707,7 +707,7 @@ public class Attr extends JCTree.Visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check that the variable's declared type is well-formed.
|
// Check that the variable's declared type is well-formed.
|
||||||
chk.validate(tree.vartype);
|
chk.validate(tree.vartype, env);
|
||||||
|
|
||||||
VarSymbol v = tree.sym;
|
VarSymbol v = tree.sym;
|
||||||
Lint lint = env.info.lint.augment(v.attributes_field, v.flags());
|
Lint lint = env.info.lint.augment(v.attributes_field, v.flags());
|
||||||
@ -1322,7 +1322,7 @@ public class Attr extends JCTree.Visitor {
|
|||||||
// current context. Also, capture the return type
|
// current context. Also, capture the return type
|
||||||
result = check(tree, capture(restype), VAL, pkind, pt);
|
result = check(tree, capture(restype), VAL, pkind, pt);
|
||||||
}
|
}
|
||||||
chk.validate(tree.typeargs);
|
chk.validate(tree.typeargs, localEnv);
|
||||||
}
|
}
|
||||||
//where
|
//where
|
||||||
/** Check that given application node appears as first statement
|
/** Check that given application node appears as first statement
|
||||||
@ -1397,7 +1397,7 @@ public class Attr extends JCTree.Visitor {
|
|||||||
// symbol + type back into the attributed tree.
|
// symbol + type back into the attributed tree.
|
||||||
Type clazztype = chk.checkClassType(
|
Type clazztype = chk.checkClassType(
|
||||||
tree.clazz.pos(), attribType(clazz, env), true);
|
tree.clazz.pos(), attribType(clazz, env), true);
|
||||||
chk.validate(clazz);
|
chk.validate(clazz, localEnv);
|
||||||
if (tree.encl != null) {
|
if (tree.encl != null) {
|
||||||
// We have to work in this case to store
|
// We have to work in this case to store
|
||||||
// symbol + type back into the attributed tree.
|
// symbol + type back into the attributed tree.
|
||||||
@ -1533,7 +1533,7 @@ public class Attr extends JCTree.Visitor {
|
|||||||
owntype = clazztype;
|
owntype = clazztype;
|
||||||
}
|
}
|
||||||
result = check(tree, owntype, VAL, pkind, pt);
|
result = check(tree, owntype, VAL, pkind, pt);
|
||||||
chk.validate(tree.typeargs);
|
chk.validate(tree.typeargs, localEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make an attributed null check tree.
|
/** Make an attributed null check tree.
|
||||||
@ -1555,7 +1555,7 @@ public class Attr extends JCTree.Visitor {
|
|||||||
Type elemtype;
|
Type elemtype;
|
||||||
if (tree.elemtype != null) {
|
if (tree.elemtype != null) {
|
||||||
elemtype = attribType(tree.elemtype, env);
|
elemtype = attribType(tree.elemtype, env);
|
||||||
chk.validate(tree.elemtype);
|
chk.validate(tree.elemtype, env);
|
||||||
owntype = elemtype;
|
owntype = elemtype;
|
||||||
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
|
for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
|
||||||
attribExpr(l.head, env, syms.intType);
|
attribExpr(l.head, env, syms.intType);
|
||||||
@ -1711,6 +1711,7 @@ public class Attr extends JCTree.Visitor {
|
|||||||
|
|
||||||
public void visitTypeCast(JCTypeCast tree) {
|
public void visitTypeCast(JCTypeCast tree) {
|
||||||
Type clazztype = attribType(tree.clazz, env);
|
Type clazztype = attribType(tree.clazz, env);
|
||||||
|
chk.validate(tree.clazz, env);
|
||||||
Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly);
|
Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly);
|
||||||
Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
|
Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
|
||||||
if (exprtype.constValue() != null)
|
if (exprtype.constValue() != null)
|
||||||
@ -1723,6 +1724,7 @@ public class Attr extends JCTree.Visitor {
|
|||||||
tree.expr.pos(), attribExpr(tree.expr, env));
|
tree.expr.pos(), attribExpr(tree.expr, env));
|
||||||
Type clazztype = chk.checkReifiableReferenceType(
|
Type clazztype = chk.checkReifiableReferenceType(
|
||||||
tree.clazz.pos(), attribType(tree.clazz, env));
|
tree.clazz.pos(), attribType(tree.clazz, env));
|
||||||
|
chk.validate(tree.clazz, env);
|
||||||
chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
|
chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
|
||||||
result = check(tree, syms.booleanType, VAL, pkind, pt);
|
result = check(tree, syms.booleanType, VAL, pkind, pt);
|
||||||
}
|
}
|
||||||
@ -2695,9 +2697,9 @@ public class Attr extends JCTree.Visitor {
|
|||||||
|
|
||||||
// Validate type parameters, supertype and interfaces.
|
// Validate type parameters, supertype and interfaces.
|
||||||
attribBounds(tree.typarams);
|
attribBounds(tree.typarams);
|
||||||
chk.validateTypeParams(tree.typarams);
|
chk.validate(tree.typarams, env);
|
||||||
chk.validate(tree.extending);
|
chk.validate(tree.extending, env);
|
||||||
chk.validate(tree.implementing);
|
chk.validate(tree.implementing, env);
|
||||||
|
|
||||||
// If this is a non-abstract class, check that it has no abstract
|
// If this is a non-abstract class, check that it has no abstract
|
||||||
// methods or unimplemented methods of an implemented interface.
|
// methods or unimplemented methods of an implemented interface.
|
||||||
|
@ -764,26 +764,32 @@ public class Check {
|
|||||||
/** Visitor method: Validate a type expression, if it is not null, catching
|
/** Visitor method: Validate a type expression, if it is not null, catching
|
||||||
* and reporting any completion failures.
|
* and reporting any completion failures.
|
||||||
*/
|
*/
|
||||||
void validate(JCTree tree) {
|
void validate(JCTree tree, Env<AttrContext> env) {
|
||||||
try {
|
try {
|
||||||
if (tree != null) tree.accept(validator);
|
if (tree != null) {
|
||||||
|
validator.env = env;
|
||||||
|
tree.accept(validator);
|
||||||
|
checkRaw(tree, env);
|
||||||
|
}
|
||||||
} catch (CompletionFailure ex) {
|
} catch (CompletionFailure ex) {
|
||||||
completionError(tree.pos(), ex);
|
completionError(tree.pos(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//where
|
||||||
|
void checkRaw(JCTree tree, Env<AttrContext> env) {
|
||||||
|
if (lint.isEnabled(Lint.LintCategory.RAW) &&
|
||||||
|
tree.type.tag == CLASS &&
|
||||||
|
!env.enclClass.name.isEmpty() && //anonymous or intersection
|
||||||
|
tree.type.isRaw()) {
|
||||||
|
log.warning(tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Visitor method: Validate a list of type expressions.
|
/** Visitor method: Validate a list of type expressions.
|
||||||
*/
|
*/
|
||||||
void validate(List<? extends JCTree> trees) {
|
void validate(List<? extends JCTree> trees, Env<AttrContext> env) {
|
||||||
for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
|
for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
|
||||||
validate(l.head);
|
validate(l.head, env);
|
||||||
}
|
|
||||||
|
|
||||||
/** Visitor method: Validate a list of type parameters.
|
|
||||||
*/
|
|
||||||
void validateTypeParams(List<JCTypeParameter> trees) {
|
|
||||||
for (List<JCTypeParameter> l = trees; l.nonEmpty(); l = l.tail)
|
|
||||||
validate(l.head);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A visitor class for type validation.
|
/** A visitor class for type validation.
|
||||||
@ -791,7 +797,7 @@ public class Check {
|
|||||||
class Validator extends JCTree.Visitor {
|
class Validator extends JCTree.Visitor {
|
||||||
|
|
||||||
public void visitTypeArray(JCArrayTypeTree tree) {
|
public void visitTypeArray(JCArrayTypeTree tree) {
|
||||||
validate(tree.elemtype);
|
validate(tree.elemtype, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitTypeApply(JCTypeApply tree) {
|
public void visitTypeApply(JCTypeApply tree) {
|
||||||
@ -805,7 +811,7 @@ public class Check {
|
|||||||
// For matching pairs of actual argument types `a' and
|
// For matching pairs of actual argument types `a' and
|
||||||
// formal type parameters with declared bound `b' ...
|
// formal type parameters with declared bound `b' ...
|
||||||
while (args.nonEmpty() && forms.nonEmpty()) {
|
while (args.nonEmpty() && forms.nonEmpty()) {
|
||||||
validate(args.head);
|
validate(args.head, env);
|
||||||
|
|
||||||
// exact type arguments needs to know their
|
// exact type arguments needs to know their
|
||||||
// bounds (for upper and lower bound
|
// bounds (for upper and lower bound
|
||||||
@ -849,14 +855,14 @@ public class Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void visitTypeParameter(JCTypeParameter tree) {
|
public void visitTypeParameter(JCTypeParameter tree) {
|
||||||
validate(tree.bounds);
|
validate(tree.bounds, env);
|
||||||
checkClassBounds(tree.pos(), tree.type);
|
checkClassBounds(tree.pos(), tree.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitWildcard(JCWildcard tree) {
|
public void visitWildcard(JCWildcard tree) {
|
||||||
if (tree.inner != null)
|
if (tree.inner != null)
|
||||||
validate(tree.inner);
|
validate(tree.inner, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitSelect(JCFieldAccess tree) {
|
public void visitSelect(JCFieldAccess tree) {
|
||||||
@ -870,7 +876,7 @@ public class Check {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void visitSelectInternal(JCFieldAccess tree) {
|
public void visitSelectInternal(JCFieldAccess tree) {
|
||||||
if (tree.type.getEnclosingType().tag != CLASS &&
|
if (tree.type.tsym.isStatic() &&
|
||||||
tree.selected.type.isParameterized()) {
|
tree.selected.type.isParameterized()) {
|
||||||
// The enclosing type is not a class, so we are
|
// The enclosing type is not a class, so we are
|
||||||
// looking at a static member type. However, the
|
// looking at a static member type. However, the
|
||||||
@ -878,7 +884,7 @@ public class Check {
|
|||||||
log.error(tree.pos(), "cant.select.static.class.from.param.type");
|
log.error(tree.pos(), "cant.select.static.class.from.param.type");
|
||||||
} else {
|
} else {
|
||||||
// otherwise validate the rest of the expression
|
// otherwise validate the rest of the expression
|
||||||
validate(tree.selected);
|
tree.selected.accept(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,6 +892,8 @@ public class Check {
|
|||||||
*/
|
*/
|
||||||
public void visitTree(JCTree tree) {
|
public void visitTree(JCTree tree) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Env<AttrContext> env;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *************************************************************************
|
/* *************************************************************************
|
||||||
|
@ -25,7 +25,14 @@
|
|||||||
|
|
||||||
package com.sun.tools.javac.comp;
|
package com.sun.tools.javac.comp;
|
||||||
|
|
||||||
import com.sun.tools.javac.util.*;
|
import java.util.AbstractQueue;
|
||||||
|
import com.sun.tools.javac.util.Context;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
|
import javax.tools.JavaFileObject;
|
||||||
|
|
||||||
/** A queue of all as yet unattributed classes.
|
/** A queue of all as yet unattributed classes.
|
||||||
*
|
*
|
||||||
@ -34,7 +41,7 @@ import com.sun.tools.javac.util.*;
|
|||||||
* This code and its internal interfaces are subject to change or
|
* This code and its internal interfaces are subject to change or
|
||||||
* deletion without notice.</b>
|
* deletion without notice.</b>
|
||||||
*/
|
*/
|
||||||
public class Todo extends ListBuffer<Env<AttrContext>> {
|
public class Todo extends AbstractQueue<Env<AttrContext>> {
|
||||||
/** The context key for the todo list. */
|
/** The context key for the todo list. */
|
||||||
protected static final Context.Key<Todo> todoKey =
|
protected static final Context.Key<Todo> todoKey =
|
||||||
new Context.Key<Todo>();
|
new Context.Key<Todo>();
|
||||||
@ -51,4 +58,115 @@ public class Todo extends ListBuffer<Env<AttrContext>> {
|
|||||||
protected Todo(Context context) {
|
protected Todo(Context context) {
|
||||||
context.put(todoKey, this);
|
context.put(todoKey, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void append(Env<AttrContext> env) {
|
||||||
|
add(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Env<AttrContext>> iterator() {
|
||||||
|
return contents.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return contents.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean offer(Env<AttrContext> e) {
|
||||||
|
if (contents.add(e)) {
|
||||||
|
if (contentsByFile != null)
|
||||||
|
addByFile(e);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Env<AttrContext> poll() {
|
||||||
|
if (size() == 0)
|
||||||
|
return null;
|
||||||
|
Env<AttrContext> env = contents.remove(0);
|
||||||
|
if (contentsByFile != null)
|
||||||
|
removeByFile(env);
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Env<AttrContext> peek() {
|
||||||
|
return (size() == 0 ? null : contents.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Queue<Queue<Env<AttrContext>>> groupByFile() {
|
||||||
|
if (contentsByFile == null) {
|
||||||
|
contentsByFile = new LinkedList<Queue<Env<AttrContext>>>();
|
||||||
|
for (Env<AttrContext> env: contents) {
|
||||||
|
addByFile(env);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return contentsByFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addByFile(Env<AttrContext> env) {
|
||||||
|
JavaFileObject file = env.toplevel.sourcefile;
|
||||||
|
if (fileMap == null)
|
||||||
|
fileMap = new HashMap<JavaFileObject, FileQueue>();
|
||||||
|
FileQueue fq = fileMap.get(file);
|
||||||
|
if (fq == null) {
|
||||||
|
fq = new FileQueue();
|
||||||
|
fileMap.put(file, fq);
|
||||||
|
contentsByFile.add(fq);
|
||||||
|
}
|
||||||
|
fq.fileContents.add(env);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeByFile(Env<AttrContext> env) {
|
||||||
|
JavaFileObject file = env.toplevel.sourcefile;
|
||||||
|
FileQueue fq = fileMap.get(file);
|
||||||
|
if (fq == null)
|
||||||
|
return;
|
||||||
|
if (fq.fileContents.remove(env)) {
|
||||||
|
if (fq.isEmpty()) {
|
||||||
|
fileMap.remove(file);
|
||||||
|
contentsByFile.remove(fq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LinkedList<Env<AttrContext>> contents = new LinkedList<Env<AttrContext>>();
|
||||||
|
LinkedList<Queue<Env<AttrContext>>> contentsByFile;
|
||||||
|
Map<JavaFileObject, FileQueue> fileMap;
|
||||||
|
|
||||||
|
class FileQueue extends AbstractQueue<Env<AttrContext>> {
|
||||||
|
@Override
|
||||||
|
public Iterator<Env<AttrContext>> iterator() {
|
||||||
|
return fileContents.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return fileContents.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean offer(Env<AttrContext> e) {
|
||||||
|
if (fileContents.offer(e)) {
|
||||||
|
contents.add(e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Env<AttrContext> poll() {
|
||||||
|
if (fileContents.size() == 0)
|
||||||
|
return null;
|
||||||
|
Env<AttrContext> env = fileContents.remove(0);
|
||||||
|
contents.remove(env);
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Env<AttrContext> peek() {
|
||||||
|
return (fileContents.size() == 0 ? null : fileContents.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
LinkedList<Env<AttrContext>> fileContents = new LinkedList<Env<AttrContext>>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ public class TransTypes extends TreeTranslator {
|
|||||||
tree.truepart = translate(tree.truepart, erasure(tree.type));
|
tree.truepart = translate(tree.truepart, erasure(tree.type));
|
||||||
tree.falsepart = translate(tree.falsepart, erasure(tree.type));
|
tree.falsepart = translate(tree.falsepart, erasure(tree.type));
|
||||||
tree.type = erasure(tree.type);
|
tree.type = erasure(tree.type);
|
||||||
result = tree;
|
result = retype(tree, tree.type, pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void visitIf(JCIf tree) {
|
public void visitIf(JCIf tree) {
|
||||||
|
@ -122,35 +122,47 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static enum CompilePolicy {
|
/**
|
||||||
/*
|
* Control how the compiler's latter phases (attr, flow, desugar, generate)
|
||||||
* Just attribute the parse trees
|
* are connected. Each individual file is processed by each phase in turn,
|
||||||
|
* but with different compile policies, you can control the order in which
|
||||||
|
* each class is processed through its next phase.
|
||||||
|
*
|
||||||
|
* <p>Generally speaking, the compiler will "fail fast" in the face of
|
||||||
|
* errors, although not aggressively so. flow, desugar, etc become no-ops
|
||||||
|
* once any errors have occurred. No attempt is currently made to determine
|
||||||
|
* if it might be safe to process a class through its next phase because
|
||||||
|
* it does not depend on any unrelated errors that might have occurred.
|
||||||
|
*/
|
||||||
|
protected static enum CompilePolicy {
|
||||||
|
/**
|
||||||
|
* Just attribute the parse trees.
|
||||||
*/
|
*/
|
||||||
ATTR_ONLY,
|
ATTR_ONLY,
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Just attribute and do flow analysis on the parse trees.
|
* Just attribute and do flow analysis on the parse trees.
|
||||||
* This should catch most user errors.
|
* This should catch most user errors.
|
||||||
*/
|
*/
|
||||||
CHECK_ONLY,
|
CHECK_ONLY,
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Attribute everything, then do flow analysis for everything,
|
* Attribute everything, then do flow analysis for everything,
|
||||||
* then desugar everything, and only then generate output.
|
* then desugar everything, and only then generate output.
|
||||||
* Means nothing is generated if there are any errors in any classes.
|
* This means no output will be generated if there are any
|
||||||
|
* errors in any classes.
|
||||||
*/
|
*/
|
||||||
SIMPLE,
|
SIMPLE,
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* After attributing everything and doing flow analysis,
|
* Groups the classes for each source file together, then process
|
||||||
* group the work by compilation unit.
|
* each group in a manner equivalent to the {@code SIMPLE} policy.
|
||||||
* Then, process the work for each compilation unit together.
|
* This means no output will be generated if there are any
|
||||||
* Means nothing is generated for a compilation unit if the are any errors
|
* errors in any of the classes in a source file.
|
||||||
* in the compilation unit (or in any preceding compilation unit.)
|
|
||||||
*/
|
*/
|
||||||
BY_FILE,
|
BY_FILE,
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Completely process each entry on the todo list in turn.
|
* Completely process each entry on the todo list in turn.
|
||||||
* -- this is the same for 1.5.
|
* -- this is the same for 1.5.
|
||||||
* Means output might be generated for some classes in a compilation unit
|
* Means output might be generated for some classes in a compilation unit
|
||||||
@ -178,7 +190,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
|
|
||||||
private static CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
|
private static CompilePolicy DEFAULT_COMPILE_POLICY = CompilePolicy.BY_TODO;
|
||||||
|
|
||||||
private static enum ImplicitSourcePolicy {
|
protected static enum ImplicitSourcePolicy {
|
||||||
/** Don't generate or process implicitly read source files. */
|
/** Don't generate or process implicitly read source files. */
|
||||||
NONE,
|
NONE,
|
||||||
/** Generate classes for implicitly read source files. */
|
/** Generate classes for implicitly read source files. */
|
||||||
@ -252,11 +264,11 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
|
|
||||||
/** The type eraser.
|
/** The type eraser.
|
||||||
*/
|
*/
|
||||||
TransTypes transTypes;
|
protected TransTypes transTypes;
|
||||||
|
|
||||||
/** The syntactic sugar desweetener.
|
/** The syntactic sugar desweetener.
|
||||||
*/
|
*/
|
||||||
Lower lower;
|
protected Lower lower;
|
||||||
|
|
||||||
/** The annotation annotator.
|
/** The annotation annotator.
|
||||||
*/
|
*/
|
||||||
@ -788,14 +800,17 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
generate(desugar(flow(attribute(todo))));
|
generate(desugar(flow(attribute(todo))));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BY_FILE:
|
case BY_FILE: {
|
||||||
for (Queue<Env<AttrContext>> queue : groupByFile(flow(attribute(todo))).values())
|
Queue<Queue<Env<AttrContext>>> q = todo.groupByFile();
|
||||||
generate(desugar(queue));
|
while (!q.isEmpty() && errorCount() == 0) {
|
||||||
|
generate(desugar(flow(attribute(q.remove()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BY_TODO:
|
case BY_TODO:
|
||||||
while (todo.nonEmpty())
|
while (!todo.isEmpty())
|
||||||
generate(desugar(flow(attribute(todo.next()))));
|
generate(desugar(flow(attribute(todo.remove()))));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1105,13 +1120,13 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
/**
|
/**
|
||||||
* Perform dataflow checks on an attributed parse tree.
|
* Perform dataflow checks on an attributed parse tree.
|
||||||
*/
|
*/
|
||||||
protected void flow(Env<AttrContext> env, ListBuffer<Env<AttrContext>> results) {
|
protected void flow(Env<AttrContext> env, Queue<Env<AttrContext>> results) {
|
||||||
try {
|
try {
|
||||||
if (errorCount() > 0)
|
if (errorCount() > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (relax || compileStates.isDone(env, CompileState.FLOW)) {
|
if (relax || compileStates.isDone(env, CompileState.FLOW)) {
|
||||||
results.append(env);
|
results.add(env);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1130,7 +1145,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
if (errorCount() > 0)
|
if (errorCount() > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
results.append(env);
|
results.add(env);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
log.useSource(prev);
|
log.useSource(prev);
|
||||||
@ -1284,7 +1299,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
generate(queue, null);
|
generate(queue, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, ListBuffer<JavaFileObject> results) {
|
public void generate(Queue<Pair<Env<AttrContext>, JCClassDecl>> queue, Queue<JavaFileObject> results) {
|
||||||
boolean usePrintSource = (stubOutput || sourceOutput || printFlat);
|
boolean usePrintSource = (stubOutput || sourceOutput || printFlat);
|
||||||
|
|
||||||
for (Pair<Env<AttrContext>, JCClassDecl> x: queue) {
|
for (Pair<Env<AttrContext>, JCClassDecl> x: queue) {
|
||||||
@ -1294,7 +1309,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
if (verboseCompilePolicy) {
|
if (verboseCompilePolicy) {
|
||||||
log.printLines(log.noticeWriter, "[generate "
|
log.printLines(log.noticeWriter, "[generate "
|
||||||
+ (usePrintSource ? " source" : "code")
|
+ (usePrintSource ? " source" : "code")
|
||||||
+ " " + env.enclClass.sym + "]");
|
+ " " + cdef.sym + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskListener != null) {
|
if (taskListener != null) {
|
||||||
@ -1312,7 +1327,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
|||||||
else
|
else
|
||||||
file = genCode(env, cdef);
|
file = genCode(env, cdef);
|
||||||
if (results != null && file != null)
|
if (results != null && file != null)
|
||||||
results.append(file);
|
results.add(file);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
log.error(cdef.pos(), "class.cant.write",
|
log.error(cdef.pos(), "class.cant.write",
|
||||||
cdef.sym, ex.getMessage());
|
cdef.sym, ex.getMessage());
|
||||||
|
@ -770,6 +770,10 @@ compiler.warn.annotation.method.not.found=\
|
|||||||
compiler.warn.annotation.method.not.found.reason=\
|
compiler.warn.annotation.method.not.found.reason=\
|
||||||
Cannot find annotation method ''{1}()'' in type ''{0}'': {2}
|
Cannot find annotation method ''{1}()'' in type ''{0}'': {2}
|
||||||
|
|
||||||
|
compiler.warn.raw.class.use=\
|
||||||
|
[raw-type] found raw type: {0}\n\
|
||||||
|
missing type parameters for generic class {1}
|
||||||
|
|
||||||
#####
|
#####
|
||||||
|
|
||||||
## The following are tokens which are non-terminals in the language. They should
|
## The following are tokens which are non-terminals in the language. They should
|
||||||
@ -823,6 +827,12 @@ compiler.err.orphaned=\
|
|||||||
compiler.misc.anonymous.class=\
|
compiler.misc.anonymous.class=\
|
||||||
<anonymous {0}>
|
<anonymous {0}>
|
||||||
|
|
||||||
|
compiler.misc.type.captureof=\
|
||||||
|
capture#{0} of {1}
|
||||||
|
|
||||||
|
compiler.misc.type.none=\
|
||||||
|
<none>
|
||||||
|
|
||||||
compiler.misc.unnamed.package=\
|
compiler.misc.unnamed.package=\
|
||||||
unnamed package
|
unnamed package
|
||||||
|
|
||||||
|
@ -46,8 +46,13 @@ public class JavadocTodo extends Todo {
|
|||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListBuffer<Env<AttrContext>> append(Env<AttrContext> e) {
|
@Override
|
||||||
|
public void append(Env<AttrContext> e) {
|
||||||
// do nothing; Javadoc doesn't perform attribution.
|
// do nothing; Javadoc doesn't perform attribution.
|
||||||
return this;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean offer(Env<AttrContext> e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,10 @@
|
|||||||
package javax.tools;
|
package javax.tools;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.CharConversionException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.CharBuffer;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
T6304921.java:671/671/680: warning: [raw-type] found raw type: java.util.ArrayList
|
||||||
|
missing type parameters for generic class java.util.ArrayList<E>
|
||||||
|
List<Integer> list = new ArrayList();
|
||||||
|
^
|
||||||
T6304921.java:667/667/682: warning: [unchecked] unchecked conversion
|
T6304921.java:667/667/682: warning: [unchecked] unchecked conversion
|
||||||
found : java.util.ArrayList
|
found : java.util.ArrayList
|
||||||
required: java.util.List<java.lang.Integer>
|
required: java.util.List<java.lang.Integer>
|
||||||
@ -18,4 +22,4 @@ T6304921.java:812/816/822: operator + cannot be applied to int,boolean
|
|||||||
return 123 + true; // bad binary expression
|
return 123 + true; // bad binary expression
|
||||||
^
|
^
|
||||||
2 errors
|
2 errors
|
||||||
3 warnings
|
4 warnings
|
||||||
|
@ -5,5 +5,5 @@
|
|||||||
[desugar A]
|
[desugar A]
|
||||||
[generate code A]
|
[generate code A]
|
||||||
[desugar B]
|
[desugar B]
|
||||||
[generate code B]
|
[generate code B.C]
|
||||||
[generate code B]
|
[generate code B]
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 6500343
|
||||||
|
* @summary compiler generates bad code when translating conditional expressions
|
||||||
|
* @author Maurizio Cimadamore
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class T6500343a {
|
||||||
|
static class Base {}
|
||||||
|
static interface I {}
|
||||||
|
static class A1 extends Base implements I {}
|
||||||
|
static class A2 extends Base implements I {}
|
||||||
|
|
||||||
|
static Object crash(I i, A1 a1, A2 a2, boolean b1, boolean b2) {
|
||||||
|
return b1 ? i : b2 ? a2 : a1;
|
||||||
|
// lub(I, lub(A1, A2)) ==> lub(I, Base&I) ==> I (doesn't compile on 1.4 ok >1.5)
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
T6500343a.crash(new A1(), new A1(), new A2(), true, false);
|
||||||
|
T6500343a.crash(new A1(), new A1(), new A2(), false, true);
|
||||||
|
T6500343a.crash(new A1(), new A1(), new A2(), false, false);
|
||||||
|
T6500343a.crash(new A1(), new A1(), new A2(), true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 6500343
|
||||||
|
* @summary compiler generates bad code when translating conditional expressions
|
||||||
|
* @author Maurizio Cimadamore
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class T6500343b {
|
||||||
|
|
||||||
|
final static int i1 = 0;
|
||||||
|
final static int i2 = 1;
|
||||||
|
|
||||||
|
static void crash(int i) {
|
||||||
|
switch (i) {
|
||||||
|
case (true ? 0 : 1):
|
||||||
|
case (i1 == 5 ? 1 : 2):
|
||||||
|
case (i1 == i2 ? 2 : 3):
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
T6500343b.crash(0);
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,14 @@
|
|||||||
* have any questions.
|
* have any questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// These tests exercise the various compile policies available via
|
||||||
|
// JavaCompiler.CompilePolicy. Like any golden file tests, they are
|
||||||
|
// somewhat fragile and susceptible to breakage, but like the canary
|
||||||
|
// in the mine, it is useful to know when something is not as it used
|
||||||
|
// to be. The golden files should not be taken as a guarantee of
|
||||||
|
// future behavior, and should be updated, with due care, if the
|
||||||
|
// behavior of the compile policy is deliberately changed.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 6260188 6290772
|
* @bug 6260188 6290772
|
156
langtools/test/tools/javac/policy/test1/Test1b.java
Normal file
156
langtools/test/tools/javac/policy/test1/Test1b.java
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test 6420151
|
||||||
|
* @summary Compile a group of files and validate the set of class files produced
|
||||||
|
* @run main Test1b -XDcompilePolicy=byfile A.java B.java D.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test 6420151
|
||||||
|
* @summary Compile a group of files and validate the set of class files produced
|
||||||
|
* @run main Test1b -XDcompilePolicy=byfile A.java C.java D.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test 6420151
|
||||||
|
* @summary Compile a group of files and validate the set of class files produced
|
||||||
|
* @run main Test1b -XDcompilePolicy=simple A.java B.java D.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test 6420151
|
||||||
|
* @summary Compile a group of files and validate the set of class files produced
|
||||||
|
* @run main Test1b -XDcompilePolicy=simple A.java C.java D.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
// These test cases should be uncommented when the default compile policy is
|
||||||
|
// changed to "byfile". While the default policy is "bytodo", the test cases fail
|
||||||
|
///*
|
||||||
|
// * @test 6420151
|
||||||
|
// * @summary Compile a group of files and validate the set of class files produced
|
||||||
|
// * @run main Test1b A.java B.java D.java
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
///*
|
||||||
|
// * @test 6420151
|
||||||
|
// * @summary Compile a group of files and validate the set of class files produced
|
||||||
|
// * @run main Test1b A.java C.java D.java
|
||||||
|
// */
|
||||||
|
|
||||||
|
// These test cases are retained for debugging; if uncommented, they show that
|
||||||
|
// to bytodo mode fails the "all or none" class file test
|
||||||
|
///*
|
||||||
|
// * @test 6420151
|
||||||
|
// * @summary Compile a group of files and validate the set of class files produced
|
||||||
|
// * @run main Test1b -XDcompilePolicy=bytodo A.java B.java D.java
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
///*
|
||||||
|
// * @test 6420151
|
||||||
|
// * @summary Compile a group of files and validate the set of class files produced
|
||||||
|
// * @run main Test1b -XDcompilePolicy=bytodo A.java C.java D.java
|
||||||
|
// */
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class Test1b
|
||||||
|
{
|
||||||
|
public static void main(String... args) throws Exception {
|
||||||
|
new Test1b().run(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void run(String... args) throws Exception {
|
||||||
|
File testSrcDir = new File(System.getProperty("test.src"));
|
||||||
|
File tmpClassDir = new File(".");
|
||||||
|
List<String> l = new ArrayList<String>();
|
||||||
|
l.add("-d");
|
||||||
|
l.add(tmpClassDir.getPath());
|
||||||
|
for (String a: args) {
|
||||||
|
if (a.endsWith(".java"))
|
||||||
|
l.add(new File(testSrcDir, a).getPath());
|
||||||
|
else
|
||||||
|
l.add(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
int rc = com.sun.tools.javac.Main.compile(l.toArray(new String[l.size()]), new PrintWriter(sw));
|
||||||
|
System.err.println(sw);
|
||||||
|
|
||||||
|
Pattern p = Pattern.compile("([A-Z]+).*");
|
||||||
|
for (String name: tmpClassDir.list()) {
|
||||||
|
if (name.endsWith(".class")) {
|
||||||
|
Matcher m = p.matcher(name);
|
||||||
|
if (m.matches()) {
|
||||||
|
found(m.group(1), name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for all classes that might have been compiled, check that
|
||||||
|
// all the classes in the source file get generated, or none do.
|
||||||
|
check("A", 3);
|
||||||
|
check("B", 3);
|
||||||
|
check("C", 3);
|
||||||
|
check("D", 3);
|
||||||
|
|
||||||
|
if (errors > 0)
|
||||||
|
throw new Exception(errors + " errors");
|
||||||
|
}
|
||||||
|
|
||||||
|
void check(String prefix, int expect) {
|
||||||
|
List<String> names = map.get(prefix);
|
||||||
|
int found = (names == null ? 0 : names.size());
|
||||||
|
if (found == 0 || found == expect) {
|
||||||
|
System.err.println("Found " + found + " files for " + prefix + ": OK");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error("Found " + found + " files for " + prefix + ": expected 0 or " + expect + " " + names);
|
||||||
|
}
|
||||||
|
|
||||||
|
void found(String prefix, String name) {
|
||||||
|
List<String> names = map.get(prefix);
|
||||||
|
if (names == null) {
|
||||||
|
names = new ArrayList<String>();
|
||||||
|
map.put(prefix, names);
|
||||||
|
}
|
||||||
|
names.add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void error(String message) {
|
||||||
|
System.err.println(message);
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String,List<String>> map = new HashMap<String,List<String>>();
|
||||||
|
int errors;
|
||||||
|
}
|
@ -1,11 +1,17 @@
|
|||||||
[attribute A]
|
[attribute A]
|
||||||
[attribute A1]
|
[attribute A1]
|
||||||
[attribute A2]
|
[attribute A2]
|
||||||
|
[flow A]
|
||||||
|
[flow A1]
|
||||||
|
[flow A2]
|
||||||
|
[desugar A]
|
||||||
|
[desugar A1]
|
||||||
|
[desugar A2]
|
||||||
|
[generate code A]
|
||||||
|
[generate code A1]
|
||||||
|
[generate code A2]
|
||||||
[attribute B]
|
[attribute B]
|
||||||
[attribute B1]
|
[attribute B1]
|
||||||
B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
|
B.java:12:9: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, B1
|
||||||
[attribute B2]
|
[attribute B2]
|
||||||
[attribute D]
|
|
||||||
[attribute D1]
|
|
||||||
[attribute D2]
|
|
||||||
1 error
|
1 error
|
@ -1,15 +1,18 @@
|
|||||||
[attribute A]
|
[attribute A]
|
||||||
[attribute A1]
|
[attribute A1]
|
||||||
[attribute A2]
|
[attribute A2]
|
||||||
[attribute C]
|
|
||||||
[attribute C1]
|
|
||||||
[attribute C2]
|
|
||||||
[attribute D]
|
|
||||||
[attribute D1]
|
|
||||||
[attribute D2]
|
|
||||||
[flow A]
|
[flow A]
|
||||||
[flow A1]
|
[flow A1]
|
||||||
[flow A2]
|
[flow A2]
|
||||||
|
[desugar A]
|
||||||
|
[desugar A1]
|
||||||
|
[desugar A2]
|
||||||
|
[generate code A]
|
||||||
|
[generate code A1]
|
||||||
|
[generate code A2]
|
||||||
|
[attribute C]
|
||||||
|
[attribute C1]
|
||||||
|
[attribute C2]
|
||||||
[flow C]
|
[flow C]
|
||||||
[flow C1]
|
[flow C1]
|
||||||
C.java:12:17: compiler.err.unreachable.stmt
|
C.java:12:17: compiler.err.unreachable.stmt
|
46
langtools/test/tools/javac/policy/test2/A.java
Normal file
46
langtools/test/tools/javac/policy/test2/A.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class A {
|
||||||
|
|
||||||
|
class A1 {
|
||||||
|
}
|
||||||
|
|
||||||
|
static class A2 extends B {
|
||||||
|
}
|
||||||
|
|
||||||
|
static class A3 extends B.Inner {
|
||||||
|
}
|
||||||
|
|
||||||
|
class A4 {
|
||||||
|
void m1() {
|
||||||
|
class A3m1 { }
|
||||||
|
}
|
||||||
|
|
||||||
|
void m2() {
|
||||||
|
new B() {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
langtools/test/tools/javac/policy/test2/B.java
Normal file
27
langtools/test/tools/javac/policy/test2/B.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class B {
|
||||||
|
static class Inner {
|
||||||
|
}
|
||||||
|
}
|
42
langtools/test/tools/javac/policy/test2/Test.java
Normal file
42
langtools/test/tools/javac/policy/test2/Test.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @compile/ref=byfile.AB.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=byfile A.java B.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @compile/ref=byfile.BA.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=byfile B.java A.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @compile/ref=bytodo.AB.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=bytodo A.java B.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @compile/ref=bytodo.BA.out -XDstdout -XDverboseCompilePolicy -XDcompile.policy=bytodo B.java A.java
|
||||||
|
*/
|
15
langtools/test/tools/javac/policy/test2/byfile.AB.out
Normal file
15
langtools/test/tools/javac/policy/test2/byfile.AB.out
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[attribute A]
|
||||||
|
[flow A]
|
||||||
|
[attribute B]
|
||||||
|
[flow B]
|
||||||
|
[desugar A]
|
||||||
|
[generate code A.A1]
|
||||||
|
[generate code A.A2]
|
||||||
|
[generate code A.A3]
|
||||||
|
[generate code A3m1]
|
||||||
|
[generate code <anonymous A$A4$1>]
|
||||||
|
[generate code A.A4]
|
||||||
|
[generate code A]
|
||||||
|
[desugar B]
|
||||||
|
[generate code B.Inner]
|
||||||
|
[generate code B]
|
15
langtools/test/tools/javac/policy/test2/byfile.BA.out
Normal file
15
langtools/test/tools/javac/policy/test2/byfile.BA.out
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[attribute B]
|
||||||
|
[flow B]
|
||||||
|
[desugar B]
|
||||||
|
[generate code B.Inner]
|
||||||
|
[generate code B]
|
||||||
|
[attribute A]
|
||||||
|
[flow A]
|
||||||
|
[desugar A]
|
||||||
|
[generate code A.A1]
|
||||||
|
[generate code A.A2]
|
||||||
|
[generate code A.A3]
|
||||||
|
[generate code A3m1]
|
||||||
|
[generate code <anonymous A$A4$1>]
|
||||||
|
[generate code A.A4]
|
||||||
|
[generate code A]
|
15
langtools/test/tools/javac/policy/test2/bytodo.AB.out
Normal file
15
langtools/test/tools/javac/policy/test2/bytodo.AB.out
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[attribute A]
|
||||||
|
[flow A]
|
||||||
|
[attribute B]
|
||||||
|
[flow B]
|
||||||
|
[desugar A]
|
||||||
|
[generate code A.A1]
|
||||||
|
[generate code A.A2]
|
||||||
|
[generate code A.A3]
|
||||||
|
[generate code A3m1]
|
||||||
|
[generate code <anonymous A$A4$1>]
|
||||||
|
[generate code A.A4]
|
||||||
|
[generate code A]
|
||||||
|
[desugar B]
|
||||||
|
[generate code B.Inner]
|
||||||
|
[generate code B]
|
15
langtools/test/tools/javac/policy/test2/bytodo.BA.out
Normal file
15
langtools/test/tools/javac/policy/test2/bytodo.BA.out
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[attribute B]
|
||||||
|
[flow B]
|
||||||
|
[desugar B]
|
||||||
|
[generate code B.Inner]
|
||||||
|
[generate code B]
|
||||||
|
[attribute A]
|
||||||
|
[flow A]
|
||||||
|
[desugar A]
|
||||||
|
[generate code A.A1]
|
||||||
|
[generate code A.A2]
|
||||||
|
[generate code A.A3]
|
||||||
|
[generate code A3m1]
|
||||||
|
[generate code <anonymous A$A4$1>]
|
||||||
|
[generate code A.A4]
|
||||||
|
[generate code A]
|
58
langtools/test/tools/javac/warnings/6747671/T6747671.java
Normal file
58
langtools/test/tools/javac/warnings/6747671/T6747671.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 6747671
|
||||||
|
* @summary -Xlint:rawtypes
|
||||||
|
* @compile/ref=T6747671.out -XDrawDiagnostics -Xlint:rawtypes T6747671.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class T6747671<E> {
|
||||||
|
|
||||||
|
static class B<X> {}
|
||||||
|
|
||||||
|
class A<X> {
|
||||||
|
class X {}
|
||||||
|
class Z<Y> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
A.X x1;//raw warning
|
||||||
|
A.Z z1;//raw warning
|
||||||
|
|
||||||
|
T6747671.B<Integer> b1;//ok
|
||||||
|
T6747671.B b2;//raw warning
|
||||||
|
|
||||||
|
A<String>.X x2;//ok
|
||||||
|
A<String>.Z<Integer> z2;//ok
|
||||||
|
A<B>.Z<A<B>> z3;//raw warning (2)
|
||||||
|
|
||||||
|
void test(Object arg1, B arg2) {//raw warning
|
||||||
|
boolean b = arg1 instanceof A;//raw warning
|
||||||
|
Object a = (A)arg1;//raw warning
|
||||||
|
A a2 = new A() {};//raw warning (2)
|
||||||
|
a2.new Z() {};//raw warning
|
||||||
|
}
|
||||||
|
}
|
12
langtools/test/tools/javac/warnings/6747671/T6747671.out
Normal file
12
langtools/test/tools/javac/warnings/6747671/T6747671.out
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
T6747671.java:42:6: compiler.warn.raw.class.use: T6747671.A.X, T6747671<E>.A<X>.X
|
||||||
|
T6747671.java:43:6: compiler.warn.raw.class.use: T6747671.A.Z, T6747671<E>.A<X>.Z<Y>
|
||||||
|
T6747671.java:46:13: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
|
||||||
|
T6747671.java:50:14: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
|
||||||
|
T6747671.java:50:7: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
|
||||||
|
T6747671.java:52:28: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
|
||||||
|
T6747671.java:53:37: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
|
||||||
|
T6747671.java:54:21: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
|
||||||
|
T6747671.java:55:9: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
|
||||||
|
T6747671.java:55:20: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
|
||||||
|
T6747671.java:56:16: compiler.warn.raw.class.use: T6747671.A.Z, T6747671<E>.A<X>.Z<Y>
|
||||||
|
11 warnings
|
@ -1,3 +1,8 @@
|
|||||||
|
Unchecked.java:16:9: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
|
||||||
Unchecked.java:17:14: compiler.warn.unchecked.call.mbr.of.raw.type: add(E), java.util.List
|
Unchecked.java:17:14: compiler.warn.unchecked.call.mbr.of.raw.type: add(E), java.util.List
|
||||||
|
Unchecked.java:26:9: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
|
||||||
|
Unchecked.java:35:9: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
|
||||||
|
Unchecked.java:46:21: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
|
||||||
|
Unchecked.java:57:9: compiler.warn.raw.class.use: java.util.List, java.util.List<E>
|
||||||
Unchecked.java:58:14: compiler.warn.unchecked.call.mbr.of.raw.type: add(E), java.util.List
|
Unchecked.java:58:14: compiler.warn.unchecked.call.mbr.of.raw.type: add(E), java.util.List
|
||||||
2 warnings
|
7 warnings
|
Loading…
x
Reference in New Issue
Block a user