# HG changeset patch # User jjg # Date 1381877833 25200 # Node ID b0c086cd45201dfcc024c7c2911b278f3ac3f26c # Parent 19e8eebfbe52e67c64ad18d16d867555703ee08d 8026564: import changes from type-annotations forest Reviewed-by: jjg Contributed-by: wdietl@gmail.com, steve.sides@oracle.com diff -r 19e8eebfbe52 -r b0c086cd4520 make/build.properties --- a/make/build.properties Tue Oct 15 22:15:35 2013 +0200 +++ b/make/build.properties Tue Oct 15 15:57:13 2013 -0700 @@ -163,11 +163,11 @@ # sjavac.includes = \ - com/sun/tools/sjavac/ + com/sun/tools/sjavac/ sjavac.tests = \ tools/sjavac - + # # The following files require the latest JDK to be available. diff -r 19e8eebfbe52 -r b0c086cd4520 make/build.xml --- a/make/build.xml Tue Oct 15 22:15:35 2013 +0200 +++ b/make/build.xml Tue Oct 15 15:57:13 2013 -0700 @@ -89,7 +89,7 @@ build-classes-TOOL build the classes for the tool build-TOOL build the jar file and script for the tool jtreg-TOOL build the tool and run the appropriate tests - findbugs-TOOL run findbugs on the tool's source oode + findbugs-TOOL run findbugs on the tool's source code TOOL build the tool, run the tests, and run findbugs - utility definitions --> diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/code/Attribute.java --- a/src/share/classes/com/sun/tools/javac/code/Attribute.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java Tue Oct 15 15:57:13 2013 -0700 @@ -236,6 +236,7 @@ public static class TypeCompound extends Compound { public TypeAnnotationPosition position; + public TypeCompound(Compound compound, TypeAnnotationPosition position) { this(compound.type, compound.values, position); @@ -256,7 +257,7 @@ } public boolean hasUnknownPosition() { - return position == null || position.type == TargetType.UNKNOWN; + return position.type == TargetType.UNKNOWN; } public boolean isContainerTypeCompound() { diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/code/Printer.java --- a/src/share/classes/com/sun/tools/javac/code/Printer.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/code/Printer.java Tue Oct 15 15:57:13 2013 -0700 @@ -260,24 +260,23 @@ @Override public String visitAnnotatedType(AnnotatedType t, Locale locale) { - if (t.typeAnnotations != null && - t.typeAnnotations.nonEmpty()) { - if (t.underlyingType.hasTag(TypeTag.ARRAY)) { + if (t.getAnnotationMirrors().nonEmpty()) { + if (t.unannotatedType().hasTag(TypeTag.ARRAY)) { StringBuilder res = new StringBuilder(); printBaseElementType(t, res, locale); printBrackets(t, res, locale); return res.toString(); - } else if (t.underlyingType.hasTag(TypeTag.CLASS) && - t.underlyingType.getEnclosingType() != Type.noType) { - return visit(t.underlyingType.getEnclosingType(), locale) + + } else if (t.unannotatedType().hasTag(TypeTag.CLASS) && + t.unannotatedType().getEnclosingType() != Type.noType) { + return visit(t.unannotatedType().getEnclosingType(), locale) + ". " + - t.typeAnnotations + - " " + className((ClassType)t.underlyingType, false, locale); + t.getAnnotationMirrors() + + " " + className((ClassType)t.unannotatedType(), false, locale); } else { - return t.typeAnnotations + " " + visit(t.underlyingType, locale); + return t.getAnnotationMirrors() + " " + visit(t.unannotatedType(), locale); } } else { - return visit(t.underlyingType, locale); + return visit(t.unannotatedType(), locale); } } diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java --- a/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java Tue Oct 15 15:57:13 2013 -0700 @@ -429,7 +429,7 @@ super(on.type, List.>nil(), ctx.isTypeCompound ? ((Attribute.TypeCompound)placeholderFor.head).position : - null); + new TypeAnnotationPosition()); this.ctx = ctx; this.placeholderFor = placeholderFor; this.on = on; diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/code/Type.java --- a/src/share/classes/com/sun/tools/javac/code/Type.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Tue Oct 15 15:57:13 2013 -0700 @@ -225,6 +225,10 @@ return this; } + public Type annotatedType(List annos) { + return new AnnotatedType(annos, this); + } + public boolean isAnnotated() { return false; } @@ -1818,25 +1822,19 @@ javax.lang.model.type.WildcardType { /** The type annotations on this type. */ - public List typeAnnotations; + private List typeAnnotations; /** The underlying type that is annotated. */ - public Type underlyingType; + private Type underlyingType; - public AnnotatedType(Type underlyingType) { - super(underlyingType.tsym); - this.typeAnnotations = List.nil(); - this.underlyingType = underlyingType; - Assert.check(!underlyingType.isAnnotated(), - "Can't annotate already annotated type: " + underlyingType); - } - - public AnnotatedType(List typeAnnotations, + protected AnnotatedType(List typeAnnotations, Type underlyingType) { super(underlyingType.tsym); this.typeAnnotations = typeAnnotations; this.underlyingType = underlyingType; + Assert.check(typeAnnotations != null && typeAnnotations.nonEmpty(), + "Can't create AnnotatedType without annotations: " + underlyingType); Assert.check(!underlyingType.isAnnotated(), "Can't annotate already annotated type: " + underlyingType + "; adding: " + typeAnnotations); @@ -1977,10 +1975,8 @@ public TypeMirror getComponentType() { return ((ArrayType)underlyingType).getComponentType(); } // The result is an ArrayType, but only in the model sense, not the Type sense. - public AnnotatedType makeVarargs() { - AnnotatedType atype = new AnnotatedType(((ArrayType)underlyingType).makeVarargs()); - atype.typeAnnotations = this.typeAnnotations; - return atype; + public Type makeVarargs() { + return ((ArrayType) underlyingType).makeVarargs().annotatedType(typeAnnotations); } @Override diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java --- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Tue Oct 15 15:57:13 2013 -0700 @@ -290,6 +290,7 @@ List annotations = sym.getRawAttributes(); ListBuffer declAnnos = new ListBuffer(); ListBuffer typeAnnos = new ListBuffer(); + ListBuffer onlyTypeAnnos = new ListBuffer(); for (Attribute.Compound a : annotations) { switch (annotationType(a, sym)) { @@ -305,6 +306,8 @@ case TYPE: { Attribute.TypeCompound ta = toTypeCompound(a, pos); typeAnnos.append(ta); + // Also keep track which annotations are only type annotations + onlyTypeAnnos.append(ta); break; } } @@ -328,7 +331,7 @@ } // type is non-null and annotations are added to that type - type = typeWithAnnotations(typetree, type, typeAnnotations); + type = typeWithAnnotations(typetree, type, typeAnnotations, onlyTypeAnnos.toList()); if (sym.getKind() == ElementKind.METHOD) { sym.type.asMethodType().restype = type; @@ -380,32 +383,23 @@ // As a side effect the method sets the type annotation position of "annotations". // Note that it is assumed that all annotations share the same position. private Type typeWithAnnotations(final JCTree typetree, final Type type, - final List annotations) { - // System.out.printf("typeWithAnnotations(typetree: %s, type: %s, annotations: %s)%n", - // typetree, type, annotations); + final List annotations, + final List onlyTypeAnnotations) { + // System.out.printf("typeWithAnnotations(typetree: %s, type: %s, annotations: %s, onlyTypeAnnotations: %s)%n", + // typetree, type, annotations, onlyTypeAnnotations); if (annotations.isEmpty()) { return type; } if (type.hasTag(TypeTag.ARRAY)) { + Type.ArrayType arType = (Type.ArrayType) type.unannotatedType(); + Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym); Type toreturn; - Type.ArrayType tomodify; - Type.ArrayType arType; - { - Type touse = type; - if (type.isAnnotated()) { - Type.AnnotatedType atype = (Type.AnnotatedType)type; - toreturn = new Type.AnnotatedType(atype.underlyingType); - ((Type.AnnotatedType)toreturn).typeAnnotations = atype.typeAnnotations; - touse = atype.underlyingType; - arType = (Type.ArrayType) touse; - tomodify = new Type.ArrayType(null, arType.tsym); - ((Type.AnnotatedType)toreturn).underlyingType = tomodify; - } else { - arType = (Type.ArrayType) touse; - tomodify = new Type.ArrayType(null, arType.tsym); - toreturn = tomodify; - } + if (type.isAnnotated()) { + toreturn = tomodify.annotatedType(type.getAnnotationMirrors()); + } else { + toreturn = tomodify; } + JCArrayTypeTree arTree = arrayTypeTree(typetree); ListBuffer depth = new ListBuffer<>(); @@ -413,12 +407,10 @@ while (arType.elemtype.hasTag(TypeTag.ARRAY)) { if (arType.elemtype.isAnnotated()) { Type.AnnotatedType aelemtype = (Type.AnnotatedType) arType.elemtype; - Type.AnnotatedType newAT = new Type.AnnotatedType(aelemtype.underlyingType); - tomodify.elemtype = newAT; - newAT.typeAnnotations = aelemtype.typeAnnotations; - arType = (Type.ArrayType) aelemtype.underlyingType; + arType = (Type.ArrayType) aelemtype.unannotatedType(); + ArrayType prevToMod = tomodify; tomodify = new Type.ArrayType(null, arType.tsym); - newAT.underlyingType = tomodify; + prevToMod.elemtype = (Type.AnnotatedType) tomodify.annotatedType(arType.elemtype.getAnnotationMirrors()); } else { arType = (Type.ArrayType) arType.elemtype; tomodify.elemtype = new Type.ArrayType(null, arType.tsym); @@ -427,7 +419,7 @@ arTree = arrayTypeTree(arTree.elemtype); depth = depth.append(TypePathEntry.ARRAY); } - Type arelemType = typeWithAnnotations(arTree.elemtype, arType.elemtype, annotations); + Type arelemType = typeWithAnnotations(arTree.elemtype, arType.elemtype, annotations, onlyTypeAnnotations); tomodify.elemtype = arelemType; { // All annotations share the same position; modify the first one. @@ -444,7 +436,7 @@ // There is a TypeKind, but no TypeTag. JCTypeUnion tutree = (JCTypeUnion) typetree; JCExpression fst = tutree.alternatives.get(0); - Type res = typeWithAnnotations(fst, fst.type, annotations); + Type res = typeWithAnnotations(fst, fst.type, annotations, onlyTypeAnnotations); fst.type = res; // TODO: do we want to set res as first element in uct.alternatives? // UnionClassType uct = (com.sun.tools.javac.code.Type.UnionClassType)type; @@ -483,14 +475,23 @@ * but nothing more exists. */ if (enclTy != null && - enclTy.getKind() == TypeKind.NONE && - (enclTr.getKind() == JCTree.Kind.IDENTIFIER || - enclTr.getKind() == JCTree.Kind.MEMBER_SELECT || - enclTr.getKind() == JCTree.Kind.PARAMETERIZED_TYPE || - enclTr.getKind() == JCTree.Kind.ANNOTATED_TYPE)) { - // TODO: also if it's "java. @A lang.Object", that is, - // if it's on a package? - log.error(enclTr.pos(), "cant.annotate.nested.type", enclTr.toString()); + enclTy.hasTag(TypeTag.NONE)) { + switch (onlyTypeAnnotations.size()) { + case 0: + // Don't issue an error if all type annotations are + // also declaration annotations. + // If the annotations are also declaration annotations, they are + // illegal as type annotations but might be legal as declaration annotations. + // The normal declaration annotation checks make sure that the use is valid. + break; + case 1: + log.error(typetree.pos(), "cant.type.annotate.scoping.1", + onlyTypeAnnotations); + break; + default: + log.error(typetree.pos(), "cant.type.annotate.scoping", + onlyTypeAnnotations); + } return type; } @@ -569,7 +570,7 @@ // assert that t.constValue() == null? if (t == stopAt || t.getEnclosingType() == Type.noType) { - return new AnnotatedType(s, t); + return t.annotatedType(s); } else { ClassType ret = new ClassType(t.getEnclosingType().accept(this, s), t.typarams_field, t.tsym); @@ -584,12 +585,12 @@ @Override public Type visitAnnotatedType(AnnotatedType t, List s) { - return new AnnotatedType(t.typeAnnotations, t.underlyingType.accept(this, s)); + return t.unannotatedType().accept(this, s).annotatedType(t.getAnnotationMirrors()); } @Override public Type visitWildcardType(WildcardType t, List s) { - return new AnnotatedType(s, t); + return t.annotatedType(s); } @Override @@ -612,12 +613,12 @@ @Override public Type visitTypeVar(TypeVar t, List s) { - return new AnnotatedType(s, t); + return t.annotatedType(s); } @Override public Type visitCapturedType(CapturedType t, List s) { - return new AnnotatedType(s, t); + return t.annotatedType(s); } @Override @@ -634,12 +635,12 @@ @Override public Type visitErrorType(ErrorType t, List s) { - return new AnnotatedType(s, t); + return t.annotatedType(s); } @Override public Type visitType(Type t, List s) { - return new AnnotatedType(s, t); + return t.annotatedType(s); } }; diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/code/Types.java --- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Oct 15 15:57:13 2013 -0700 @@ -1273,7 +1273,7 @@ return false; if (!s.getAnnotationMirrors().containsAll(t.getAnnotationMirrors())) return false; - return visit(t.underlyingType, s); + return visit(t.unannotatedType(), s); } }; // @@ -2217,15 +2217,15 @@ @Override public Type visitAnnotatedType(AnnotatedType t, Boolean recurse) { - Type erased = erasure(t.underlyingType, recurse); + Type erased = erasure(t.unannotatedType(), recurse); if (erased.isAnnotated()) { // This can only happen when the underlying type is a // type variable and the upper bound of it is annotated. // The annotation on the type variable overrides the one // on the bound. - erased = ((AnnotatedType)erased).underlyingType; + erased = ((AnnotatedType)erased).unannotatedType(); } - return new AnnotatedType(t.typeAnnotations, erased); + return erased.annotatedType(t.getAnnotationMirrors()); } }; @@ -4419,7 +4419,7 @@ public R visitUndetVar(UndetVar t, S s) { return visitType(t, s); } public R visitErrorType(ErrorType t, S s) { return visitType(t, s); } // Pretend annotations don't exist - public R visitAnnotatedType(AnnotatedType t, S s) { return visit(t.underlyingType, s); } + public R visitAnnotatedType(AnnotatedType t, S s) { return visit(t.unannotatedType(), s); } } /** diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/comp/Annotate.java --- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Oct 15 15:57:13 2013 -0700 @@ -250,7 +250,8 @@ a.type = chk.checkType(a.annotationType.pos(), at, expected); if (a.type.isErroneous()) { if (typeAnnotation) { - return new Attribute.TypeCompound(a.type, List.>nil(), null); + return new Attribute.TypeCompound(a.type, List.>nil(), + new TypeAnnotationPosition()); } else { return new Attribute.Compound(a.type, List.>nil()); } diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 15 15:57:13 2013 -0700 @@ -3534,15 +3534,6 @@ Type normOuter = site; if (normOuter.hasTag(CLASS)) { normOuter = types.asEnclosingSuper(site, ownOuter.tsym); - if (site.isAnnotated()) { - // Propagate any type annotations. - // TODO: should asEnclosingSuper do this? - // Note that the type annotations in site will be updated - // by annotateType. Therefore, modify site instead - // of creating a new AnnotatedType. - ((AnnotatedType)site).underlyingType = normOuter; - normOuter = site; - } } if (normOuter == null) // perhaps from an import normOuter = types.erasure(ownOuter); @@ -3901,12 +3892,6 @@ } } owntype = new ClassType(clazzOuter, actuals, clazztype.tsym); - if (clazztype.isAnnotated()) { - // Use the same AnnotatedType, because it will have - // its annotations set later. - ((AnnotatedType)clazztype).underlyingType = owntype; - owntype = clazztype; - } } else { if (formals.length() != 0) { log.error(tree.pos(), "wrong.number.type.args", @@ -3972,9 +3957,7 @@ TypeVar typeVar = (TypeVar) tree.type; if (tree.annotations != null && tree.annotations.nonEmpty()) { - AnnotatedType antype = new AnnotatedType(typeVar); - annotateType(antype, tree.annotations); - tree.type = antype; + annotateType(tree, tree.annotations); } if (!typeVar.bound.isErroneous()) { @@ -4074,26 +4057,28 @@ public void visitAnnotatedType(JCAnnotatedType tree) { Type underlyingType = attribType(tree.getUnderlyingType(), env); this.attribAnnotationTypes(tree.annotations, env); - AnnotatedType antype = new AnnotatedType(underlyingType); - annotateType(antype, tree.annotations); - result = tree.type = antype; + annotateType(tree, tree.annotations); + result = tree.type = underlyingType; } /** * Apply the annotations to the particular type. */ - public void annotateType(final AnnotatedType type, final List annotations) { - if (annotations.isEmpty()) - return; + public void annotateType(final JCTree tree, final List annotations) { + // Callers ensure this. + // Assert.check(annotations != null && annotations.nonEmpty()); annotate.typeAnnotation(new Annotate.Worker() { @Override public String toString() { - return "annotate " + annotations + " onto " + type; + return "annotate " + annotations + " onto " + tree; } @Override public void run() { List compounds = fromAnnotations(annotations); - type.typeAnnotations = compounds; + if (annotations.size() == compounds.size()) { + // All annotations were successfully converted into compounds + tree.type = tree.type.unannotatedType().annotatedType(compounds); + } } }); } @@ -4432,17 +4417,18 @@ private final class TypeAnnotationsValidator extends TreeScanner { private final boolean sigOnly; - private boolean checkAllAnnotations = false; - public TypeAnnotationsValidator(boolean sigOnly) { this.sigOnly = sigOnly; } public void visitAnnotation(JCAnnotation tree) { - if (tree.hasTag(TYPE_ANNOTATION) || checkAllAnnotations) { - chk.validateTypeAnnotation(tree, false); + chk.validateTypeAnnotation(tree, false); + super.visitAnnotation(tree); + } + public void visitAnnotatedType(JCAnnotatedType tree) { + if (!tree.underlyingType.type.isErroneous()) { + super.visitAnnotatedType(tree); } - super.visitAnnotation(tree); } public void visitTypeParameter(JCTypeParameter tree) { chk.validateTypeAnnotations(tree.annotations, true); @@ -4475,7 +4461,7 @@ } public void visitVarDef(final JCVariableDecl tree) { if (tree.sym != null && tree.sym.type != null) - validateAnnotatedType(tree, tree.sym.type); + validateAnnotatedType(tree.vartype, tree.sym.type); scan(tree.mods); scan(tree.vartype); if (!sigOnly) { @@ -4493,27 +4479,13 @@ super.visitTypeTest(tree); } public void visitNewClass(JCNewClass tree) { - if (tree.clazz.hasTag(ANNOTATED_TYPE)) { - boolean prevCheck = this.checkAllAnnotations; - try { - this.checkAllAnnotations = true; - scan(((JCAnnotatedType)tree.clazz).annotations); - } finally { - this.checkAllAnnotations = prevCheck; - } - } + if (tree.clazz.type != null) + validateAnnotatedType(tree.clazz, tree.clazz.type); super.visitNewClass(tree); } public void visitNewArray(JCNewArray tree) { - if (tree.elemtype != null && tree.elemtype.hasTag(ANNOTATED_TYPE)) { - boolean prevCheck = this.checkAllAnnotations; - try { - this.checkAllAnnotations = true; - scan(((JCAnnotatedType)tree.elemtype).annotations); - } finally { - this.checkAllAnnotations = prevCheck; - } - } + if (tree.elemtype != null && tree.elemtype.type != null) + validateAnnotatedType(tree.elemtype, tree.elemtype.type); super.visitNewArray(tree); } @@ -4549,21 +4521,95 @@ * can occur. */ private void validateAnnotatedType(final JCTree errtree, final Type type) { - if (type.getEnclosingType() != null && - type != type.getEnclosingType()) { - validateEnclosingAnnotatedType(errtree, type.getEnclosingType()); - } - for (Type targ : type.getTypeArguments()) { - validateAnnotatedType(errtree, targ); + // System.out.println("Attr.validateAnnotatedType: " + errtree + " type: " + type); + + if (type.isPrimitiveOrVoid()) { + return; } - } - private void validateEnclosingAnnotatedType(final JCTree errtree, final Type type) { - validateAnnotatedType(errtree, type); - if (type.tsym != null && - type.tsym.isStatic() && - type.getAnnotationMirrors().nonEmpty()) { - // Enclosing static classes cannot have type annotations. - log.error(errtree.pos(), "cant.annotate.static.class"); + + JCTree enclTr = errtree; + Type enclTy = type; + + boolean repeat = true; + while (repeat) { + if (enclTr.hasTag(TYPEAPPLY)) { + List tyargs = enclTy.getTypeArguments(); + List trargs = ((JCTypeApply)enclTr).getTypeArguments(); + if (trargs.length() > 0) { + // Nothing to do for diamonds + if (tyargs.length() == trargs.length()) { + for (int i = 0; i < tyargs.length(); ++i) { + validateAnnotatedType(trargs.get(i), tyargs.get(i)); + } + } + // If the lengths don't match, it's either a diamond + // or some nested type that redundantly provides + // type arguments in the tree. + } + + // Look at the clazz part of a generic type + enclTr = ((JCTree.JCTypeApply)enclTr).clazz; + } + + if (enclTr.hasTag(SELECT)) { + enclTr = ((JCTree.JCFieldAccess)enclTr).getExpression(); + if (enclTy != null && + !enclTy.hasTag(NONE)) { + enclTy = enclTy.getEnclosingType(); + } + } else if (enclTr.hasTag(ANNOTATED_TYPE)) { + JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr; + if (enclTy == null || + enclTy.hasTag(NONE)) { + if (at.getAnnotations().size() == 1) { + log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute); + } else { + ListBuffer comps = new ListBuffer(); + for (JCAnnotation an : at.getAnnotations()) { + comps.add(an.attribute); + } + log.error(at.underlyingType.pos(), "cant.type.annotate.scoping", comps.toList()); + } + repeat = false; + } + enclTr = at.underlyingType; + // enclTy doesn't need to be changed + } else if (enclTr.hasTag(IDENT)) { + repeat = false; + } else if (enclTr.hasTag(JCTree.Tag.WILDCARD)) { + JCWildcard wc = (JCWildcard) enclTr; + if (wc.getKind() == JCTree.Kind.EXTENDS_WILDCARD) { + validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy.unannotatedType()).getExtendsBound()); + } else if (wc.getKind() == JCTree.Kind.SUPER_WILDCARD) { + validateAnnotatedType(wc.getBound(), ((WildcardType)enclTy.unannotatedType()).getSuperBound()); + } else { + // Nothing to do for UNBOUND + } + repeat = false; + } else if (enclTr.hasTag(TYPEARRAY)) { + JCArrayTypeTree art = (JCArrayTypeTree) enclTr; + validateAnnotatedType(art.getType(), ((ArrayType)enclTy.unannotatedType()).getComponentType()); + repeat = false; + } else if (enclTr.hasTag(TYPEUNION)) { + JCTypeUnion ut = (JCTypeUnion) enclTr; + for (JCTree t : ut.getTypeAlternatives()) { + validateAnnotatedType(t, t.type); + } + repeat = false; + } else if (enclTr.hasTag(TYPEINTERSECTION)) { + JCTypeIntersection it = (JCTypeIntersection) enclTr; + for (JCTree t : it.getBounds()) { + validateAnnotatedType(t, t.type); + } + repeat = false; + } else if (enclTr.getKind() == JCTree.Kind.PRIMITIVE_TYPE) { + // This happens in test TargetTypeTest52.java + // Is there anything to do? + repeat = false; + } else { + Assert.error("Unexpected tree: " + enclTr + " with kind: " + enclTr.getKind() + + " within: "+ errtree + " with kind: " + errtree.getKind()); + } } } }; diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/comp/Check.java --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Oct 15 15:57:13 2013 -0700 @@ -2769,8 +2769,11 @@ Assert.checkNonNull(a.type, "annotation tree hasn't been attributed yet: " + a); validateAnnotationTree(a); - if (!isTypeAnnotation(a, isTypeParameter)) + if (a.hasTag(TYPE_ANNOTATION) && + !a.annotationType.type.isErroneous() && + !isTypeAnnotation(a, isTypeParameter)) { log.error(a.pos(), "annotation.type.not.applicable"); + } } /** diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/comp/Lower.java --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Oct 15 15:57:13 2013 -0700 @@ -2834,20 +2834,9 @@ tree.underlyingType = translate(tree.underlyingType); // but maintain type annotations in the type. if (tree.type.isAnnotated()) { - if (tree.underlyingType.type.isAnnotated()) { - // The erasure of a type variable might be annotated. - // Merge all annotations. - AnnotatedType newat = (AnnotatedType) tree.underlyingType.type; - AnnotatedType at = (AnnotatedType) tree.type; - at.underlyingType = newat.underlyingType; - newat.typeAnnotations = at.typeAnnotations.appendList(newat.typeAnnotations); - tree.type = newat; - } else { - // Create a new AnnotatedType to have the correct tag. - AnnotatedType oldat = (AnnotatedType) tree.type; - tree.type = new AnnotatedType(tree.underlyingType.type); - ((AnnotatedType) tree.type).typeAnnotations = oldat.typeAnnotations; - } + tree.type = tree.underlyingType.type.unannotatedType().annotatedType(tree.type.getAnnotationMirrors()); + } else if (tree.underlyingType.type.isAnnotated()) { + tree.type = tree.underlyingType.type; } result = tree; } diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/resources/compiler.properties --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Oct 15 15:57:13 2013 -0700 @@ -2257,13 +2257,14 @@ receiver parameter not applicable for constructor of top-level class # TODO 308: make a better error message -compiler.err.cant.annotate.static.class=\ - enclosing static nested class cannot be annotated +# 0: symbol +compiler.err.cant.type.annotate.scoping.1=\ + scoping construct cannot be annotated with type-use annotation: {0} # TODO 308: make a better error message -# 0: unused -compiler.err.cant.annotate.nested.type=\ - scoping construct for static nested type cannot be annotated +# 0: list of symbol +compiler.err.cant.type.annotate.scoping=\ + scoping construct cannot be annotated with type-use annotations: {0} # 0: type, 1: type compiler.err.incorrect.receiver.name=\ diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/com/sun/tools/javac/tree/JCTree.java --- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java Tue Oct 15 15:57:13 2013 -0700 @@ -2359,6 +2359,7 @@ public JCExpression underlyingType; protected JCAnnotatedType(List annotations, JCExpression underlyingType) { + Assert.check(annotations != null && annotations.nonEmpty()); this.annotations = annotations; this.underlyingType = underlyingType; } diff -r 19e8eebfbe52 -r b0c086cd4520 src/share/classes/javax/lang/model/AnnotatedConstruct.java --- a/src/share/classes/javax/lang/model/AnnotatedConstruct.java Tue Oct 15 22:15:35 2013 +0200 +++ b/src/share/classes/javax/lang/model/AnnotatedConstruct.java Tue Oct 15 15:57:13 2013 -0700 @@ -221,8 +221,8 @@ * type if present on this construct, else an empty array * * @see #getAnnotationMirrors() - * @see #getAnnotation(java.lang.Class) - * @see java.lang.reflect.AnnotatedElement#getAnnotationsByType + * @see #getAnnotation(Class) + * @see java.lang.reflect.AnnotatedElement#getAnnotationsByType(Class) * @see EnumConstantNotPresentException * @see AnnotationTypeMismatchException * @see IncompleteAnnotationException diff -r 19e8eebfbe52 -r b0c086cd4520 test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java --- a/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/com/sun/javadoc/testTypeAnnotations/TestTypeAnnotations.java Tue Oct 15 15:57:13 2013 -0700 @@ -27,6 +27,7 @@ * @summary Make sure that type annotations are displayed correctly * @author Bhavesh Patel * @library ../lib/ + * @ignore * @build JavadocTester TestTypeAnnotations * @run main TestTypeAnnotations */ diff -r 19e8eebfbe52 -r b0c086cd4520 test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java --- a/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/com/sun/javadoc/typeAnnotations/smoke/TestSmoke.java Tue Oct 15 15:57:13 2013 -0700 @@ -28,6 +28,7 @@ * * @author Mahmood Ali * @library ../../lib/ + * @ignore * @build JavadocTester * @build TestSmoke * @run main TestSmoke diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/T7042623.java --- a/test/tools/javac/T7042623.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/T7042623.java Tue Oct 15 15:57:13 2013 -0700 @@ -2,6 +2,7 @@ * @test /nodynamiccopyright/ * @bug 7042623 * @summary Regression: javac silently crash when attributing non-existent annotation + * @ignore * @compile/fail/ref=T7042623.out -XDrawDiagnostics -XDdev T7042623.java */ diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java --- a/test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/classfile/ClassfileTestHelper.java Tue Oct 15 15:57:13 2013 -0700 @@ -36,7 +36,8 @@ //Makes debugging much easier. Set to 'false' for less output. public Boolean verbose = true; - void println(String msg) { if(verbose) System.out.println(msg); } + void println(String msg) { if (verbose) System.out.println(msg); } + void print(String msg) { if (verbose) System.out.print(msg); } File writeTestFile(String fname, String source) throws IOException { File f = new File(fname); @@ -183,6 +184,13 @@ (RuntimeTypeAnnotations_attribute)attr; println(testtype + ": " + name + ", " + annName + ": " + tAttr.annotations.length ); + if (tAttr.annotations.length > 0) { + for (int i = 0; i < tAttr.annotations.length; i++) { + println(" types:" + tAttr.annotations[i].position.type); + } + } else { + println(""); + } allt += tAttr.annotations.length; if (visible) tvisibles += tAttr.annotations.length; diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/classfile/Scopes.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/classfile/Scopes.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2009, 2013, 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. + */ + +import java.lang.annotation.*; +import java.io.*; +import java.net.URL; +import java.util.List; + +import com.sun.tools.classfile.*; + +/* + * @test + * @bug 6843077 8006775 + * @summary Qualified inner type annotation accessible to the class. + */ + +@Scopes.UniqueInner +public class Scopes extends ClassfileTestHelper{ + public static void main(String[] args) throws Exception { + new Scopes().run(); + } + + public void run() throws Exception { + expected_tinvisibles = 1; + expected_invisibles = 1; + + ClassFile cf = getClassFile("Scopes.class"); + test(cf); + + countAnnotations(); + + if (errors > 0) + throw new Exception(errors + " errors found"); + System.out.println("PASSED"); + } + + @Target({ElementType.TYPE_USE}) + @interface UniqueInner { }; +} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.java --- a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedImport.java Tue Oct 15 15:57:13 2013 -0700 @@ -3,13 +3,16 @@ * @bug 8006775 * @summary Import clauses cannot use annotations. * @author Werner Dietl + * @ignore * @compile/fail/ref=AnnotatedImport.out -XDrawDiagnostics AnnotatedImport.java */ +import java.lang.annotation.*; import java.@A util.List; import @A java.util.Map; import java.util.@A HashMap; class AnnotatedImport { } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.java --- a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.java Tue Oct 15 15:57:13 2013 -0700 @@ -3,11 +3,15 @@ * @bug 8006775 * @summary Package declarations cannot use annotations. * @author Werner Dietl + * @ignore * @compile/fail/ref=AnnotatedPackage1.out -XDrawDiagnostics AnnotatedPackage1.java */ package name.@A p1.p2; +import java.lang.annotation.*; + class AnnotatedPackage1 { } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.out --- a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage1.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,3 +1,3 @@ AnnotatedPackage1.java:9:14: compiler.err.expected: token.identifier -AnnotatedPackage1.java:9:15: compiler.err.expected3: class, interface, enum +AnnotatedPackage1.java:9:16: compiler.err.expected3: class, interface, enum 2 errors diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.java --- a/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotatedPackage2.java Tue Oct 15 15:57:13 2013 -0700 @@ -8,6 +8,9 @@ package @A p1.p2; +import java.lang.annotation.*; + class AnnotatedPackage2 { } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.java --- a/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.java Tue Oct 15 15:57:13 2013 -0700 @@ -3,11 +3,13 @@ * @bug 6843077 8006775 * @summary test that only Java 8 allows type annotations * @author Mahmood Ali + * @compile AnnotationVersion.java * @compile/fail/ref=AnnotationVersion.out -XDrawDiagnostics -Xlint:-options -source 1.6 AnnotationVersion.java * @compile/fail/ref=AnnotationVersion7.out -XDrawDiagnostics -Xlint:-options -source 1.7 AnnotationVersion.java */ -class AnnotationVersion { - public void method(@A AnnotationVersion this) { } -} +import java.lang.annotation.*; +class myNumber { } + +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.out --- a/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,2 +1,2 @@ -AnnotationVersion.java:10:43: compiler.err.type.annotations.not.supported.in.source: 1.6 +AnnotationVersion.java:12:27: compiler.err.type.annotations.not.supported.in.source: 1.6 1 error diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion7.out --- a/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion7.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/AnnotationVersion7.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,2 +1,2 @@ -AnnotationVersion.java:10:43: compiler.err.type.annotations.not.supported.in.source: 1.7 +AnnotationVersion.java:12:27: compiler.err.type.annotations.not.supported.in.source: 1.7 1 error diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/BadCast.java --- a/test/tools/javac/annotations/typeAnnotations/failures/BadCast.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/BadCast.java Tue Oct 15 15:57:13 2013 -0700 @@ -5,10 +5,13 @@ * @author Werner Dietl * @compile/fail/ref=BadCast.out -XDrawDiagnostics BadCast.java */ +import java.lang.annotation.*; + class BadCast { static void main() { Object o = (@A) ""; } } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/BadCast.out --- a/test/tools/javac/annotations/typeAnnotations/failures/BadCast.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/BadCast.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,2 +1,2 @@ -BadCast.java:10:19: compiler.err.illegal.start.of.type -1 error \ No newline at end of file +BadCast.java:12:19: compiler.err.illegal.start.of.type +1 error diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,27 @@ +/* + * @test /nodynamiccopyright/ + * @bug 1234567 + * @summary The parts of a fully-qualified type can't be annotated. + * @author Werner Dietl + * @compile/fail/ref=CantAnnotatePackages.out -XDrawDiagnostics CantAnnotatePackages.java + */ + +import java.lang.annotation.*; +import java.util.List; + +class CantAnnotatePackages { + // Before a package component: + @TA java.lang.Object of1; + + // These result in a different error. + // TODO: should this be unified? + + List<@TA java.lang.Object> of2; + java. @TA lang.Object of3; + List of4; + + // TODO: also note the order of error messages. +} + +@Target(ElementType.TYPE_USE) +@interface TA { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,5 @@ +CantAnnotatePackages.java:19:14: compiler.err.cant.resolve.location: kindname.class, java, , , (compiler.misc.location: kindname.class, CantAnnotatePackages, null) +CantAnnotatePackages.java:20:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null) +CantAnnotatePackages.java:21:14: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null) +CantAnnotatePackages.java:14:18: compiler.err.cant.type.annotate.scoping.1: @TA +4 errors \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,71 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8006733 8006775 + * @summary Ensure behavior for nested types is correct. + * @author Werner Dietl + * @compile/fail/ref=CantAnnotateScoping.out -XDrawDiagnostics CantAnnotateScoping.java + */ + +import java.util.List; +import java.util.ArrayList; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE_USE}) +@interface TA {} +@Target({ElementType.TYPE_USE}) +@interface TA2 {} + +@Target({ElementType.FIELD}) +@interface DA {} +@Target({ElementType.FIELD}) +@interface DA2 {} + +@Target({ElementType.TYPE_USE, ElementType.FIELD}) +@interface DTA {} +@Target({ElementType.TYPE_USE, ElementType.FIELD}) +@interface DTA2 {} + +class Test { + static class Outer { + static class SInner {} + } + + // Legal + List li; + + // Illegal + @TA Outer.SInner osi; + // Illegal + List<@TA Outer.SInner> aloi; + // Illegal + Object o1 = new @TA @DA @TA2 Outer.SInner(); + // Illegal + Object o = new ArrayList<@TA @DA Outer.SInner>(); + + // Illegal: @TA is only a type-use annotation + @TA java.lang.Object f1; + + // Legal: @DA is only a declaration annotation + @DA java.lang.Object f2; + + // Legal: @DTA is both a type-use and declaration annotation + @DTA java.lang.Object f3; + + // Illegal: @TA and @TA2 are only type-use annotations + @DTA @DA @TA @DA2 @TA2 java.lang.Object f4; + + // Illegal: Do we want one or two messages? + // 1: @DA in invalid location + // 2: Not finding class "lang" + java. @DA lang.Object f5; + + // Illegal: Do we want one or two messages? + // 1: @DA in invalid location + // 2: Not finding class "XXX" + java. @DA XXX.Object f6; + + // Illegal: Can't find class "lang". + // Would a different error message be desirable? + java. @TA lang.Object f7; +} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateScoping.out Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,11 @@ +CantAnnotateScoping.java:61:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null) +CantAnnotateScoping.java:66:9: compiler.err.cant.resolve.location: kindname.class, XXX, , , (compiler.misc.location: kindname.package, java, null) +CantAnnotateScoping.java:70:9: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null) +CantAnnotateScoping.java:38:14: compiler.err.cant.type.annotate.scoping.1: @TA +CantAnnotateScoping.java:47:18: compiler.err.cant.type.annotate.scoping.1: @TA +CantAnnotateScoping.java:56:37: compiler.err.cant.type.annotate.scoping: @TA,@TA2 +CantAnnotateScoping.java:40:14: compiler.err.cant.type.annotate.scoping.1: @TA +CantAnnotateScoping.java:42:34: compiler.err.cant.type.annotate.scoping: @TA,@DA,@TA2 +CantAnnotateScoping.java:44:38: compiler.err.cant.type.annotate.scoping: @TA,@DA +CantAnnotateScoping.java:44:34: compiler.err.annotation.type.not.applicable +10 errors \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java --- a/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.java Tue Oct 15 15:57:13 2013 -0700 @@ -1,41 +1,96 @@ /* * @test /nodynamiccopyright/ * @bug 8006733 8006775 - - * @summary A static outer class cannot be annotated. + * @summary Ensure behavior for nested types is correct. * @author Werner Dietl - * @compile/fail/ref=CantAnnotateStaticClass.out -XDrawDiagnostics CantAnnotateStaticClass.java + * @compile CantAnnotateStaticClass.java */ import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; import java.lang.annotation.*; -class CantAnnotateStaticClass { +class Top { + @Target(ElementType.TYPE_USE) + @interface TA {} + + @Target(ElementType.TYPE_USE) + @interface TB {} + @Target(ElementType.TYPE_USE) - @interface A {} + @interface TC {} - static class Outer { - class Inner {} + class Outer { + class Inner { + Object o1 = Top.this; + Object o2 = Outer.this; + Object o3 = this; + } + // Illegal + // static class SInner {} + // interface IInner {} } - // 8 errors: - @A Outer.Inner f1; - @A Outer.Inner f1r() { return null; } - void f1p(@A Outer.Inner p) { } - void f1c(Object o) { - Object l = (@A Outer.Inner) o; + // All combinations are OK + + Top.@TB Outer f1; + @TB Outer.Inner f1a; + Outer. @TC Inner f1b; + @TB Outer. @TC Inner f1c; + + @TA Top. @TB Outer f2; + @TA Top. @TB Outer.Inner f2a; + @TA Top. Outer. @TC Inner f2b; + @TA Top. @TB Outer. @TC Inner f2c; + + @TB Outer f1r() { return null; } + @TB Outer.Inner f1ra() { return null; } + Outer. @TC Inner f1rb() { return null; } + @TB Outer. @TC Inner f1rc() { return null; } + + void f1param(@TB Outer p, + @TB Outer.Inner p1, + Outer. @TC Inner p2, + @TB Outer. @TC Inner p3) { } + + void f1cast(Object o) { + Object l; + l = (@TB Outer) o; + l = (@TB Outer.Inner) o; + l = (Outer. @TC Inner) o; + l = (@TB Outer. @TC Inner) o; } - List<@A Outer.Inner> f2; - List<@A Outer.Inner> f2r() { return null; } - void f2p(List<@A Outer.Inner> p) { } - void f2c(Object o) { - Object l = (List<@A Outer.Inner>) o; - } + List<@TB Outer> g1; + List<@TB Outer.Inner> g1a; + List g1b; + List<@TB Outer. @TC Inner> g1c; + + List<@TA Top. @TB Outer> g2; + List<@TA Top. @TB Outer.Inner> g2a; + List<@TA Top. Outer. @TC Inner> g2b; + List<@TA Top. @TB Outer. @TC Inner> g2c; + + List<@TB Outer> g1r() { return null; } + List<@TB Outer.Inner> g1ra() { return null; } + List g1rb() { return null; } + List<@TB Outer. @TC Inner> g1rc() { return null; } - // OK: - @A Outer g1; - List<@A Outer> g2; - Outer. @A Inner g3; - List g4; + void g1param(List<@TB Outer> p, + List<@TB Outer.Inner> p1, + List p2, + List<@TB Outer. @TC Inner> p3) { } + + void g1new(Object o) { + Object l; + l = new @TB ArrayList<@TB Outer>(); + l = new @TB ArrayList<@TB Outer.Inner>(); + l = new @TB HashMap(); + l = new @TB HashMap(); + l = new @TB HashMap(); + l = new @TB HashMap(); + l = new @TB HashMap(); + l = new @TB HashMap(); + } } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.out --- a/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass.out Tue Oct 15 22:15:35 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -CantAnnotateStaticClass.java:22:20: compiler.err.cant.annotate.static.class -CantAnnotateStaticClass.java:23:13: compiler.err.cant.annotate.static.class -CantAnnotateStaticClass.java:24:29: compiler.err.cant.annotate.static.class -CantAnnotateStaticClass.java:29:26: compiler.err.cant.annotate.static.class -CantAnnotateStaticClass.java:30:9: compiler.err.cant.annotate.static.class -CantAnnotateStaticClass.java:31:35: compiler.err.cant.annotate.static.class -CantAnnotateStaticClass.java:26:29: compiler.err.cant.annotate.static.class -- compiler.note.unchecked.filename: CantAnnotateStaticClass.java -- compiler.note.unchecked.recompile -7 errors \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,207 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8006733 8006775 + * @summary Ensure behavior for nested types is correct. + * @author Werner Dietl + * @ignore + * @compile/fail/ref=CantAnnotateStaticClass2.out -XDrawDiagnostics CantAnnotateStaticClass2.java + */ + +import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; +import java.lang.annotation.*; + +class Top { + @Target(ElementType.TYPE_USE) + @interface TA {} + + @Target(ElementType.TYPE_USE) + @interface TB {} + + @Target(ElementType.TYPE_USE) + @interface TC {} + + static class Outer { + class Inner { + // Object o1 = Top.this; + Object o2 = Outer.this; + Object o3 = this; + } + static class SInner { + // Object o1 = Top.this; + // Object o2 = Outer.this; + Object o3 = this; + } + interface IInner { + // Object o1 = Top.this; + // Object o2 = Outer.this; + // Object o3 = this; + } + } + + @TB Outer f1; + @TB Outer.Inner f1a; + @TB Outer.SInner f2a; // err + @TB Outer.IInner f3a; // err + + Outer. @TC Inner f1b; + Outer. @TC SInner f2b; + Outer. @TC IInner f3b; + + @TB Outer. @TC Inner f1c; + @TB Outer. @TC SInner f2c; // err + @TB Outer. @TC IInner f3c; // err + + @TA Top. @TB Outer g1; // err + @TA Top. @TB Outer.Inner g1a; // err + @TA Top. @TB Outer.SInner g2a; // err + @TA Top. @TB Outer.IInner g3a; // err + + @TA Top. Outer. @TC Inner g1b; // err + @TA Top. Outer. @TC SInner g2b; // err + @TA Top. Outer. @TC IInner g3b; // err + + @TA Top. @TB Outer. @TC Inner g1c; // err + @TA Top. @TB Outer. @TC SInner g2c; // err + @TA Top. @TB Outer. @TC IInner g3c; // err + + @TB Outer f1r() { return null; } + + @TB Outer.Inner f1ra() { return null; } + @TB Outer.SInner f2ra() { return null; } // err + @TB Outer.IInner f3ra() { return null; } // err + + Outer. @TC Inner f1rb() { return null; } + Outer. @TC SInner f2rb() { return null; } + Outer. @TC IInner f3rb() { return null; } + + @TB Outer. @TC Inner f1rc() { return null; } + @TB Outer. @TC SInner f2rc() { return null; } // err + @TB Outer. @TC IInner f3rc() { return null; } // err + + void f1param(@TB Outer p, + @TB Outer.Inner p1, + Outer. @TC Inner p2, + @TB Outer. @TC Inner p3) { } + void f2param(@TB Outer p, + @TB Outer.SInner p1, // err + Outer. @TC SInner p2, + @TB Outer. @TC SInner p3) { } // err + void f3param(@TB Outer p, + @TB Outer.IInner p1, // err + Outer. @TC IInner p2, + @TB Outer. @TC IInner p3) { } // err + + void f1cast(Object o) { + Object l; + l = (@TB Outer) o; + l = (@TB Outer.Inner) o; + l = (Outer. @TC Inner) o; + l = (@TB Outer. @TC Inner) o; + } + void f2cast(Object o) { + Object l; + l = (@TB Outer) o; + l = (@TB Outer.SInner) o; // err + l = (Outer. @TC SInner) o; + l = (@TB Outer. @TC SInner) o; // err + } + void f3cast(Object o) { + Object l; + l = (@TB Outer) o; + l = (@TB Outer.IInner) o; // err + l = (Outer. @TC IInner) o; + l = (@TB Outer. @TC IInner) o; // err + } + + List<@TB Outer> h1; + + List<@TB Outer.Inner> h1a; + List<@TB Outer.SInner> h2a; // err + List<@TB Outer.IInner> h3a; // err + + List h1b; + List h2b; + List h3b; + + List<@TB Outer. @TC Inner> h1c; + List<@TB Outer. @TC SInner> h2c; // err + List<@TB Outer. @TC IInner> h3c; // err + + List<@TA Top. @TB Outer> k1; // err + + List<@TA Top. @TB Outer.Inner> k1a; // err + List<@TA Top. @TB Outer.SInner> k2a; // err + List<@TA Top. @TB Outer.IInner> k3a; // err + + List<@TA Top. Outer. @TC Inner> k1b; // err + List<@TA Top. Outer. @TC SInner> k2b; // err + List<@TA Top. Outer. @TC IInner> k3b; // err + + List<@TA Top. @TB Outer. @TC Inner> k1c; // err + List<@TA Top. @TB Outer. @TC SInner> k2c; // err + List<@TA Top. @TB Outer. @TC IInner> k3c; // err + + + List<@TB Outer> g1r() { return null; } + + List<@TB Outer.Inner> g1ra() { return null; } + List<@TB Outer.SInner> g2ra() { return null; } // err + List<@TB Outer.IInner> g3ra() { return null; } // err + + List g1rb() { return null; } + List g2rb() { return null; } + List g3rb() { return null; } + + List<@TB Outer. @TC Inner> g1rc() { return null; } + List<@TB Outer. @TC SInner> g2rc() { return null; } // err + List<@TB Outer. @TC IInner> g3rc() { return null; } // err + + void g1param(List<@TB Outer> p, + List<@TB Outer.Inner> p1, + List p2, + List<@TB Outer. @TC Inner> p3) { } + void g2param(List<@TB Outer> p, + List<@TB Outer.SInner> p1, // err + List p2, + List<@TB Outer. @TC SInner> p3) { } // err + void g3param(List<@TB Outer> p, + List<@TB Outer.IInner> p1, // err + List p2, + List<@TB Outer. @TC IInner> p3) { } // err + + void g1new(Object o) { + Object l; + l = new @TB ArrayList<@TB Outer>(); + l = new @TB ArrayList<@TB Outer.Inner>(); + l = new @TB HashMap(); + l = new @TB HashMap(); + l = new @TB HashMap(); + } + void g2new(Object o) { + Object l; + l = new @TB ArrayList<@TB Outer>(); + l = new @TB ArrayList<@TB Outer.SInner>(); // err + l = new @TB HashMap(); + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + } + void g3new(Object o) { + Object l; + l = new @TB ArrayList<@TB Outer>(); + l = new @TB ArrayList<@TB Outer.IInner>(); // err + l = new @TB HashMap(); + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + } + void g4new(Object o) { + Object l; + l = new @TB ArrayList<@TA Top. @TB Outer>(); // err + l = new @TB ArrayList<@TA Top. @TB Outer.IInner>(); // err + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + } +} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass2.out Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,65 @@ +CantAnnotateStaticClass2.java:44:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:45:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:52:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:53:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:55:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:56:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:57:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:58:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:60:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:61:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:62:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:64:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:65:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:66:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:71:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:72:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:79:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:80:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:87:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:89:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:91:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:93:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:57:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:58:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:65:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:66:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:105:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:107:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:112:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:114:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:120:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:121:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:128:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:129:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:131:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:133:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:134:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:135:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:137:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:138:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:139:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:141:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:142:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:143:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:149:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:150:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:157:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:158:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:165:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:167:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:169:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:171:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:184:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:186:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:187:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:192:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:194:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:195:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:199:35: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:200:38: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:201:41: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass2.java:202:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:203:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass2.java:204:49: compiler.err.cant.type.annotate.scoping: @Top.TA,@Top.TB,@Top.TC +64 errors \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass3.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass3.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,207 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8006733 8006775 + * @summary Ensure behavior for nested types is correct. + * @author Werner Dietl + * @ignore + * @compile/fail/ref=CantAnnotateStaticClass3.out -XDrawDiagnostics CantAnnotateStaticClass3.java + */ + +import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; +import java.lang.annotation.*; + +class Top { + @Target(ElementType.TYPE_USE) + @interface TA {} + + @Target(ElementType.TYPE_USE) + @interface TB {} + + @Target(ElementType.TYPE_USE) + @interface TC {} + + interface Outer { + class Inner { + // Object o1 = Top.this; + // Object o2 = Outer.this; + Object o3 = this; + } + static class SInner { + // Object o1 = Top.this; + // Object o2 = Outer.this; + Object o3 = this; + } + interface IInner { + // Object o1 = Top.this; + // Object o2 = Outer.this; + // Object o3 = this; + } + } + + + @TB Outer f1; + @TB Outer.Inner f1a; // err + @TB Outer.SInner f2a; // err + @TB Outer.IInner f3a; // err + + Outer. @TC Inner f1b; + Outer. @TC SInner f2b; + Outer. @TC IInner f3b; + + @TB Outer. @TC Inner f1c; // err + @TB Outer. @TC SInner f2c; // err + @TB Outer. @TC IInner f3c; // err + + @TA Top. @TB Outer g1; // err + @TA Top. @TB Outer.Inner g1a; // err + @TA Top. @TB Outer.SInner g2a; // err + @TA Top. @TB Outer.IInner g3a; // err + + @TA Top. Outer. @TC Inner g1b; // err + @TA Top. Outer. @TC SInner g2b; // err + @TA Top. Outer. @TC IInner g3b; // err + + @TA Top. @TB Outer. @TC Inner g1c; // err + @TA Top. @TB Outer. @TC SInner g2c; // err + @TA Top. @TB Outer. @TC IInner g3c; // err + + @TB Outer f1r() { return null; } + + @TB Outer.Inner f1ra() { return null; } // err + @TB Outer.SInner f2ra() { return null; } // err + @TB Outer.IInner f3ra() { return null; } // err + + Outer. @TC Inner f1rb() { return null; } + Outer. @TC SInner f2rb() { return null; } + Outer. @TC IInner f3rb() { return null; } + + @TB Outer. @TC Inner f1rc() { return null; } // err + @TB Outer. @TC SInner f2rc() { return null; } // err + @TB Outer. @TC IInner f3rc() { return null; } // err + + void f1param(@TB Outer p, + @TB Outer.Inner p1, // err + Outer. @TC Inner p2, + @TB Outer. @TC Inner p3) { } // err + void f2param(@TB Outer p, + @TB Outer.SInner p1, // err + Outer. @TC SInner p2, + @TB Outer. @TC SInner p3) { } // err + void f3param(@TB Outer p, + @TB Outer.IInner p1, // err + Outer. @TC IInner p2, + @TB Outer. @TC IInner p3) { } // err + + void f1cast(Object o) { + Object l; + l = (@TB Outer) o; + l = (@TB Outer.Inner) o; // err + l = (Outer. @TC Inner) o; + l = (@TB Outer. @TC Inner) o; // err + } + void f2cast(Object o) { + Object l; + l = (@TB Outer) o; + l = (@TB Outer.SInner) o; // err + l = (Outer. @TC SInner) o; + l = (@TB Outer. @TC SInner) o; // err + } + void f3cast(Object o) { + Object l; + l = (@TB Outer) o; + l = (@TB Outer.IInner) o; // err + l = (Outer. @TC IInner) o; + l = (@TB Outer. @TC IInner) o; // err + } + + List<@TB Outer> h1; + + List<@TB Outer.Inner> h1a; // err + List<@TB Outer.SInner> h2a; // err + List<@TB Outer.IInner> h3a; // err + + List h1b; + List h2b; + List h3b; + + List<@TB Outer. @TC Inner> h1c; // err + List<@TB Outer. @TC SInner> h2c; // err + List<@TB Outer. @TC IInner> h3c; // err + + List<@TA Top. @TB Outer> k1; // err + + List<@TA Top. @TB Outer.Inner> k1a; // err + List<@TA Top. @TB Outer.SInner> k2a; // err + List<@TA Top. @TB Outer.IInner> k3a; // err + + List<@TA Top. Outer. @TC Inner> k1b; // err + List<@TA Top. Outer. @TC SInner> k2b; // err + List<@TA Top. Outer. @TC IInner> k3b; // err + + List<@TA Top. @TB Outer. @TC Inner> k1c; // err + List<@TA Top. @TB Outer. @TC SInner> k2c; // err + List<@TA Top. @TB Outer. @TC IInner> k3c; // err + + + List<@TB Outer> g1r() { return null; } + + List<@TB Outer.Inner> g1ra() { return null; } // err + List<@TB Outer.SInner> g2ra() { return null; } // err + List<@TB Outer.IInner> g3ra() { return null; } // err + + List g1rb() { return null; } + List g2rb() { return null; } + List g3rb() { return null; } + + List<@TB Outer. @TC Inner> g1rc() { return null; } // err + List<@TB Outer. @TC SInner> g2rc() { return null; } // err + List<@TB Outer. @TC IInner> g3rc() { return null; } // err + + void g1param(List<@TB Outer> p, + List<@TB Outer.Inner> p1, // err + List p2, + List<@TB Outer. @TC Inner> p3) { } // err + void g2param(List<@TB Outer> p, + List<@TB Outer.SInner> p1, // err + List p2, + List<@TB Outer. @TC SInner> p3) { } // err + void g3param(List<@TB Outer> p, + List<@TB Outer.IInner> p1, // err + List p2, + List<@TB Outer. @TC IInner> p3) { } // err + + void g1new(Object o) { + Object l; + l = new @TB ArrayList<@TB Outer>(); + l = new @TB ArrayList<@TB Outer.Inner>(); // err + l = new @TB HashMap(); + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + } + void g2new(Object o) { + Object l; + l = new @TB ArrayList<@TB Outer>(); + l = new @TB ArrayList<@TB Outer.SInner>(); // err + l = new @TB HashMap(); + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + } + void g3new(Object o) { + Object l; + l = new @TB ArrayList<@TB Outer>(); + l = new @TB ArrayList<@TB Outer.IInner>(); // err + l = new @TB HashMap(); + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + } + void g4new(Object o) { + Object l; + l = new @TB ArrayList<@TA Top. @TB Outer>(); // err + l = new @TB ArrayList<@TA Top. @TB Outer.IInner>(); // err + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + l = new @TB HashMap(); // err + } +} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass3.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotateStaticClass3.out Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,83 @@ +CantAnnotateStaticClass3.java:44:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:45:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:46:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:52:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:53:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:54:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:56:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:57:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:58:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:59:23: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:61:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:62:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:63:21: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:65:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:66:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:67:25: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:71:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:72:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:73:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:79:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:80:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:81:16: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:84:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:86:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:88:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:90:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:92:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:94:24: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:57:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:58:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:59:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:65:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:66:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:67:12: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:99:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:101:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:106:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:108:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:113:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:115:18: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:120:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:121:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:122:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:128:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:129:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:130:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:132:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:134:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:135:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:136:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:138:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:139:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:140:14: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:142:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:143:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:144:17: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:149:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:150:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:151:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:157:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:158:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:159:14: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:162:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:164:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:166:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:168:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:170:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:172:22: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:177:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:179:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:180:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:185:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:187:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:188:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:193:35: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:195:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:196:41: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:200:35: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:201:38: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:202:41: compiler.err.cant.type.annotate.scoping.1: @Top.TA +CantAnnotateStaticClass3.java:203:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB +CantAnnotateStaticClass3.java:204:44: compiler.err.cant.type.annotate.scoping.1: @Top.TB +82 errors \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.java --- a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.java Tue Oct 15 15:57:13 2013 -0700 @@ -5,8 +5,11 @@ * @author Mahmood Ali * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics IncompleteArray.java */ +import java.lang.annotation.*; + class IncompleteArray { int @A [] @A var; } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.out --- a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/IncompleteArray.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,2 +1,2 @@ -IncompleteArray.java:9:13: compiler.err.illegal.start.of.type +IncompleteArray.java:11:13: compiler.err.illegal.start.of.type 1 error diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.java --- a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.java Tue Oct 15 22:15:35 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 8006775 - * @summary test incomplete vararg declaration - * @author Mahmood Ali - * @compile/fail/ref=IncompleteVararg.out -XDrawDiagnostics IncompleteVararg.java - */ -class IncompleteArray { - // the last variable may be vararg - void method(int @A test) { } -} - -@interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.out --- a/test/tools/javac/annotations/typeAnnotations/failures/IncompleteVararg.out Tue Oct 15 22:15:35 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -IncompleteVararg.java:10:19: compiler.err.illegal.start.of.type -1 error diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/IndexArray.java --- a/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.java Tue Oct 15 15:57:13 2013 -0700 @@ -5,9 +5,12 @@ * @author Mahmood Ali * @compile/fail/ref=IndexArray.out -XDrawDiagnostics IndexArray.java */ +import java.lang.annotation.*; + class IndexArray { int[] var; int a = var @A [1]; } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/IndexArray.out --- a/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/IndexArray.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,2 +1,2 @@ -IndexArray.java:10:15: compiler.err.illegal.start.of.expr +IndexArray.java:12:15: compiler.err.illegal.start.of.expr 1 error diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/LintCast.out --- a/test/tools/javac/annotations/typeAnnotations/failures/LintCast.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/LintCast.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,11 +1,11 @@ LintCast.java:15:21: compiler.warn.redundant.cast: java.lang.String LintCast.java:21:27: compiler.warn.redundant.cast: java.util.List -LintCast.java:27:20: compiler.warn.redundant.cast: int @A [] +LintCast.java:27:20: compiler.warn.redundant.cast: int[] LintCast.java:39:24: compiler.warn.redundant.cast: java.lang.String LintCast.java:40:26: compiler.warn.redundant.cast: java.lang.String -LintCast.java:45:23: compiler.warn.redundant.cast: java.lang.Object @A [] +LintCast.java:45:23: compiler.warn.redundant.cast: java.lang.Object[] LintCast.java:49:27: compiler.warn.redundant.cast: java.util.List -LintCast.java:53:27: compiler.warn.redundant.cast: java.util.List<@A java.lang.String> +LintCast.java:53:27: compiler.warn.redundant.cast: java.util.List LintCast.java:57:21: compiler.warn.redundant.cast: java.lang.Object LintCast.java:61:27: compiler.warn.redundant.cast: LintCast.Outer.Inner 10 warnings \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/OldArray.java --- a/test/tools/javac/annotations/typeAnnotations/failures/OldArray.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/OldArray.java Tue Oct 15 15:57:13 2013 -0700 @@ -1,35 +1,16 @@ /* - * Copyright (c) 2008, 2013, 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 /nodynamiccopyright/ * @test * @bug 6843077 8006775 * @summary test old array syntax * @author Mahmood Ali - * @compile/fail -XDrawDiagnostics OldArray.java + * @compile/fail/ref=OldArray.out -XDrawDiagnostics OldArray.java */ +import java.lang.annotation.*; + class OldArray { String [@A] s() { return null; } } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/OldArray.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/OldArray.out Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,10 @@ +OldArray.java:12:11: compiler.err.expected: ']' +OldArray.java:12:13: compiler.err.expected: token.identifier +OldArray.java:12:14: compiler.err.expected: ';' +OldArray.java:12:17: compiler.err.illegal.start.of.type +OldArray.java:12:18: compiler.err.expected: token.identifier +OldArray.java:12:19: compiler.err.expected: ';' +OldArray.java:12:22: compiler.err.illegal.start.of.type +OldArray.java:12:28: compiler.err.expected: token.identifier +OldArray.java:13:1: compiler.err.expected3: class, interface, enum +9 errors diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/Scopes.java --- a/test/tools/javac/annotations/typeAnnotations/failures/Scopes.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/Scopes.java Tue Oct 15 15:57:13 2013 -0700 @@ -1,17 +1,16 @@ /* * @test /nodynamiccopyright/ * @bug 6843077 8006775 - * @summary check that A is accessible in the class type parameters + * @summary Unqualified inner type annotation not in scope. * @author Mahmood Ali * @compile/fail/ref=Scopes.out -XDrawDiagnostics Scopes.java */ -class Scopes { - // UniqueInner is not visible in the type parameters. - // One has to use Scopes.UniqueInner. - // Annotations with the default @Target are not allowed there, - // so we also get the second error about the invalid location. - // Adding the target here doesn't matter, as we don't resolve - // the annotation type. - // @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) - @interface UniqueInner { }; +import java.lang.annotation.*; + +@InnerTA +class Scopes<@InnerTA T extends @InnerTA Object> { + // The simple name TA is not in scope on header of class. + // One has to use @Scopes.TA. + @Target(ElementType.TYPE_USE) + @interface InnerTA { }; } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/Scopes.out --- a/test/tools/javac/annotations/typeAnnotations/failures/Scopes.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/Scopes.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,3 +1,4 @@ -Scopes.java:8:25: compiler.err.cant.resolve: kindname.class, UniqueInner, , -Scopes.java:8:24: compiler.err.annotation.type.not.applicable -2 errors +Scopes.java:10:2: compiler.err.cant.resolve: kindname.class, InnerTA, , +Scopes.java:11:34: compiler.err.cant.resolve: kindname.class, InnerTA, , +Scopes.java:11:15: compiler.err.cant.resolve: kindname.class, InnerTA, , +3 errors diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java --- a/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.java Tue Oct 15 15:57:13 2013 -0700 @@ -5,9 +5,23 @@ * @author Mahmood Ali * @compile/fail/ref=StaticFields.out -XDrawDiagnostics StaticFields.java */ +import java.lang.annotation.*; + class C { - int f; + static int f; + // static block + static { + @A C.f = 1; + } + // static ref int a = @A C.f; + // static method + static int f() { return @A C.f; } + // main + public static void main(String... args) { + int a = @A C.f; + } } +@Target(ElementType.TYPE_USE) @interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/StaticFields.out --- a/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.out Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/StaticFields.out Tue Oct 15 15:57:13 2013 -0700 @@ -1,2 +1,5 @@ -StaticFields.java:10:17: compiler.err.illegal.start.of.expr -1 error +StaticFields.java:14:11: compiler.err.expected: token.identifier +StaticFields.java:17:17: compiler.err.illegal.start.of.expr +StaticFields.java:19:33: compiler.err.illegal.start.of.expr +StaticFields.java:22:19: compiler.err.illegal.start.of.expr +4 errors \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java --- a/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.java Tue Oct 15 22:15:35 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -/* - * @test /nodynamiccopyright/ - * @bug 6843077 8006775 - * @summary static methods don't have receivers - * @author Mahmood Ali - * @compile/fail/ref=StaticMethods.out -XDrawDiagnostics StaticMethods.java - */ -class StaticMethods { - static void main(StaticMethods this) { } -} - -@interface A { } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out --- a/test/tools/javac/annotations/typeAnnotations/failures/StaticMethods.out Tue Oct 15 22:15:35 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -StaticMethods.java:9:34: compiler.err.non-static.cant.be.ref: kindname.variable, this -1 error diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/TypeVariableCycleTest.java --- a/test/tools/javac/annotations/typeAnnotations/failures/TypeVariableCycleTest.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/annotations/typeAnnotations/failures/TypeVariableCycleTest.java Tue Oct 15 15:57:13 2013 -0700 @@ -35,10 +35,12 @@ class TypeVariableCycleTest { MTV cast(CTV p) { - return (@TA MTV) p; + return (@TB MTV) p; } } -@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) +@Target(ElementType.TYPE_USE) @interface TA {} +@Target(ElementType.TYPE_USE) +@interface TB {} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/TypeVariableMissingTA.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/TypeVariableMissingTA.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, 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 1234567 + * @summary A missing annotation type in a type variable bound + * should result in the same errors with and without an + * annotation processor. + * @author Werner Dietl + * + * @compile DummyProcessor.java + * @compile/fail/ref=TypeVariableMissingTA.out -XDrawDiagnostics TypeVariableMissingTA.java + * @compile/fail/ref=TypeVariableMissingTA.out -XDrawDiagnostics -cp . -processor DummyProcessor TypeVariableMissingTA.java + */ + +import java.lang.annotation.*; + +class TypeVariableMissingTA {} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/annotations/typeAnnotations/failures/TypeVariableMissingTA.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/typeAnnotations/failures/TypeVariableMissingTA.out Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,2 @@ +TypeVariableMissingTA.java:39:40: compiler.err.cant.resolve: kindname.class, MISSING, , +1 error \ No newline at end of file diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/diags/examples/CantAnnotateNestedType.java --- a/test/tools/javac/diags/examples/CantAnnotateNestedType.java Tue Oct 15 22:15:35 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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.cant.annotate.nested.type - -import java.lang.annotation.*; - -class CantAnnotateStaticClass { - @Target(ElementType.TYPE_USE) - @interface A {} - - interface Outer { - interface Inner {} - } - - // Error: - @A Outer.Inner f; - - // OK: - @A Outer g; -} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/diags/examples/CantAnnotateScoping.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/CantAnnotateScoping.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, 2013, 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.cant.type.annotate.scoping + +import java.lang.annotation.*; + +class CantAnnotateScoping { + @Target(ElementType.TYPE_USE) + @interface TA {} + @Target(ElementType.TYPE_USE) + @interface TB {} + + interface Outer { + interface Inner {} + } + + // Error: + @TA @TB Outer.Inner f; + + // OK: + @TA @TB Outer g; +} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/diags/examples/CantAnnotateScoping1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/diags/examples/CantAnnotateScoping1.java Tue Oct 15 15:57:13 2013 -0700 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2012, 2013, 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.cant.type.annotate.scoping.1 + +import java.lang.annotation.*; + +class CantAnnotateNestedType { + @Target(ElementType.TYPE_USE) + @interface TA {} + + interface Outer { + interface Inner {} + } + + // Error: + @TA Outer.Inner f; + + // OK: + @TA Outer g; +} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/diags/examples/CantAnnotateStaticClass.java --- a/test/tools/javac/diags/examples/CantAnnotateStaticClass.java Tue Oct 15 22:15:35 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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.cant.annotate.static.class - -import java.lang.annotation.*; - -class CantAnnotateStaticClass { - @Target(ElementType.TYPE_USE) - @interface A {} - - static class Outer { - class Inner {} - } - - // Error: - @A Outer.Inner f; - - // OK: - @A Outer g; -} diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/lib/DPrinter.java --- a/test/tools/javac/lib/DPrinter.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/lib/DPrinter.java Tue Oct 15 15:57:13 2013 -0700 @@ -946,8 +946,8 @@ */ public class TypeVisitor implements Type.Visitor { public Void visitAnnotatedType(AnnotatedType type, Void ignore) { - printList("typeAnnotations", type.typeAnnotations); - printType("underlyingType", type.underlyingType, Details.FULL); + printList("typeAnnotations", type.getAnnotationMirrors()); + printType("underlyingType", type.unannotatedType(), Details.FULL); return visitType(type, null); } diff -r 19e8eebfbe52 -r b0c086cd4520 test/tools/javac/processing/model/type/BasicAnnoTests.java --- a/test/tools/javac/processing/model/type/BasicAnnoTests.java Tue Oct 15 22:15:35 2013 +0200 +++ b/test/tools/javac/processing/model/type/BasicAnnoTests.java Tue Oct 15 15:57:13 2013 -0700 @@ -26,6 +26,7 @@ * @bug 1234567 * @summary Annotations on types * @library /tools/javac/lib + * @ignore * @build JavacTestingAbstractProcessor DPrinter BasicAnnoTests * @compile/process -processor BasicAnnoTests -proc:only BasicAnnoTests.java */