8138822: Source version error missing version number
Reviewed-by: jjg
This commit is contained in:
parent
5961266aa9
commit
eb56700eba
@ -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);
|
||||
|
@ -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();
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.6
|
||||
1 error
|
@ -0,0 +1,2 @@
|
||||
WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.7
|
||||
1 error
|
Loading…
x
Reference in New Issue
Block a user