8138822: Source version error missing version number

Reviewed-by: jjg
This commit is contained in:
Dan Smith 2016-09-16 11:58:23 -06:00
parent 5961266aa9
commit eb56700eba
4 changed files with 30 additions and 1 deletions

View File

@ -92,6 +92,7 @@ public class Annotate {
private final Attribute theUnfinishedDefaultValue;
private final boolean allowRepeatedAnnos;
private final String sourceName;
protected Annotate(Context context) {
context.put(annotateKey, this);
@ -114,6 +115,7 @@ public class Annotate {
Source source = Source.instance(context);
allowRepeatedAnnos = source.allowRepeatedAnnotations();
sourceName = source.name;
}
/** Semaphore to delay annotation processing */
@ -322,7 +324,7 @@ public class Annotate {
if (annotated.containsKey(a.type.tsym)) {
if (!allowRepeatedAnnos) {
log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), "repeatable.annotations.not.supported.in.source");
log.error(DiagnosticFlag.SOURCE_LEVEL, a.pos(), "repeatable.annotations.not.supported.in.source", sourceName);
}
ListBuffer<T> l = annotated.get(a.type.tsym);
l = l.append(c);

View File

@ -0,0 +1,23 @@
/*
* @test /nodynamiccopyright/
* @bug 8138822
* @summary test that only Java 8+ allows repeating annotations
* @compile WrongVersion.java
* @compile -Xlint:-options -source 8 WrongVersion.java
* @compile/fail/ref=WrongVersion7.out -XDrawDiagnostics -Xlint:-options -source 7 WrongVersion.java
* @compile/fail/ref=WrongVersion6.out -XDrawDiagnostics -Xlint:-options -source 6 WrongVersion.java
*/
import java.lang.annotation.Repeatable;
@Ann(1) @Ann(2)
class C {
}
@Repeatable(AnnContainer.class)
@interface Ann {
int value();
}
@interface AnnContainer {
Ann[] value();
}

View File

@ -0,0 +1,2 @@
WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.6
1 error

View File

@ -0,0 +1,2 @@
WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.7
1 error