changeset 4307:fc0a38e90a7c

8138822: Source version error missing version number Reviewed-by: jjg
author dlsmith
date Fri, 16 Sep 2016 11:58:23 -0600
parents 013e3e406ddf
children 6077dc32728a
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out
diffstat 4 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Thu Sep 15 21:08:49 2016 +0000
+++ b/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/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/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/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