RFR: JDK-8138822 Source version error missing version number

Dan Smith daniel.smith at oracle.com
Thu Sep 15 17:34:48 UTC 2016


This is a trivial fix for an error message that is missing a parameter. Just need a quick review.

https://bugs.openjdk.java.net/browse/JDK-8138822

Patch is below.

—Dan

---------------------

# HG changeset patch
# Parent 6e028413ea0835895813b3c84d78cc46e815cf07

diff -r 6e028413ea08 src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Wed Sep 14 20:00:20 2016 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java	Wed Sep 14 16:45:20 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);
diff -r 6e028413ea08 test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/WrongVersion.java	Wed Sep 14 16:45:20 2016 -0600
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8138822
+ * @summary test that only Java 8+ allows repeating annotations
+ * @compile WrongVersion.java
+ * @compile/fail/ref=WrongVersion6.out -XDrawDiagnostics -Xlint:-options -source 6 WrongVersion.java
+ * @compile/fail/ref=WrongVersion7.out -XDrawDiagnostics -Xlint:-options -source 7 WrongVersion.java
+ */
+import java.lang.annotation.Repeatable;
+
+ at Ann(1) @Ann(2)
+class C {
+}
+
+ at Repeatable(AnnContainer.class)
+ at interface Ann {
+    int value();
+}
+
+ at interface AnnContainer {
+    Ann[] value();
+}
diff -r 6e028413ea08 test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/WrongVersion6.out	Wed Sep 14 16:45:20 2016 -0600
@@ -0,0 +1,2 @@
+WrongVersion.java:11:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.6
+1 error
diff -r 6e028413ea08 test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/WrongVersion7.out	Wed Sep 14 16:45:20 2016 -0600
@@ -0,0 +1,2 @@
+WrongVersion.java:11:9: compiler.err.repeatable.annotations.not.supported.in.source: 1.7
+1 error



More information about the compiler-dev mailing list