--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Thu Sep 15 21:08:49 2016 +0000
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Sep 16 11:58:23 2016 -0600
@@ -92,6 +92,7 @@
private final Attribute theUnfinishedDefaultValue;
private final boolean allowRepeatedAnnos;
+ private final String sourceName;
protected Annotate(Context context) {
context.put(annotateKey, this);
@@ -114,6 +115,7 @@
Source source = Source.instance(context);
allowRepeatedAnnos = source.allowRepeatedAnnotations();
+ sourceName = source.name;
}
/** Semaphore to delay annotation processing */
@@ -322,7 +324,7 @@
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);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java Fri Sep 16 11:58:23 2016 -0600
@@ -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();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out Fri Sep 16 11:58:23 2016 -0600
@@ -0,0 +1,2 @@
+WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.6
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out Fri Sep 16 11:58:23 2016 -0600
@@ -0,0 +1,2 @@
+WrongVersion.java:12:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.7
+1 error