--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Sun Aug 29 22:42:08 2010 -0700
@@ -328,6 +328,10 @@
return (tsym.flags() & INTERFACE) != 0;
}
+ public boolean isFinal() {
+ return (tsym.flags() & FINAL) != 0;
+ }
+
public boolean isPrimitive() {
return tag < VOID;
}
@@ -347,11 +351,17 @@
return false;
}
- /** Does this type contain an occurrence of some type in `elems'?
+ /** Does this type contain an occurrence of some type in 'ts'?
*/
- public boolean containsSome(List<Type> ts) {
- for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
- if (this.contains(ts.head)) return true;
+ public boolean containsAny(List<Type> ts) {
+ for (Type t : ts)
+ if (this.contains(t)) return true;
+ return false;
+ }
+
+ public static boolean containsAny(List<Type> ts1, List<Type> ts2) {
+ for (Type t : ts1)
+ if (t.containsAny(ts2)) return true;
return false;
}
@@ -431,6 +441,10 @@
this.bound = bound;
}
+ public boolean contains(Type t) {
+ return kind != UNBOUND && type.contains(t);
+ }
+
public boolean isSuperBound() {
return kind == SUPER ||
kind == UNBOUND;
@@ -681,7 +695,9 @@
return
elem == this
|| (isParameterized()
- && (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem)));
+ && (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem)))
+ || (isCompound()
+ && (supertype_field.contains(elem) || contains(interfaces_field, elem)));
}
public void complete() {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Sun Aug 29 22:42:08 2010 -0700
@@ -960,7 +960,7 @@
return true;
if (s.tag == TYPEVAR) {
- if (isCastable(s.getUpperBound(), t, Warner.noWarnings)) {
+ if (isCastable(t, s.getUpperBound(), Warner.noWarnings)) {
warnStack.head.warnUnchecked();
return true;
} else {
@@ -1030,7 +1030,12 @@
&& !disjointTypes(aHigh.allparams(), lowSub.allparams())
&& !disjointTypes(aLow.allparams(), highSub.allparams())
&& !disjointTypes(aLow.allparams(), lowSub.allparams())) {
- if (upcast ? giveWarning(a, b) :
+ if (s.isInterface() &&
+ !t.isInterface() &&
+ t.isFinal() &&
+ !isSubtype(t, s)) {
+ return false;
+ } else if (upcast ? giveWarning(a, b) :
giveWarning(b, a))
warnStack.head.warnUnchecked();
return true;
@@ -1230,18 +1235,23 @@
if (t == s) return false;
if (t.tag == TYPEVAR) {
TypeVar tv = (TypeVar) t;
- if (s.tag == TYPEVAR)
- s = s.getUpperBound();
return !isCastable(tv.bound,
- s,
+ relaxBound(s),
Warner.noWarnings);
}
if (s.tag != WILDCARD)
s = upperBound(s);
- if (s.tag == TYPEVAR)
- s = s.getUpperBound();
-
- return !isSubtype(t, s);
+
+ return !isSubtype(t, relaxBound(s));
+ }
+
+ private Type relaxBound(Type t) {
+ if (t.tag == TYPEVAR) {
+ while (t.tag == TYPEVAR)
+ t = t.getUpperBound();
+ t = rewriteQuantifiers(t, true, true);
+ }
+ return t;
}
// </editor-fold>
@@ -2945,6 +2955,13 @@
public Type capture(Type t) {
if (t.tag != CLASS)
return t;
+ if (t.getEnclosingType() != Type.noType) {
+ Type capturedEncl = capture(t.getEnclosingType());
+ if (capturedEncl != t.getEnclosingType()) {
+ Type type1 = memberType(capturedEncl, t.tsym);
+ t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments());
+ }
+ }
ClassType cls = (ClassType)t;
if (cls.isRaw() || !cls.isParameterized())
return cls;
@@ -3273,7 +3290,7 @@
* quantifiers) only
*/
private Type rewriteQuantifiers(Type t, boolean high, boolean rewriteTypeVars) {
- return new Rewriter(high, rewriteTypeVars).rewrite(t);
+ return new Rewriter(high, rewriteTypeVars).visit(t);
}
class Rewriter extends UnaryVisitor<Type> {
@@ -3286,25 +3303,21 @@
this.rewriteTypeVars = rewriteTypeVars;
}
- Type rewrite(Type t) {
- ListBuffer<Type> from = new ListBuffer<Type>();
- ListBuffer<Type> to = new ListBuffer<Type>();
- adaptSelf(t, from, to);
+ @Override
+ public Type visitClassType(ClassType t, Void s) {
ListBuffer<Type> rewritten = new ListBuffer<Type>();
- List<Type> formals = from.toList();
boolean changed = false;
- for (Type arg : to.toList()) {
+ for (Type arg : t.allparams()) {
Type bound = visit(arg);
if (arg != bound) {
changed = true;
- bound = high ? makeExtendsWildcard(bound, (TypeVar)formals.head)
- : makeSuperWildcard(bound, (TypeVar)formals.head);
}
rewritten.append(bound);
- formals = formals.tail;
}
if (changed)
- return subst(t.tsym.type, from.toList(), rewritten.toList());
+ return subst(t.tsym.type,
+ t.tsym.type.allparams(),
+ rewritten.toList());
else
return t;
}
@@ -3315,13 +3328,22 @@
@Override
public Type visitCapturedType(CapturedType t, Void s) {
- return visitWildcardType(t.wildcard, null);
+ Type bound = visitWildcardType(t.wildcard, null);
+ return (bound.contains(t)) ?
+ (high ? syms.objectType : syms.botType) :
+ bound;
}
@Override
public Type visitTypeVar(TypeVar t, Void s) {
- if (rewriteTypeVars)
- return high ? t.bound : syms.botType;
+ if (rewriteTypeVars) {
+ Type bound = high ?
+ (t.bound.contains(t) ?
+ syms.objectType :
+ visit(t.bound)) :
+ syms.botType;
+ return rewriteAsWildcardType(bound, t);
+ }
else
return t;
}
@@ -3331,11 +3353,31 @@
Type bound = high ? t.getExtendsBound() :
t.getSuperBound();
if (bound == null)
- bound = high ? syms.objectType : syms.botType;
- return bound;
+ bound = high ? syms.objectType : syms.botType;
+ return rewriteAsWildcardType(visit(bound), t.bound);
+ }
+
+ private Type rewriteAsWildcardType(Type bound, TypeVar formal) {
+ return high ?
+ makeExtendsWildcard(B(bound), formal) :
+ makeSuperWildcard(B(bound), formal);
+ }
+
+ Type B(Type t) {
+ while (t.tag == WILDCARD) {
+ WildcardType w = (WildcardType)t;
+ t = high ?
+ w.getExtendsBound() :
+ w.getSuperBound();
+ if (t == null) {
+ t = high ? syms.objectType : syms.botType;
+ }
+ }
+ return t;
}
}
+
/**
* Create a wildcard with the given upper (extends) bound; create
* an unbounded wildcard if bound is Object.
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Sun Aug 29 22:42:08 2010 -0700
@@ -675,24 +675,34 @@
// Check that type parameters are well-formed.
chk.validate(tree.typarams, localEnv);
- if ((owner.flags() & ANNOTATION) != 0 &&
- tree.typarams.nonEmpty())
- log.error(tree.typarams.head.pos(),
- "intf.annotation.members.cant.have.type.params");
// Check that result type is well-formed.
chk.validate(tree.restype, localEnv);
- if ((owner.flags() & ANNOTATION) != 0)
+
+ // annotation method checks
+ if ((owner.flags() & ANNOTATION) != 0) {
+ // annotation method cannot have throws clause
+ if (tree.thrown.nonEmpty()) {
+ log.error(tree.thrown.head.pos(),
+ "throws.not.allowed.in.intf.annotation");
+ }
+ // annotation method cannot declare type-parameters
+ if (tree.typarams.nonEmpty()) {
+ log.error(tree.typarams.head.pos(),
+ "intf.annotation.members.cant.have.type.params");
+ }
+ // validate annotation method's return type (could be an annotation type)
chk.validateAnnotationType(tree.restype);
-
- if ((owner.flags() & ANNOTATION) != 0)
+ // ensure that annotation method does not clash with members of Object/Annotation
chk.validateAnnotationMethod(tree.pos(), m);
- // Check that all exceptions mentioned in the throws clause extend
- // java.lang.Throwable.
- if ((owner.flags() & ANNOTATION) != 0 && tree.thrown.nonEmpty())
- log.error(tree.thrown.head.pos(),
- "throws.not.allowed.in.intf.annotation");
+ if (tree.defaultValue != null) {
+ // if default value is an annotation, check it is a well-formed
+ // annotation value (e.g. no duplicate values, no missing values, etc.)
+ chk.validateAnnotationTree(tree.defaultValue);
+ }
+ }
+
for (List<JCExpression> l = tree.thrown; l.nonEmpty(); l = l.tail)
chk.checkType(l.head.pos(), l.head.type, syms.throwableType);
@@ -1546,7 +1556,7 @@
List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
if (TreeInfo.isDiamond(tree)) {
- clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes, true);
+ clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes);
clazz.type = clazztype;
}
@@ -1586,13 +1596,15 @@
localEnv.info.varArgs = false;
tree.constructor = rs.resolveConstructor(
tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
- tree.constructorType = checkMethod(clazztype,
- tree.constructor,
- localEnv,
- tree.args,
- argtypes,
- typeargtypes,
- localEnv.info.varArgs);
+ tree.constructorType = tree.constructor.type.isErroneous() ?
+ syms.errType :
+ checkMethod(clazztype,
+ tree.constructor,
+ localEnv,
+ tree.args,
+ argtypes,
+ typeargtypes,
+ localEnv.info.varArgs);
if (localEnv.info.varArgs)
assert tree.constructorType.isErroneous() || tree.varargsElement != null;
}
@@ -1682,8 +1694,7 @@
Type clazztype,
Pair<Scope, Scope> mapping,
List<Type> argtypes,
- List<Type> typeargtypes,
- boolean reportErrors) {
+ List<Type> typeargtypes) {
if (clazztype.isErroneous() || mapping == erroneousMapping) {
//if the type of the instance creation expression is erroneous,
//or something prevented us to form a valid mapping, return the
@@ -1721,7 +1732,7 @@
env,
clazztype.tsym.type,
argtypes,
- typeargtypes, reportErrors);
+ typeargtypes);
} finally {
((ClassSymbol) clazztype.tsym).members_field = mapping.fst;
}
@@ -1750,42 +1761,37 @@
Warner.noWarnings);
} catch (Infer.InferenceException ex) {
//an error occurred while inferring uninstantiated type-variables
- //we need to optionally report an error
- if (reportErrors) {
- log.error(tree.clazz.pos(),
- "cant.apply.diamond.1",
- diags.fragment("diamond", clazztype.tsym),
- ex.diagnostic);
- }
+ log.error(tree.clazz.pos(),
+ "cant.apply.diamond.1",
+ diags.fragment("diamond", clazztype.tsym),
+ ex.diagnostic);
}
}
- if (reportErrors) {
- clazztype = chk.checkClassType(tree.clazz.pos(),
- clazztype,
- true);
- if (clazztype.tag == CLASS) {
- List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
- if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
- //one or more types inferred in the previous steps is either a
- //captured type or an intersection type --- we need to report an error.
- String subkey = invalidDiamondArgs.size() > 1 ?
- "diamond.invalid.args" :
- "diamond.invalid.arg";
- //The error message is of the kind:
- //
- //cannot infer type arguments for {clazztype}<>;
- //reason: {subkey}
- //
- //where subkey is a fragment of the kind:
- //
- //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
- log.error(tree.clazz.pos(),
- "cant.apply.diamond.1",
- diags.fragment("diamond", clazztype.tsym),
- diags.fragment(subkey,
- invalidDiamondArgs,
- diags.fragment("diamond", clazztype.tsym)));
- }
+ clazztype = chk.checkClassType(tree.clazz.pos(),
+ clazztype,
+ true);
+ if (clazztype.tag == CLASS) {
+ List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
+ if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
+ //one or more types inferred in the previous steps is either a
+ //captured type or an intersection type --- we need to report an error.
+ String subkey = invalidDiamondArgs.size() > 1 ?
+ "diamond.invalid.args" :
+ "diamond.invalid.arg";
+ //The error message is of the kind:
+ //
+ //cannot infer type arguments for {clazztype}<>;
+ //reason: {subkey}
+ //
+ //where subkey is a fragment of the kind:
+ //
+ //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
+ log.error(tree.clazz.pos(),
+ "cant.apply.diamond.1",
+ diags.fragment("diamond", clazztype.tsym),
+ diags.fragment(subkey,
+ invalidDiamondArgs,
+ diags.fragment("diamond", clazztype.tsym)));
}
}
return clazztype;
@@ -2002,7 +2008,7 @@
public void visitTypeCast(JCTypeCast tree) {
Type clazztype = attribType(tree.clazz, env);
- chk.validate(tree.clazz, env);
+ chk.validate(tree.clazz, env, false);
Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly);
Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
if (exprtype.constValue() != null)
@@ -2015,7 +2021,7 @@
tree.expr.pos(), attribExpr(tree.expr, env));
Type clazztype = chk.checkReifiableReferenceType(
tree.clazz.pos(), attribType(tree.clazz, env));
- chk.validate(tree.clazz, env);
+ chk.validate(tree.clazz, env, false);
chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
result = check(tree, syms.booleanType, VAL, pkind, pt);
}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Sun Aug 29 22:42:08 2010 -0700
@@ -25,6 +25,7 @@
package com.sun.tools.javac.comp;
+import com.sun.source.tree.AssignmentTree;
import java.util.*;
import java.util.Set;
@@ -329,7 +330,7 @@
for (Scope.Entry e = s.next.lookup(c.name);
e.scope != null && e.sym.owner == c.owner;
e = e.next()) {
- if (e.sym.kind == TYP &&
+ if (e.sym.kind == TYP && e.sym.type.tag != TYPEVAR &&
(e.sym.owner.kind & (VAR | MTH)) != 0 &&
c.name != names.error) {
duplicateError(pos, e.sym);
@@ -905,33 +906,15 @@
*
* and we can't make sure that the bound is already attributed because
* of possible cycles.
- */
- private Validator validator = new Validator();
-
- /** 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.
*/
void validate(JCTree tree, Env<AttrContext> env) {
- try {
- if (tree != null) {
- validator.env = env;
- tree.accept(validator);
- checkRaw(tree, env);
- }
- } catch (CompletionFailure ex) {
- completionError(tree.pos(), ex);
- }
+ validate(tree, env, true);
}
- //where
- void checkRaw(JCTree tree, Env<AttrContext> env) {
- if (lint.isEnabled(Lint.LintCategory.RAW) &&
- tree.type.tag == CLASS &&
- !TreeInfo.isDiamond(tree) &&
- !env.enclClass.name.isEmpty() && //anonymous or intersection
- tree.type.isRaw()) {
- log.warning(Lint.LintCategory.RAW,
- tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
- }
+ void validate(JCTree tree, Env<AttrContext> env, boolean checkRaw) {
+ new Validator(env).validateTree(tree, checkRaw, true);
}
/** Visitor method: Validate a list of type expressions.
@@ -945,9 +928,16 @@
*/
class Validator extends JCTree.Visitor {
+ boolean isOuter;
+ Env<AttrContext> env;
+
+ Validator(Env<AttrContext> env) {
+ this.env = env;
+ }
+
@Override
public void visitTypeArray(JCArrayTypeTree tree) {
- validate(tree.elemtype, env);
+ tree.elemtype.accept(this);
}
@Override
@@ -959,10 +949,14 @@
List<Type> forms = tree.type.tsym.type.getTypeArguments();
ListBuffer<Type> tvars_buf = new ListBuffer<Type>();
+ boolean is_java_lang_Class = tree.type.tsym.flatName() == names.java_lang_Class;
+
// For matching pairs of actual argument types `a' and
// formal type parameters with declared bound `b' ...
while (args.nonEmpty() && forms.nonEmpty()) {
- validate(args.head, env);
+ validateTree(args.head,
+ !(isOuter && is_java_lang_Class),
+ false);
// exact type arguments needs to know their
// bounds (for upper and lower bound
@@ -1014,14 +1008,14 @@
@Override
public void visitTypeParameter(JCTypeParameter tree) {
- validate(tree.bounds, env);
+ validateTrees(tree.bounds, true, isOuter);
checkClassBounds(tree.pos(), tree.type);
}
@Override
public void visitWildcard(JCWildcard tree) {
if (tree.inner != null)
- validate(tree.inner, env);
+ validateTree(tree.inner, true, isOuter);
}
@Override
@@ -1059,7 +1053,34 @@
public void visitTree(JCTree tree) {
}
- Env<AttrContext> env;
+ public void validateTree(JCTree tree, boolean checkRaw, boolean isOuter) {
+ try {
+ if (tree != null) {
+ this.isOuter = isOuter;
+ tree.accept(this);
+ if (checkRaw)
+ checkRaw(tree, env);
+ }
+ } catch (CompletionFailure ex) {
+ completionError(tree.pos(), ex);
+ }
+ }
+
+ public void validateTrees(List<? extends JCTree> trees, boolean checkRaw, boolean isOuter) {
+ for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
+ validateTree(l.head, checkRaw, isOuter);
+ }
+
+ void checkRaw(JCTree tree, Env<AttrContext> env) {
+ if (lint.isEnabled(Lint.LintCategory.RAW) &&
+ tree.type.tag == CLASS &&
+ !TreeInfo.isDiamond(tree) &&
+ !env.enclClass.name.isEmpty() && //anonymous or intersection
+ tree.type.isRaw()) {
+ log.warning(Lint.LintCategory.RAW,
+ tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
+ }
+ }
}
/* *************************************************************************
@@ -1929,6 +1950,20 @@
* Check annotations
**************************************************************************/
+ /**
+ * Recursively validate annotations values
+ */
+ void validateAnnotationTree(JCTree tree) {
+ class AnnotationValidator extends TreeScanner {
+ @Override
+ public void visitAnnotation(JCAnnotation tree) {
+ super.visitAnnotation(tree);
+ validateAnnotation(tree);
+ }
+ }
+ tree.accept(new AnnotationValidator());
+ }
+
/** Annotation types are restricted to primitives, String, an
* enum, an annotation, Class, Class<?>, Class<? extends
* Anything>, arrays of the preceding.
@@ -1992,7 +2027,7 @@
/** Check an annotation of a symbol.
*/
public void validateAnnotation(JCAnnotation a, Symbol s) {
- validateAnnotation(a);
+ validateAnnotationTree(a);
if (!annotationApplicable(a, s))
log.error(a.pos(), "annotation.type.not.applicable");
@@ -2006,7 +2041,7 @@
public void validateTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) {
if (a.type == null)
throw new AssertionError("annotation tree hasn't been attributed yet: " + a);
- validateAnnotation(a);
+ validateAnnotationTree(a);
if (!isTypeAnnotation(a, isTypeParameter))
log.error(a.pos(), "annotation.type.not.applicable");
@@ -2103,8 +2138,12 @@
public void validateAnnotation(JCAnnotation a) {
if (a.type.isErroneous()) return;
- // collect an inventory of the members
- Set<MethodSymbol> members = new HashSet<MethodSymbol>();
+ // collect an inventory of the members (sorted alphabetically)
+ Set<MethodSymbol> members = new TreeSet<MethodSymbol>(new Comparator<Symbol>() {
+ public int compare(Symbol t, Symbol t1) {
+ return t.name.compareTo(t1.name);
+ }
+ });
for (Scope.Entry e = a.annotationType.type.tsym.members().elems;
e != null;
e = e.sibling)
@@ -2120,15 +2159,21 @@
if (!members.remove(m))
log.error(assign.lhs.pos(), "duplicate.annotation.member.value",
m.name, a.type);
- if (assign.rhs.getTag() == ANNOTATION)
- validateAnnotation((JCAnnotation)assign.rhs);
}
// all the remaining ones better have default values
- for (MethodSymbol m : members)
- if (m.defaultValue == null && !m.type.isErroneous())
- log.error(a.pos(), "annotation.missing.default.value",
- a.type, m.name);
+ ListBuffer<Name> missingDefaults = ListBuffer.lb();
+ for (MethodSymbol m : members) {
+ if (m.defaultValue == null && !m.type.isErroneous()) {
+ missingDefaults.append(m.name);
+ }
+ }
+ if (missingDefaults.nonEmpty()) {
+ String key = (missingDefaults.size() > 1)
+ ? "annotation.missing.default.value.1"
+ : "annotation.missing.default.value";
+ log.error(a.pos(), key, a.type, missingDefaults);
+ }
// special case: java.lang.annotation.Target must not have
// repeated values in its value member
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Sun Aug 29 22:42:08 2010 -0700
@@ -138,24 +138,73 @@
/** A mapping that returns its type argument with every UndetVar replaced
* by its `inst' field. Throws a NoInstanceException
* if this not possible because an `inst' field is null.
+ * Note: mutually referring undertvars will be left uninstantiated
+ * (that is, they will be replaced by the underlying type-variable).
*/
+
Mapping getInstFun = new Mapping("getInstFun") {
public Type apply(Type t) {
switch (t.tag) {
- case UNKNOWN:
- throw ambiguousNoInstanceException
- .setMessage("undetermined.type");
- case UNDETVAR:
- UndetVar that = (UndetVar) t;
- if (that.inst == null)
+ case UNKNOWN:
throw ambiguousNoInstanceException
- .setMessage("type.variable.has.undetermined.type",
- that.qtype);
- return apply(that.inst);
- default:
- return t.map(this);
+ .setMessage("undetermined.type");
+ case UNDETVAR:
+ UndetVar that = (UndetVar) t;
+ if (that.inst == null)
+ throw ambiguousNoInstanceException
+ .setMessage("type.variable.has.undetermined.type",
+ that.qtype);
+ return isConstraintCyclic(that) ?
+ that.qtype :
+ apply(that.inst);
+ default:
+ return t.map(this);
}
}
+
+ private boolean isConstraintCyclic(UndetVar uv) {
+ Types.UnaryVisitor<Boolean> constraintScanner =
+ new Types.UnaryVisitor<Boolean>() {
+
+ List<Type> seen = List.nil();
+
+ Boolean visit(List<Type> ts) {
+ for (Type t : ts) {
+ if (visit(t)) return true;
+ }
+ return false;
+ }
+
+ public Boolean visitType(Type t, Void ignored) {
+ return false;
+ }
+
+ @Override
+ public Boolean visitClassType(ClassType t, Void ignored) {
+ if (t.isCompound()) {
+ return visit(types.supertype(t)) ||
+ visit(types.interfaces(t));
+ } else {
+ return visit(t.getTypeArguments());
+ }
+ }
+ @Override
+ public Boolean visitWildcardType(WildcardType t, Void ignored) {
+ return visit(t.type);
+ }
+
+ @Override
+ public Boolean visitUndetVar(UndetVar t, Void ignored) {
+ if (seen.contains(t)) {
+ return true;
+ } else {
+ seen = seen.prepend(t);
+ return visit(t.inst);
+ }
+ }
+ };
+ return constraintScanner.visit(uv);
+ }
};
/***************************************************************************
@@ -257,10 +306,9 @@
TypeVar tv = (TypeVar)uv.qtype;
ListBuffer<Type> hibounds = new ListBuffer<Type>();
for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS)) {
- if (!t.containsSome(that.tvars) && t.tag != BOT) {
- hibounds.append(t);
- }
+ hibounds.append(types.subst(t, that.tvars, undetvars));
}
+
List<Type> inst = that.getConstraints(tv, ConstraintKind.EQUAL);
if (inst.nonEmpty() && inst.head.tag != BOT) {
uv.inst = inst.head;
@@ -279,9 +327,32 @@
// check bounds
List<Type> targs = Type.map(undetvars, getInstFun);
- targs = types.subst(targs, that.tvars, targs);
+ if (Type.containsAny(targs, that.tvars)) {
+ //replace uninferred type-vars
+ targs = types.subst(targs,
+ that.tvars,
+ instaniateAsUninferredVars(undetvars, that.tvars));
+ }
return chk.checkType(warn.pos(), that.inst(targs, types), to);
}
+ //where
+ private List<Type> instaniateAsUninferredVars(List<Type> undetvars, List<Type> tvars) {
+ ListBuffer<Type> new_targs = ListBuffer.lb();
+ //step 1 - create syntethic captured vars
+ for (Type t : undetvars) {
+ UndetVar uv = (UndetVar)t;
+ Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null);
+ new_targs = new_targs.append(newArg);
+ }
+ //step 2 - replace synthetic vars in their bounds
+ for (Type t : new_targs.toList()) {
+ CapturedType ct = (CapturedType)t;
+ ct.bound = types.subst(ct.bound, tvars, new_targs.toList());
+ WildcardType wt = new WildcardType(ct.bound, BoundKind.EXTENDS, syms.boundClass);
+ ct.wildcard = wt;
+ }
+ return new_targs.toList();
+ }
/** Instantiate method type `mt' by finding instantiations of
* `tvars' so that method can be applied to `argtypes'.
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Sun Aug 29 22:42:08 2010 -0700
@@ -1079,14 +1079,21 @@
private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
- Scope typaramScope = new Scope(tree.sym);
+ Scope baseScope = new Scope(tree.sym);
+ //import already entered local classes into base scope
+ for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) {
+ if (e.sym.isLocal()) {
+ baseScope.enter(e.sym);
+ }
+ }
+ //import current type-parameters into base scope
if (tree.typarams != null)
for (List<JCTypeParameter> typarams = tree.typarams;
typarams.nonEmpty();
typarams = typarams.tail)
- typaramScope.enter(typarams.head.type.tsym);
+ baseScope.enter(typarams.head.type.tsym);
Env<AttrContext> outer = env.outer; // the base clause can't see members of this class
- Env<AttrContext> localEnv = outer.dup(tree, outer.info.dup(typaramScope));
+ Env<AttrContext> localEnv = outer.dup(tree, outer.info.dup(baseScope));
localEnv.baseClause = true;
localEnv.outer = outer;
localEnv.info.isSelfCall = false;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Sun Aug 29 22:42:08 2010 -0700
@@ -40,6 +40,8 @@
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Kinds.*;
import static com.sun.tools.javac.code.TypeTags.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
import javax.lang.model.element.ElementVisitor;
import java.util.Map;
@@ -1447,7 +1449,7 @@
Env<AttrContext> env,
Type site,
List<Type> argtypes,
- List<Type> typeargtypes, boolean reportErrors) {
+ List<Type> typeargtypes) {
Symbol sym = methodNotFound;
JCDiagnostic explanation = null;
List<MethodResolutionPhase> steps = methodResolutionSteps;
@@ -1466,11 +1468,20 @@
}
steps = steps.tail;
}
- if (sym.kind >= AMBIGUOUS && reportErrors) {
- String key = explanation == null ?
- "cant.apply.diamond" :
- "cant.apply.diamond.1";
- log.error(pos, key, diags.fragment("diamond", site.tsym), explanation);
+ if (sym.kind >= AMBIGUOUS) {
+ final JCDiagnostic details = explanation;
+ Symbol errSym = new ResolveError(WRONG_MTH, "diamond error") {
+ @Override
+ JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+ String key = details == null ?
+ "cant.apply.diamond" :
+ "cant.apply.diamond.1";
+ return diags.create(dkind, log.currentSource(), pos, key, diags.fragment("diamond", site.tsym), details);
+ }
+ };
+ MethodResolutionPhase errPhase = firstErroneousResolutionPhase();
+ sym = access(errSym, pos, site, names.init, true, argtypes, typeargtypes);
+ env.info.varArgs = errPhase.isVarargsRequired();
}
return sym;
}
@@ -1655,8 +1666,10 @@
List<Type> typeargtypes) {
JCDiagnostic d = error.getDiagnostic(JCDiagnostic.DiagnosticType.ERROR,
pos, site, name, argtypes, typeargtypes);
- if (d != null)
+ if (d != null) {
+ d.setFlag(DiagnosticFlag.RESOLVE_ERROR);
log.report(d);
+ }
}
private final LocalizedString noArgs = new LocalizedString("compiler.misc.no.args");
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Sun Aug 29 22:42:08 2010 -0700
@@ -1455,24 +1455,27 @@
List<Integer> gaps) {
if (startpc != endpc) {
List<JCExpression> subClauses = TreeInfo.isMultiCatch(tree) ?
- ((JCTypeDisjoint)tree.param.vartype).components :
- List.of(tree.param.vartype);
- for (JCExpression subCatch : subClauses) {
- int catchType = makeRef(tree.pos(), subCatch.type);
- List<Integer> lGaps = gaps;
- while (lGaps.nonEmpty()) {
- int end = lGaps.head.intValue();
+ ((JCTypeDisjoint)tree.param.vartype).components :
+ List.of(tree.param.vartype);
+ while (gaps.nonEmpty()) {
+ for (JCExpression subCatch : subClauses) {
+ int catchType = makeRef(tree.pos(), subCatch.type);
+ int end = gaps.head.intValue();
registerCatch(tree.pos(),
startpc, end, code.curPc(),
catchType);
- lGaps = lGaps.tail;
- startpc = lGaps.head.intValue();
- lGaps = lGaps.tail;
}
- if (startpc < endpc)
+ gaps = gaps.tail;
+ startpc = gaps.head.intValue();
+ gaps = gaps.tail;
+ }
+ if (startpc < endpc) {
+ for (JCExpression subCatch : subClauses) {
+ int catchType = makeRef(tree.pos(), subCatch.type);
registerCatch(tree.pos(),
startpc, endpc, code.curPc(),
catchType);
+ }
}
VarSymbol exparam = tree.param.sym;
code.statBegin(tree.pos);
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Sun Aug 29 22:42:08 2010 -0700
@@ -529,7 +529,7 @@
log.error("warnings.and.werror");
}
}
- return log.nerrors;
+ return log.nerrors;
}
protected final <T> Queue<T> stopIfError(CompileState cs, Queue<T> queue) {
@@ -868,7 +868,7 @@
/**
* Parses a list of files.
*/
- public List<JCCompilationUnit> parseFiles(List<JavaFileObject> fileObjects) throws IOException {
+ public List<JCCompilationUnit> parseFiles(Iterable<JavaFileObject> fileObjects) throws IOException {
if (shouldStop(CompileState.PARSE))
return List.nil();
@@ -981,14 +981,13 @@
*/
public JavaCompiler processAnnotations(List<JCCompilationUnit> roots,
List<String> classnames)
- throws IOException { // TODO: see TEMP note in JavacProcessingEnvironment
+ throws IOException { // TODO: see TEMP note in JavacProcessingEnvironment
if (shouldStop(CompileState.PROCESS)) {
- // Errors were encountered. If todo is empty, then the
- // encountered errors were parse errors. Otherwise, the
- // errors were found during the enter phase which should
- // be ignored when processing annotations.
-
- if (todo.isEmpty())
+ // Errors were encountered.
+ // If log.unrecoverableError is set, the errors were parse errors
+ // or other errors during enter which cannot be fixed by running
+ // any annotation processors.
+ if (log.unrecoverableError)
return this;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Sun Aug 29 22:42:08 2010 -0700
@@ -795,6 +795,13 @@
final JavaCompiler compiler;
/** The log for the round. */
final Log log;
+ /** The number of warnings in the previous round. */
+ final int priorWarnings;
+
+ /** The ASTs to be compiled. */
+ List<JCCompilationUnit> roots;
+ /** The classes to be compiler that have were generated. */
+ Map<String, JavaFileObject> genClassFiles;
/** The set of annotations to be processed this round. */
Set<TypeElement> annotationsPresent;
@@ -803,10 +810,12 @@
/** The set of package-info files to be processed this round. */
List<PackageSymbol> packageInfoFiles;
- /** Create a round. */
- Round(Context context, int number) {
+ /** Create a round (common code). */
+ private Round(Context context, int number, int priorWarnings) {
this.context = context;
this.number = number;
+ this.priorWarnings = priorWarnings;
+
compiler = JavaCompiler.instance(context);
log = Log.instance(context);
@@ -814,15 +823,86 @@
JavacProcessingEnvironment.this.context = context;
// the following will be populated as needed
- annotationsPresent = new LinkedHashSet<TypeElement>();
topLevelClasses = List.nil();
packageInfoFiles = List.nil();
}
+ /** Create the first round. */
+ Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols) {
+ this(context, 1, 0);
+ this.roots = roots;
+ genClassFiles = new HashMap<String,JavaFileObject>();
+
+ compiler.todo.clear(); // free the compiler's resources
+
+ // The reverse() in the following line is to maintain behavioural
+ // compatibility with the previous revision of the code. Strictly speaking,
+ // it should not be necessary, but a javah golden file test fails without it.
+ topLevelClasses =
+ getTopLevelClasses(roots).prependList(classSymbols.reverse());
+
+ packageInfoFiles = getPackageInfoFiles(roots);
+
+ findAnnotationsPresent();
+ }
+
+ /** Create a new round. */
+ private Round(Round prev,
+ Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles)
+ throws IOException {
+ this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings);
+ this.genClassFiles = prev.genClassFiles;
+
+ updateProcessingState();
+
+ List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
+ roots = cleanTrees(prev.roots).appendList(parsedFiles);
+
+ // Check for errors after parsing
+ if (unrecoverableError())
+ return;
+
+ enterClassFiles(genClassFiles);
+ List<ClassSymbol> newClasses = enterClassFiles(newClassFiles);
+ genClassFiles.putAll(newClassFiles);
+ enterTrees(roots);
+
+ if (unrecoverableError())
+ return;
+
+ topLevelClasses = join(
+ getTopLevelClasses(parsedFiles),
+ getTopLevelClassesFromClasses(newClasses));
+
+ packageInfoFiles = join(
+ getPackageInfoFiles(parsedFiles),
+ getPackageInfoFilesFromClasses(newClasses));
+
+ findAnnotationsPresent();
+ }
+
/** Create the next round to be used. */
- Round next() {
- compiler.close(false);
- return new Round(contextForNextRound(), number + 1);
+ Round next(Set<JavaFileObject> newSourceFiles, Map<String, JavaFileObject> newClassFiles)
+ throws IOException {
+ try {
+ return new Round(this, newSourceFiles, newClassFiles);
+ } finally {
+ compiler.close(false);
+ }
+ }
+
+ /** Create the compiler to be used for the final compilation. */
+ JavaCompiler finalCompiler(boolean errorStatus) {
+ try {
+ JavaCompiler c = JavaCompiler.instance(nextContext());
+ if (errorStatus) {
+ c.log.nwarnings += priorWarnings + compiler.log.nwarnings;
+ c.log.nerrors += compiler.log.nerrors;
+ }
+ return c;
+ } finally {
+ compiler.close(false);
+ }
}
/** Return the number of errors found so far in this round.
@@ -839,12 +919,16 @@
/** Return whether or not an unrecoverable error has occurred. */
boolean unrecoverableError() {
- return log.unrecoverableError;
+ return log.unrecoverableError
+ || messager.errorRaised()
+ || (werror && log.nwarnings > 0)
+ || (fatalErrors && log.nerrors > 0);
}
/** Find the set of annotations present in the set of top level
- * classes and package info files to be processed this round. */
- void findAnnotationsPresent(ComputeAnnotationSet annotationComputer) {
+ * classes and package info files to be processed this round. */
+ void findAnnotationsPresent() {
+ ComputeAnnotationSet annotationComputer = new ComputeAnnotationSet(elementUtils);
// Use annotation processing to compute the set of annotations present
annotationsPresent = new LinkedHashSet<TypeElement>();
for (ClassSymbol classSym : topLevelClasses)
@@ -853,26 +937,13 @@
annotationComputer.scan(pkgSym, annotationsPresent);
}
- /**
- * Parse the latest set of generated source files created by the filer.
- */
- List<JCCompilationUnit> parseNewSourceFiles()
- throws IOException {
- List<JavaFileObject> fileObjects = List.nil();
- for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
- fileObjects = fileObjects.prepend(jfo);
- }
-
- return compiler.parseFiles(fileObjects);
- }
-
- /** Enter the latest set of generated class files created by the filer. */
- List<ClassSymbol> enterNewClassFiles() {
+ /** Enter a set of generated class files. */
+ List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
ClassReader reader = ClassReader.instance(context);
Names names = Names.instance(context);
List<ClassSymbol> list = List.nil();
- for (Map.Entry<String,JavaFileObject> entry : filer.getGeneratedClasses().entrySet()) {
+ for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
Name name = names.fromString(entry.getKey());
JavaFileObject file = entry.getValue();
if (file.getKind() != JavaFileObject.Kind.CLASS)
@@ -900,11 +971,7 @@
/** Run a processing round. */
void run(boolean lastRound, boolean errorStatus) {
-// assert lastRound
-// ? (topLevelClasses.size() == 0 && annotationsPresent.size() == 0)
-// : (errorStatus == false);
-//
-// printRoundInfo(topLevelClasses, annotationsPresent, lastRound);
+ printRoundInfo(lastRound);
TaskListener taskListener = context.get(TaskListener.class);
if (taskListener != null)
@@ -912,7 +979,6 @@
try {
if (lastRound) {
- printRoundInfo(List.<ClassSymbol>nil(), Collections.<TypeElement>emptySet(), lastRound);
filer.setLastRound(true);
Set<Element> emptyRootElements = Collections.emptySet(); // immutable
RoundEnvironment renv = new JavacRoundEnvironment(true,
@@ -921,7 +987,6 @@
JavacProcessingEnvironment.this);
discoveredProcs.iterator().runContributingProcs(renv);
} else {
- printRoundInfo(topLevelClasses, annotationsPresent, lastRound);
discoverAndRunProcs(context, annotationsPresent, topLevelClasses, packageInfoFiles);
}
} finally {
@@ -931,11 +996,7 @@
}
/** Update the processing state for the current context. */
- // Question: should this not be part of next()?
- // Note: Calling it from next() breaks some tests. There is an issue
- // whether the annotationComputer is using elementUtils with the
- // correct context.
- void updateProcessingState() {
+ private void updateProcessingState() {
filer.newRound(context);
messager.newRound(context);
@@ -944,14 +1005,14 @@
}
/** Print info about this round. */
- private void printRoundInfo(List<ClassSymbol> topLevelClasses,
- Set<TypeElement> annotationsPresent,
- boolean lastRound) {
+ private void printRoundInfo(boolean lastRound) {
if (printRounds || verbose) {
+ List<ClassSymbol> tlc = lastRound ? List.<ClassSymbol>nil() : topLevelClasses;
+ Set<TypeElement> ap = lastRound ? Collections.<TypeElement>emptySet() : annotationsPresent;
log.printNoteLines("x.print.rounds",
- (!lastRound ? number : number + 1),
- "{" + topLevelClasses.toString(", ") + "}",
- annotationsPresent,
+ number,
+ "{" + tlc.toString(", ") + "}",
+ ap,
lastRound);
}
}
@@ -960,7 +1021,7 @@
* Important values are propogated from round to round;
* other values are implicitly reset.
*/
- private Context contextForNextRound() {
+ private Context nextContext() {
Context next = new Context();
Options options = Options.instance(context);
@@ -1025,138 +1086,90 @@
Iterable<? extends PackageSymbol> pckSymbols)
throws IOException {
+ TaskListener taskListener = context.get(TaskListener.class);
log = Log.instance(context);
- Round round = new Round(context, 1);
- round.compiler.todo.clear(); // free the compiler's resources
-
- // The reverse() in the following line is to maintain behavioural
- // compatibility with the previous revision of the code. Strictly speaking,
- // it should not be necessary, but a javah golden file test fails without it.
- round.topLevelClasses =
- getTopLevelClasses(roots).prependList(classSymbols.reverse());
-
- round.packageInfoFiles = getPackageInfoFiles(roots);
-
Set<PackageSymbol> specifiedPackages = new LinkedHashSet<PackageSymbol>();
for (PackageSymbol psym : pckSymbols)
specifiedPackages.add(psym);
this.specifiedPackages = Collections.unmodifiableSet(specifiedPackages);
- ComputeAnnotationSet annotationComputer = new ComputeAnnotationSet(elementUtils);
- round.findAnnotationsPresent(annotationComputer);
-
- boolean errorStatus = false;
+ Round round = new Round(context, roots, classSymbols);
- runAround:
- while (true) {
- if ((fatalErrors && round.errorCount() != 0)
- || (werror && round.warningCount() != 0)) {
- errorStatus = true;
- break runAround;
- }
-
+ boolean errorStatus;
+ boolean moreToDo;
+ do {
+ // Run processors for round n
round.run(false, false);
- /*
- * Processors for round n have run to completion. Prepare
- * for round (n+1) by checked for errors raised by
- * annotation processors and then checking for syntax
- * errors on any generated source files.
- */
- if (messager.errorRaised()) {
- errorStatus = true;
- break runAround;
- }
-
- if (!moreToDo())
- break runAround; // No new files
-
- round = round.next();
-
- List<JCCompilationUnit> parsedFiles = round.parseNewSourceFiles();
- roots = cleanTrees(roots).appendList(parsedFiles);
+ // Processors for round n have run to completion.
+ // Check for errors and whether there is more work to do.
+ errorStatus = round.unrecoverableError();
+ moreToDo = moreToDo();
- // Check for errors after parsing
- if (round.unrecoverableError()) {
- errorStatus = true;
- break runAround;
- }
-
- List<ClassSymbol> newClasses = round.enterNewClassFiles();
- round.enterTrees(roots);
+ // Set up next round.
+ // Copy mutable collections returned from filer.
+ round = round.next(
+ new LinkedHashSet<JavaFileObject>(filer.getGeneratedSourceFileObjects()),
+ new LinkedHashMap<String,JavaFileObject>(filer.getGeneratedClasses()));
- round.topLevelClasses = join(
- getTopLevelClasses(parsedFiles),
- getTopLevelClassesFromClasses(newClasses));
+ // Check for errors during setup.
+ if (round.unrecoverableError())
+ errorStatus = true;
- round.packageInfoFiles = join(
- getPackageInfoFiles(parsedFiles),
- getPackageInfoFilesFromClasses(newClasses));
-
- round.findAnnotationsPresent(annotationComputer);
- round.updateProcessingState();
- }
+ } while (moreToDo && !errorStatus);
// run last round
round.run(true, errorStatus);
- // Add any sources generated during the last round to the set
- // of files to be compiled.
- if (moreToDo()) {
- List<JCCompilationUnit> parsedFiles = round.parseNewSourceFiles();
- roots = cleanTrees(roots).appendList(parsedFiles);
- }
-
- // Set error status for any files compiled and generated in
- // the last round
- if (round.unrecoverableError() || (werror && round.warningCount() != 0))
- errorStatus = true;
-
- round = round.next();
-
filer.warnIfUnclosedFiles();
warnIfUnmatchedOptions();
- /*
- * If an annotation processor raises an error in a round,
- * that round runs to completion and one last round occurs.
- * The last round may also occur because no more source or
- * class files have been generated. Therefore, if an error
- * was raised on either of the last *two* rounds, the compile
- * should exit with a nonzero exit code. The current value of
- * errorStatus holds whether or not an error was raised on the
- * second to last round; errorRaised() gives the error status
- * of the last round.
- */
- errorStatus = errorStatus || messager.errorRaised();
+ /*
+ * If an annotation processor raises an error in a round,
+ * that round runs to completion and one last round occurs.
+ * The last round may also occur because no more source or
+ * class files have been generated. Therefore, if an error
+ * was raised on either of the last *two* rounds, the compile
+ * should exit with a nonzero exit code. The current value of
+ * errorStatus holds whether or not an error was raised on the
+ * second to last round; errorRaised() gives the error status
+ * of the last round.
+ */
+ if (messager.errorRaised()
+ || werror && round.warningCount() > 0 && round.errorCount() > 0)
+ errorStatus = true;
+
+ Set<JavaFileObject> newSourceFiles =
+ new LinkedHashSet<JavaFileObject>(filer.getGeneratedSourceFileObjects());
+ roots = cleanTrees(round.roots);
+
+ JavaCompiler compiler = round.finalCompiler(errorStatus);
+
+ if (newSourceFiles.size() > 0)
+ roots = roots.appendList(compiler.parseFiles(newSourceFiles));
+
+ errorStatus = errorStatus || (compiler.errorCount() > 0);
// Free resources
this.close();
- TaskListener taskListener = this.context.get(TaskListener.class);
if (taskListener != null)
taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
- JavaCompiler compiler;
-
if (errorStatus) {
- compiler = round.compiler;
- compiler.log.nwarnings += messager.warningCount();
- compiler.log.nerrors += messager.errorCount();
if (compiler.errorCount() == 0)
compiler.log.nerrors++;
- } else if (procOnly && !foundTypeProcessors) {
- compiler = round.compiler;
+ return compiler;
+ }
+
+ if (procOnly && !foundTypeProcessors) {
compiler.todo.clear();
- } else { // Final compilation
- round = round.next();
- round.updateProcessingState();
- compiler = round.compiler;
+ } else {
if (procOnly && foundTypeProcessors)
compiler.shouldStopPolicy = CompileState.FLOW;
- compiler.enterTrees(cleanTrees(roots));
+ compiler.enterTrees(roots);
}
return compiler;
@@ -1185,7 +1198,9 @@
for (JCCompilationUnit unit : units) {
for (JCTree node : unit.defs) {
if (node.getTag() == JCTree.CLASSDEF) {
- classes = classes.prepend(((JCClassDecl) node).sym);
+ ClassSymbol sym = ((JCClassDecl) node).sym;
+ assert sym != null;
+ classes = classes.prepend(sym);
}
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Sun Aug 29 22:42:08 2010 -0700
@@ -42,7 +42,9 @@
compiler.err.already.defined.this.unit=\
{0} is already defined in this compilation unit
compiler.err.annotation.missing.default.value=\
- annotation {0} is missing {1}
+ annotation {0} is missing value for the attribute {1}
+compiler.err.annotation.missing.default.value.1=\
+ annotation {0} is missing values for attributes {1}
compiler.err.annotation.not.valid.for.type=\
annotation not valid for a value of type {0}
compiler.err.annotation.type.not.applicable=\
--- a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java Sun Aug 29 22:42:08 2010 -0700
@@ -25,8 +25,10 @@
package com.sun.tools.javac.util;
+import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
+import java.util.Set;
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
@@ -83,7 +85,7 @@
*/
public JCDiagnostic error(
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return create(ERROR, null, true, source, pos, key, args);
+ return create(ERROR, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
}
/**
@@ -96,7 +98,7 @@
*/
public JCDiagnostic mandatoryWarning(
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return create(WARNING, null, true, source, pos, key, args);
+ return create(WARNING, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
}
/**
@@ -111,7 +113,7 @@
public JCDiagnostic mandatoryWarning(
LintCategory lc,
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return create(WARNING, lc, true, source, pos, key, args);
+ return create(WARNING, lc, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
}
/**
@@ -123,7 +125,7 @@
*/
public JCDiagnostic warning(
LintCategory lc, String key, Object... args) {
- return create(WARNING, lc, false, null, null, key, args);
+ return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
}
/**
@@ -135,7 +137,7 @@
*/
public JCDiagnostic warning(
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return create(WARNING, null, false, source, pos, key, args);
+ return create(WARNING, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
}
/**
@@ -149,7 +151,7 @@
*/
public JCDiagnostic warning(
LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return create(WARNING, lc, false, source, pos, key, args);
+ return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
}
/**
@@ -159,7 +161,7 @@
* @see MandatoryWarningHandler
*/
public JCDiagnostic mandatoryNote(DiagnosticSource source, String key, Object... args) {
- return create(NOTE, null, true, source, null, key, args);
+ return create(NOTE, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, null, key, args);
}
/**
@@ -168,7 +170,7 @@
* @param args Fields of the message.
*/
public JCDiagnostic note(String key, Object... args) {
- return create(NOTE, null, false, null, null, key, args);
+ return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
}
/**
@@ -180,7 +182,7 @@
*/
public JCDiagnostic note(
DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return create(NOTE, null, false, source, pos, key, args);
+ return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
}
/**
@@ -189,7 +191,7 @@
* @param args Fields of the message.
*/
public JCDiagnostic fragment(String key, Object... args) {
- return create(FRAGMENT, null, false, null, null, key, args);
+ return create(FRAGMENT, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
}
/**
@@ -204,7 +206,7 @@
*/
public JCDiagnostic create(
DiagnosticType kind, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return create(kind, null, false, source, pos, key, args);
+ return create(kind, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
}
/**
@@ -218,8 +220,8 @@
* @param args Fields of the message.
*/
public JCDiagnostic create(
- DiagnosticType kind, LintCategory lc, boolean isMandatory, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
- return new JCDiagnostic(formatter, kind, lc, isMandatory, source, pos, qualify(kind, key), args);
+ DiagnosticType kind, LintCategory lc, Set<DiagnosticFlag> flags, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
+ return new JCDiagnostic(formatter, kind, lc, flags, source, pos, qualify(kind, key), args);
}
protected String qualify(DiagnosticType t, String key) {
@@ -240,7 +242,7 @@
return new JCDiagnostic(getFragmentFormatter(),
FRAGMENT,
null,
- false,
+ EnumSet.noneOf(DiagnosticFlag.class),
null,
null,
"compiler." + FRAGMENT.key + "." + key,
@@ -327,6 +329,11 @@
private final int pos;
}
+ public enum DiagnosticFlag {
+ MANDATORY,
+ RESOLVE_ERROR
+ }
+
private final DiagnosticType type;
private final DiagnosticSource source;
private final DiagnosticPosition position;
@@ -334,7 +341,7 @@
private final int column;
private final String key;
protected final Object[] args;
- private final boolean mandatory;
+ private final Set<DiagnosticFlag> flags;
private final LintCategory lintCategory;
/**
@@ -350,7 +357,7 @@
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
DiagnosticType dt,
LintCategory lc,
- boolean mandatory,
+ Set<DiagnosticFlag> flags,
DiagnosticSource source,
DiagnosticPosition pos,
String key,
@@ -361,7 +368,7 @@
this.defaultFormatter = formatter;
this.type = dt;
this.lintCategory = lc;
- this.mandatory = mandatory;
+ this.flags = flags;
this.source = source;
this.position = pos;
this.key = key;
@@ -401,7 +408,7 @@
* @return true if this diagnostic is required to be shown.
*/
public boolean isMandatory() {
- return mandatory;
+ return flags.contains(DiagnosticFlag.MANDATORY);
}
/**
@@ -520,8 +527,9 @@
case NOTE:
return Diagnostic.Kind.NOTE;
case WARNING:
- return mandatory ? Diagnostic.Kind.MANDATORY_WARNING
- : Diagnostic.Kind.WARNING;
+ return flags.contains(DiagnosticFlag.MANDATORY)
+ ? Diagnostic.Kind.MANDATORY_WARNING
+ : Diagnostic.Kind.WARNING;
case ERROR:
return Diagnostic.Kind.ERROR;
default:
@@ -537,6 +545,14 @@
return defaultFormatter.formatMessage(this, locale);
}
+ public void setFlag(DiagnosticFlag flag) {
+ flags.add(flag);
+ }
+
+ public boolean isFlagSet(DiagnosticFlag flag) {
+ return flags.contains(flag);
+ }
+
public static class MultilineDiagnostic extends JCDiagnostic {
private final List<JCDiagnostic> subdiagnostics;
@@ -545,7 +561,7 @@
super(other.defaultFormatter,
other.getType(),
other.getLintCategory(),
- other.isMandatory(),
+ other.flags,
other.getDiagnosticSource(),
other.position,
other.getCode(),
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6857948/T6857948.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6857948
+ * @summary 6857948: Calling a constructor with a doubly bogus argument causes an internal error
+ * @author Maurizio Cimadamore
+ *
+ * @compile/fail/ref=T6857948.out -XDrawDiagnostics T6857948.java
+ */
+
+class Foo {
+ Foo(String v) {}
+};
+
+class Test {
+ public static void main() {
+ Foo f = new Foo("Hello!",nosuchfunction()) {};
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6857948/T6857948.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,3 @@
+T6857948.java:16:32: compiler.err.cant.resolve.location.args: kindname.method, nosuchfunction, , , kindname.class, Test
+T6857948.java:16:50: compiler.err.cant.apply.symbol: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, null
+2 errors
--- a/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/Diagnostics/6862608/T6862608a.out Sun Aug 29 22:42:08 2010 -0700
@@ -1,3 +1,3 @@
-T6862608a.java:19:41: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>, java.util.List<java.util.Comparator<?>>)
+T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String>
- compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, java.lang.Object, kindname.method, <T>compound(java.lang.Iterable<? extends java.util.Comparator<? super T>>))}
1 error
--- a/langtools/test/tools/javac/T6358024.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/T6358024.java Sun Aug 29 22:42:08 2010 -0700
@@ -60,7 +60,7 @@
new Option[] { new XOption("-XprintRounds"),
new Option("-processorpath", "."),
new Option("-processor", self) },
- 11);
+ 12);
}
static void test(JavacFileManager fm, JavaFileObject f, Option[] opts, int expect) throws Throwable {
--- a/langtools/test/tools/javac/T6403466.out Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/T6403466.out Sun Aug 29 22:42:08 2010 -0700
@@ -13,6 +13,10 @@
Finished TaskEvent[ENTER,T6403466Wrapper.java,null]
Started TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
Finished TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
+Started TaskEvent[ENTER,T6403466.java,null]
+Started TaskEvent[ENTER,T6403466Wrapper.java,null]
+Finished TaskEvent[ENTER,T6403466.java,null]
+Finished TaskEvent[ENTER,T6403466Wrapper.java,null]
Started TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
Finished TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
Finished TaskEvent[ANNOTATION_PROCESSING,null,null]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T6977800.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6977800
+ * @summary Regression: invalid resolution of supertype for local class
+ * @compile T6977800.java
+ */
+
+class T6977800 {
+ public static void test() {
+ class A {
+ int x = 1;
+ }
+ class B extends A {}
+ System.out.println(new B().x);
+ }
+
+ static class A {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/6881115/T6881115.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6881115 6976649
+ * @summary javac permits nested anno w/o mandatory attrs => IncompleteAnnotationException
+ * @author mcimadamore
+ * @compile/fail/ref=T6881115.out -XDrawDiagnostics T6881115.java
+ */
+
+@interface A {
+ B b() default @B(b2 = 1, b2 = 2);
+ B[] b_arr() default {@B(), @B(b2 = 1, b2 = 2)};
+}
+@interface B {
+ String b1();
+ int b2();
+}
+@A(b = @B(b2 = 1, b2 = 2),
+ b_arr = {@B(), @B(b2 = 1, b2 = 2)})
+class T6881115<@A(b = @B(b2 = 1, b2 = 2),
+ b_arr = {@B(), @B(b2 = 1, b2 = 2)}) X> {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/6881115/T6881115.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,16 @@
+T6881115.java:10:30: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:10:19: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:11:26: compiler.err.annotation.missing.default.value.1: B, b1,b2
+T6881115.java:11:43: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:11:32: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:17:19: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:17:8: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:18:13: compiler.err.annotation.missing.default.value.1: B, b1,b2
+T6881115.java:18:30: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:18:19: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:19:34: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:19:23: compiler.err.annotation.missing.default.value: B, b1
+T6881115.java:20:28: compiler.err.annotation.missing.default.value.1: B, b1,b2
+T6881115.java:20:45: compiler.err.duplicate.annotation.member.value: b2, B
+T6881115.java:20:34: compiler.err.annotation.missing.default.value: B, b1
+15 errors
--- a/langtools/test/tools/javac/annotations/pos/TrailingComma.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/annotations/pos/TrailingComma.java Sun Aug 29 22:42:08 2010 -0700
@@ -36,7 +36,7 @@
}
-@TestAnnotation({@SuppressWarnings(),
+@TestAnnotation({@SuppressWarnings({}),
@SuppressWarnings({"Beware the ides of March.",}),
@SuppressWarnings({"Look both ways", "Before Crossing",}), })
public class TrailingComma {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6270087/T6270087.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6270087 6932571
+ * @summary Javac rejects legal cast
+ * @compile T6270087.java
+ */
+
+class T6270087 {
+
+ static class Foo<X> {}
+
+ <S extends Comparable<S>> void test1(Comparable<Integer> c) {
+ Object o = (Comparable<S>)c;
+ }
+
+ <U extends Throwable, V extends Runnable> void test2(Foo<V> lv) {
+ Object o = (Foo<U>) lv;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6270087/T6270087neg.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6270087 6932571
+ * @summary Javac rejects legal cast
+ * @compile/fail/ref=T6270087neg.out -XDrawDiagnostics T6270087neg.java
+ */
+
+class T6270087neg {
+
+ static class Foo<X> {}
+
+ <U extends Integer, V extends String> void test2(Foo<V> lv) {
+ Object o = (Foo<U>) lv;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6270087/T6270087neg.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,2 @@
+T6270087neg.java:36:29: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6270087neg.Foo<V>, T6270087neg.Foo<U>
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6507317/T6507317.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6507317 6932571
+ * @summary Problem when casting from parametrized type to concrete class
+ * @compile T6507317.java
+ */
+
+import java.util.Comparator;
+
+abstract class T6507317<T extends Comparable<T>> implements Comparator<T> {
+ void test(T t) {
+ String s = (String)t;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6569057/T6569057.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6569057 6932571
+ * @summary Generics regression on cast
+ * @compile T6569057.java
+ */
+
+class T6569057 {
+ static class A<X extends B<?>> { }
+
+ static class B<X extends A<?>> {
+ D<? extends B<X>> get() { return null; }
+ }
+
+ static class D<Y extends B<?>> {}
+
+ <E extends B<?>> void test(E x, D<B<A<?>>> d) {
+ boolean b = x.get() == d;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6932571/T6932571a.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6932571
+ * @summary Compiling Generics causing Inconvertible types
+ * @compile T6932571a.java
+ */
+
+class T6932571a {
+ static class A<T extends Comparable<? super T>> {
+ public void test(T v) {
+ Object obj = (Integer)v;
+ }
+ }
+
+ static class B<T extends Comparable<? extends T>> {
+ public void test(T v) {
+ Object obj = (Integer)v;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6932571/T6932571b.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6932571
+ * @summary Compiling Generics causing Inconvertible types
+ * @compile T6932571b.java
+ */
+
+class T6932571b {
+
+ interface A1<T extends B<? super T>> {
+ public T getT();
+ }
+
+ interface A2<T extends B<? extends T>> {
+ public T getT();
+ }
+
+ class B<T extends B<T>> {}
+
+ class C extends B<C> {}
+
+ void test1(A1<?> a) {
+ Object o = (C)a.getT();
+ }
+
+ void test2(A2<?> a) {
+ Object o = (C)a.getT();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6932571/T6932571neg.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6932571
+ * @summary Compiling Generics causing Inconvertible types
+ * @compile/fail/ref=T6932571neg.out -XDrawDiagnostics T6932571neg.java
+ */
+
+class T6932571neg {
+ interface I<T>{ }
+ interface I1 extends I<String> {}
+ static class Y implements I<String> {}
+ final static class S implements I<String> {}
+
+ <G extends I<G>> void test() {
+ S s = new S();
+ G g = (G) s;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6932571/T6932571neg.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,2 @@
+T6932571neg.java:39:19: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6932571neg.S, G
+1 error
--- a/langtools/test/tools/javac/diags/Example.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/diags/Example.java Sun Aug 29 22:42:08 2010 -0700
@@ -421,7 +421,7 @@
if (verbose)
System.err.println("run_simple: " + opts + " " + files);
- List<String> args = new ArrayList<String>(opts);
+ List<String> args = new ArrayList<String>();
if (keys != null || raw)
args.add("-XDrawDiagnostics");
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt Sun Aug 29 22:42:08 2010 -0700
@@ -64,6 +64,7 @@
compiler.misc.fatal.err.cant.locate.meth # Resolve, from Lower
compiler.misc.file.does.not.contain.package
compiler.misc.illegal.start.of.class.file
+compiler.misc.inferred.do.not.conform.to.params # UNUSED (hard to see if very complex inference scenario might require this though, so leaving it in, as per JLS3)
compiler.misc.kindname.annotation
compiler.misc.kindname.enum
compiler.misc.kindname.package
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/AnnotationMissingValues1.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.annotation.missing.default.value.1
+
+@interface Anno {
+ String a();
+ String b();
+}
+
+@Anno
+class AnnotationMissingValue { }
--- a/langtools/test/tools/javac/diags/examples/InvalidInferredTypes.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/diags/examples/InvalidInferredTypes.java Sun Aug 29 22:42:08 2010 -0700
@@ -22,17 +22,17 @@
*/
// key: compiler.err.invalid.inferred.types
-// key: compiler.misc.inferred.do.not.conform.to.params
+// key: compiler.misc.inferred.do.not.conform.to.bounds
import java.util.*;
class InvalidInferredTypes {
- <T> Comparator<T> compound(Iterable<? extends Comparator<? super T>> it) {
+ <T extends List<? super T>> T makeList() {
return null;
}
- public void test(List<Comparator<?>> x) {
- Comparator<String> c3 = compound(x);
+ public void test() {
+ List<? super String> l = makeList();
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6369605/T6369605a.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6369605
+ * @summary Unconstrained type variables fails to include bounds
+ * @author mcimadamore
+ * @compile T6369605a.java
+ */
+import java.util.List;
+
+class T6369605a {
+ static <T extends List<T>> T m1() {
+ return null;
+ }
+
+ static <T extends List<U>, U extends List<T>> T m2() {
+ return null;
+ }
+
+ static <T extends List<U>, U extends List<V>, V extends List<T>> T m3() {
+ return null;
+ }
+
+ List<?> l1 = m1();
+ List<?> l2 = m2();
+ List<?> l3 = m3();
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6369605/T6369605b.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6369605
+ * @summary Unconstrained type variables fails to include bounds
+ * @author mcimadamore
+ * @compile T6369605b.java
+ */
+import java.util.List;
+
+class T6369605b {
+ static <T extends List<X>, X> List<T> m1() {
+ return null;
+ }
+
+ static <T extends List<U>, U extends List<X>, X> List<T> m2() {
+ return null;
+ }
+
+ static <T extends List<U>, U extends List<V>, V extends List<X>, X> List<T> m3() {
+ return null;
+ }
+
+ List<?> l1 = m1();
+ List<?> l2 = m2();
+ List<?> l3 = m3();
+}
--- a/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out Sun Aug 29 22:42:08 2010 -0700
@@ -1,2 +1,2 @@
-T6638712a.java:16:41: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>, java.util.List<java.util.Comparator<?>>)
+T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String>
1 error
--- a/langtools/test/tools/javac/generics/typevars/5060485/Compatibility.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/generics/typevars/5060485/Compatibility.java Sun Aug 29 22:42:08 2010 -0700
@@ -26,7 +26,7 @@
* @bug 5060485
* @summary The scope of a class type parameter is too wide
* @author Peter von der Ah\u00e9
- * @compile/fail Compatibility.java
+ * @compile/fail/ref=Compatibility.out -XDrawDiagnostics Compatibility.java
*/
class NumberList<T extends Number> {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typevars/5060485/Compatibility.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,2 @@
+Compatibility.java:36:35: compiler.err.not.within.bounds: Test.Y
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typevars/5060485/Compatibility02.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2006, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 5060485 6977800
+ * @summary The scope of a class type parameter is too wide
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=Compatibility02.out -XDrawDiagnostics Compatibility.java
+ */
+
+class NumberList<T extends Number> {}
+
+class Test {
+ <Y extends Number> void m() {
+ static class Y {}
+ class Y1<S extends NumberList<Y>> {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typevars/5060485/Compatibility02.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,2 @@
+Compatibility.java:36:35: compiler.err.not.within.bounds: Test.Y
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/wildcards/6886247/T6886247_1.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6886247
+ * @author Maurizio Cimadamore
+ * @summary regression: javac crashes with an assertion error in Attr.java
+ * @compile T6886247_1.java
+ */
+class Outer<E> {
+
+ public void method(Outer<? extends E>.Inner inner) {
+ E entry = inner.getE();
+ }
+
+ class Inner {
+ E getE() {return null;}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/wildcards/6886247/T6886247_2.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6886247
+ * @author Maurizio Cimadamore
+ * @summary regression: javac crashes with an assertion error in Attr.java
+ * @compile/fail/ref=T6886247_2.out -XDrawDiagnostics T6886247_2.java
+ */
+
+class Outer<E> {
+
+ public void method(Outer<?>.Inner inner) {
+ E entry = inner.getE();
+ }
+
+ class Inner {
+ E getE() {return null;}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/wildcards/6886247/T6886247_2.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,2 @@
+T6886247_2.java:35:28: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.type.captureof: 1, ?, E
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/T6978574.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6978574
+ * @summary return statement in try block with multi-catch causes ClassFormatError
+ */
+
+public class T6978574 {
+ static class A extends Exception { }
+ static class B extends Exception { }
+
+ static void foo() throws A { throw new A(); }
+ static void bar() throws B { throw new B(); }
+
+ static void test(boolean b) {
+ try {
+ if (b) foo(); else bar();
+ return; // This should *not* cause ClassFormatError
+ } catch (final A | B e ) { caught = true; }
+ return;
+ }
+
+ static boolean caught = false;
+
+ public static void main(String[] args) {
+ test(true);
+ if (!caught) throw new AssertionError();
+ caught = false;
+ test(false);
+ if (!caught) throw new AssertionError();
+ }
+}
--- a/langtools/test/tools/javac/processing/filer/TestLastRound.out Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/processing/filer/TestLastRound.out Sun Aug 29 22:42:08 2010 -0700
@@ -1,3 +1,4 @@
- compiler.warn.proc.file.create.last.round: LastRound.java
- compiler.err.warnings.and.werror
1 error
+1 warning
--- a/langtools/test/tools/javac/warnings/6747671/T6747671.java Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/warnings/6747671/T6747671.java Sun Aug 29 22:42:08 2010 -0700
@@ -27,8 +27,8 @@
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
+ boolean b = arg1 instanceof A;//ok
+ Object a = (A)arg1;//ok
A a2 = new A() {};//raw warning (2)
a2.new Z() {};//raw warning
}
--- a/langtools/test/tools/javac/warnings/6747671/T6747671.out Wed Jul 05 17:20:50 2017 +0200
+++ b/langtools/test/tools/javac/warnings/6747671/T6747671.out Sun Aug 29 22:42:08 2010 -0700
@@ -4,9 +4,7 @@
T6747671.java:27:14: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
T6747671.java:27:7: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
T6747671.java:29:28: compiler.warn.raw.class.use: T6747671.B, T6747671.B<X>
-T6747671.java:30:37: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
-T6747671.java:31:21: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
T6747671.java:32:9: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
T6747671.java:32:20: compiler.warn.raw.class.use: T6747671.A, T6747671<E>.A<X>
T6747671.java:33:16: compiler.warn.raw.class.use: T6747671.A.Z, T6747671<E>.A<X>.Z<Y>
-11 warnings
+9 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/6885255/T6885255.java Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,31 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 6885255
+ * @summary -Xlint:rawtypes
+ * @compile/ref=T6885255.out -XDrawDiagnostics -Xlint:rawtypes T6885255.java
+ */
+
+class T6885255 {
+
+ static class Test<X, Y> {}
+
+ Class<Test> ct; //no warn - outer Class w/ raw param
+ Class<Test<Test, Test>> ctt; //warn - outer Class w/o raw param (2)
+
+ Class<Class<Test>> cct; //warn - outer Class w/o raw param
+ Class<Class<Test<Test, Test>>> cctt; //warn - outer Class w/o raw param (2)
+
+ Object o1 = (Test)null; //no warn - outer raw and cast
+ Object o2 = (Test<Test, Test>)null; //warn - inner raw (2)
+
+ Object o3 = (Class)null; //no warn - outer raw and cast
+ Object o4 = (Class<Test>)null; //no warn - outer Class w/ raw param
+
+ Object o5 = (Class<Test<Test, Test>>)null; //warn - outer Class w/ non raw param (2)
+ Object o6 = (Class<Class<Test<Test, Test>>>)null; //warn - outer Class w/ non raw param (2)
+
+ Object o7 = (Test<Class, Class>)null; //warn - inner raw (2)
+ Object o8 = (Test<Class<Test>, Class<Test>>)null; //warn - inner Class (2)
+
+ boolean b = null instanceof Test; //no warn - raw and instanceof
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/warnings/6885255/T6885255.out Sun Aug 29 22:42:08 2010 -0700
@@ -0,0 +1,16 @@
+T6885255.java:13:16: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:13:22: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:15:17: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:16:22: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:16:28: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:19:23: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:19:29: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:24:29: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:24:35: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:25:35: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:25:41: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:27:23: compiler.warn.raw.class.use: java.lang.Class, java.lang.Class<T>
+T6885255.java:27:30: compiler.warn.raw.class.use: java.lang.Class, java.lang.Class<T>
+T6885255.java:28:29: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+T6885255.java:28:42: compiler.warn.raw.class.use: T6885255.Test, T6885255.Test<X,Y>
+15 warnings