1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Mar 12 16:02:43 2013 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java Tue Mar 12 17:39:34 2013 +0100 1.3 @@ -384,10 +384,16 @@ 1.4 Assert.check(!annotations.isEmpty() && 1.5 !annotations.tail.isEmpty()); // i.e. size() > 1 1.6 1.7 + int count = 0; 1.8 for (List<T> al = annotations; 1.9 !al.isEmpty(); 1.10 al = al.tail) 1.11 { 1.12 + count++; 1.13 + 1.14 + // There must be more than a single anno in the annotation list 1.15 + Assert.check(count > 1 || !al.tail.isEmpty()); 1.16 + 1.17 T currentAnno = al.head; 1.18 1.19 origAnnoType = currentAnno.type; 1.20 @@ -395,7 +401,9 @@ 1.21 arrayOfOrigAnnoType = types.makeArrayType(origAnnoType); 1.22 } 1.23 1.24 - Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno)); 1.25 + // Only report errors if this isn't the first occurrence I.E. count > 1 1.26 + boolean reportError = count > 1; 1.27 + Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno), reportError); 1.28 if (currentContainerType == null) { 1.29 continue; 1.30 } 1.31 @@ -464,7 +472,8 @@ 1.32 1.33 /** Fetches the actual Type that should be the containing annotation. */ 1.34 private Type getContainingType(Attribute.Compound currentAnno, 1.35 - DiagnosticPosition pos) 1.36 + DiagnosticPosition pos, 1.37 + boolean reportError) 1.38 { 1.39 Type origAnnoType = currentAnno.type; 1.40 TypeSymbol origAnnoDecl = origAnnoType.tsym; 1.41 @@ -473,7 +482,8 @@ 1.42 // annotation's declaration, or null if it has none 1.43 Attribute.Compound ca = origAnnoDecl.attribute(syms.repeatableType.tsym); 1.44 if (ca == null) { // has no Repeatable annotation 1.45 - log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType); 1.46 + if (reportError) 1.47 + log.error(pos, "duplicate.annotation.missing.container", origAnnoType, syms.repeatableType); 1.48 return null; 1.49 } 1.50